diff options
author | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-03-28 15:40:28 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-04-03 11:07:07 +0200 |
commit | 4bbf313e9d3cab70c6dab6da4c03bf2ad60aa760 (patch) | |
tree | da7d22709196427b4ecdb80b42e7a1f28cdef425 /src/gui/painting | |
parent | afacf694d5a6f34b88989e76971d70d700ce4949 (diff) |
Fix UI squishing when using QWidget::setRenderToTexture
When resizing a window, a window might not be resized synchronously with
its backing store. We need to use the actual texture size as the transform
to avoid stretching the rendered texture.
Change-Id: I945f6d190577ccdcb54483a267a1e42df1ca3156
Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Diffstat (limited to 'src/gui/painting')
-rw-r--r-- | src/gui/painting/qplatformbackingstore.cpp | 10 | ||||
-rw-r--r-- | src/gui/painting/qplatformbackingstore.h | 2 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp index 710d84e3aa..6425aa065e 100644 --- a/src/gui/painting/qplatformbackingstore.cpp +++ b/src/gui/painting/qplatformbackingstore.cpp @@ -247,14 +247,14 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion ®i d_ptr->blitter->blit(textureId, target, QOpenGLTextureBlitter::OriginBottomLeft); } - GLuint textureId = toTexture(deviceRegion(region, window)); + GLuint textureId = toTexture(deviceRegion(region, window), &d_ptr->textureSize); if (!textureId) return; funcs->glEnable(GL_BLEND); funcs->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(windowRect, windowRect); + QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(QRect(QPoint(), d_ptr->textureSize), windowRect); d_ptr->blitter->setSwizzleRB(true); d_ptr->blitter->blit(textureId, target, QOpenGLTextureBlitter::OriginTopLeft); d_ptr->blitter->setSwizzleRB(false); @@ -282,6 +282,7 @@ QImage QPlatformBackingStore::toImage() const backingstore as an OpenGL texture. \a dirtyRegion is the part of the backingstore which may have changed since the last call to this function. The caller of this function must ensure that there is a current context. + The size of the texture is returned in \a textureSize. The ownership of the texture is not transferred. The caller must not store the return value between calls, but instead call this function before each use. @@ -291,7 +292,7 @@ QImage QPlatformBackingStore::toImage() const content using toImage() and performs a texture upload. */ -GLuint QPlatformBackingStore::toTexture(const QRegion &dirtyRegion) const +GLuint QPlatformBackingStore::toTexture(const QRegion &dirtyRegion, QSize *textureSize) const { QImage image = toImage(); QSize imageSize = image.size(); @@ -325,7 +326,8 @@ GLuint QPlatformBackingStore::toTexture(const QRegion &dirtyRegion) const funcs->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, imageSize.width(), imageSize.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, const_cast<uchar*>(image.constBits())); - d_ptr->textureSize = imageSize; + if (textureSize) + *textureSize = imageSize; } else { funcs->glBindTexture(GL_TEXTURE_2D, d_ptr->textureId); QRect imageRect = image.rect(); diff --git a/src/gui/painting/qplatformbackingstore.h b/src/gui/painting/qplatformbackingstore.h index 76fd3d40b4..4728622cac 100644 --- a/src/gui/painting/qplatformbackingstore.h +++ b/src/gui/painting/qplatformbackingstore.h @@ -111,7 +111,7 @@ public: #ifndef QT_NO_OPENGL virtual void composeAndFlush(QWindow *window, const QRegion ®ion, const QPoint &offset, QPlatformTextureList *textures, QOpenGLContext *context); virtual QImage toImage() const; - virtual GLuint toTexture(const QRegion &dirtyRegion) const; + virtual GLuint toTexture(const QRegion &dirtyRegion, QSize *textureSize) const; #endif virtual void resize(const QSize &size, const QRegion &staticContents) = 0; |