summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikolaj Boc <mikolaj.boc@qt.io>2022-08-16 16:45:07 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-08-20 00:51:20 +0000
commitbf945666945951d63f9d588f52111760e0c35689 (patch)
treec3fa350ddbcd21d6fa9873baa0b3c379bab861e6
parente70018c8141d5b58d10c1050aa9034cf6f10fe0c (diff)
Avoid image format conversion when drawing window nonclient area
This radically speeds up window resizing and dragging. Fixes: QTBUG-105709 Change-Id: I844601a5b139d21024db0c373482af18f350d0eb Reviewed-by: Lorn Potter <lorn.potter@gmail.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit 2a23652bbbba8def270b78d76c91a5a96d391106) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/plugins/platforms/wasm/qwasmcompositor.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/plugins/platforms/wasm/qwasmcompositor.cpp b/src/plugins/platforms/wasm/qwasmcompositor.cpp
index f804542b34..9a83b62b5b 100644
--- a/src/plugins/platforms/wasm/qwasmcompositor.cpp
+++ b/src/plugins/platforms/wasm/qwasmcompositor.cpp
@@ -546,7 +546,7 @@ void QWasmCompositor::drawWindowDecorations(QOpenGLTextureBlitter *blitter, QWas
int height = window->windowFrameGeometry().height();
qreal dpr = window->devicePixelRatio();
- QImage image(QSize(width * dpr, height * dpr), QImage::Format_RGB32);
+ QImage image(QSize(width * dpr, height * dpr), QImage::Format_ARGB32_Premultiplied);
image.setDevicePixelRatio(dpr);
QPainter painter(&image);
painter.fillRect(QRect(0, 0, width, height), painter.background());
@@ -567,12 +567,19 @@ void QWasmCompositor::drawWindowDecorations(QOpenGLTextureBlitter *blitter, QWas
texture.setMinificationFilter(QOpenGLTexture::Nearest);
texture.setMagnificationFilter(QOpenGLTexture::Nearest);
texture.setWrapMode(QOpenGLTexture::ClampToEdge);
- texture.setData(image, QOpenGLTexture::DontGenerateMipMaps);
+ texture.setFormat(QOpenGLTexture::RGBAFormat);
+ texture.setSize(image.width(), image.height());
+ texture.setMipLevels(1);
+ texture.allocateStorage(QOpenGLTexture::RGBA, QOpenGLTexture::UInt8);
+
+ QOpenGLPixelTransferOptions uploadOptions;
+ uploadOptions.setAlignment(1);
+
texture.create();
texture.bind();
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, image.width(), image.height(), GL_RGBA, GL_UNSIGNED_BYTE,
- image.constScanLine(0));
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, image.width(), image.height(), GL_RGBA,
+ GL_UNSIGNED_BYTE, image.constScanLine(0));
QRect windowCanvasGeometry = window->windowFrameGeometry().translated(-screen->geometry().topLeft());
blit(blitter, screen, &texture, windowCanvasGeometry);