From 64857434e29c367191b653e24e0fe672c13eb2b1 Mon Sep 17 00:00:00 2001 From: Frank Meerkoetter Date: Fri, 18 Dec 2015 21:39:49 +0100 Subject: Fix broken permission to mode mapping Fixes coverity CID154258. Change-Id: Ia958d24c533c4f0077abd363ee4c041cc2cdb6f0 Reviewed-by: Konstantin Ritt --- src/gui/text/qzip.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/gui') diff --git a/src/gui/text/qzip.cpp b/src/gui/text/qzip.cpp index be002167cb..31ef8f87be 100644 --- a/src/gui/text/qzip.cpp +++ b/src/gui/text/qzip.cpp @@ -243,11 +243,11 @@ static QFile::Permissions modeToPermissions(quint32 mode) static quint32 permissionsToMode(QFile::Permissions perms) { quint32 mode = 0; - if (mode & (QFile::ReadOwner | QFile::ReadUser)) + if (perms & (QFile::ReadOwner | QFile::ReadUser)) mode |= UnixFileAttributes::ReadUser; - if (mode & (QFile::WriteOwner | QFile::WriteUser)) + if (perms & (QFile::WriteOwner | QFile::WriteUser)) mode |= UnixFileAttributes::WriteUser; - if (mode & (QFile::ExeOwner | QFile::ExeUser)) + if (perms & (QFile::ExeOwner | QFile::ExeUser)) mode |= UnixFileAttributes::WriteUser; if (perms & QFile::ReadGroup) mode |= UnixFileAttributes::ReadGroup; -- cgit v1.2.3 From eaa3a9d0108cdf692f1686cafefb7b834f0e5af6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Szczygie=C5=82?= Date: Fri, 1 Jan 2016 20:02:42 +0100 Subject: Fix crash because of NULL screen in QXcbWindow Change-Id: If7bbe3ad1656dadcb098bcd3ece2e7b064eeb44d Task-number: QTBUG-50081 Reviewed-by: Shawn Rutledge --- src/gui/kernel/qwindow.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index e728d32e4b..83e8777627 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -609,18 +609,16 @@ void QWindow::setParent(QWindow *parent) } QObject::setParent(parent); - if (parent) + + QPlatformWindow *parentPlatformWindow = parent ? parent->d_func()->platformWindow : Q_NULLPTR; + + if (parentPlatformWindow) d->disconnectFromScreen(); else d->connectToScreen(newScreen); - if (d->platformWindow) { - if (parent && parent->d_func()->platformWindow) { - d->platformWindow->setParent(parent->d_func()->platformWindow); - } else { - d->platformWindow->setParent(0); - } - } + if (d->platformWindow) + d->platformWindow->setParent(parentPlatformWindow); d->parentWindow = parent; -- cgit v1.2.3 From c19216cbeab53b5de249dc2a31e6555f013e6be0 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 15 Dec 2015 13:17:35 +0100 Subject: Fix QPainter::rotate() documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I5d11f84181cad9be644e850c83459b47ec2f2f15 Reviewed-by: Topi Reiniƶ --- src/gui/painting/qpainter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index e80c0130c3..5dcab11f0a 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -3154,7 +3154,7 @@ void QPainter::shear(qreal sh, qreal sv) /*! \fn void QPainter::rotate(qreal angle) - Rotates the coordinate system clockwise. The given \a angle parameter uses degree unit. + Rotates the coordinate system clockwise. The given \a angle parameter is in degrees. \sa setWorldTransform(), {QPainter#Coordinate Transformations}{Coordinate Transformations} */ -- cgit v1.2.3 From 0cee94017f441be09518a190ac1c4cbd8a76adc6 Mon Sep 17 00:00:00 2001 From: Mauro Persano Date: Thu, 24 Dec 2015 14:15:19 -0200 Subject: QOpenGLTexture: fix target for compressed textures Trying to set data for a compressed cubemap texture face fails, because the code incorrectly tries to bind to a cubemap face target. This was already fixed for uncompressed textures. Instead of duplicating the code, moved the texture binding/unbinding code to a RAII class. Change-Id: I8f1cb7fc661b919200f85c3465d6e6e3c22d0871 Reviewed-by: Sean Harmer --- src/gui/opengl/qopengltexturehelper.cpp | 208 +++++++++++--------------------- 1 file changed, 70 insertions(+), 138 deletions(-) (limited to 'src/gui') diff --git a/src/gui/opengl/qopengltexturehelper.cpp b/src/gui/opengl/qopengltexturehelper.cpp index bf8b514449..df2945a479 100644 --- a/src/gui/opengl/qopengltexturehelper.cpp +++ b/src/gui/opengl/qopengltexturehelper.cpp @@ -453,260 +453,192 @@ void QOpenGLTextureHelper::dsa_CompressedTextureImage3D(GLuint texture, GLenum t CompressedTextureImage3DEXT(texture, target, level, internalFormat, width, height, depth, border, imageSize, bits); } +namespace { + +class TextureBinder +{ +public: + TextureBinder(QOpenGLTextureHelper *textureFunctions, GLuint texture, GLenum target, GLenum bindingTarget) + : m_textureFunctions(textureFunctions) + { + // For cubemaps we can't use the standard DSA emulation as it is illegal to + // try to bind a texture to one of the cubemap face targets. So we force the + // target and binding target to the cubemap values in this case. + switch (target) { + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + bindingTarget = GL_TEXTURE_BINDING_CUBE_MAP; + m_target = GL_TEXTURE_CUBE_MAP; + break; + + default: + m_target = target; + break; + } + + m_textureFunctions->glGetIntegerv(bindingTarget, &m_oldTexture); + m_textureFunctions->glBindTexture(m_target, texture); + } + + ~TextureBinder() + { + m_textureFunctions->glBindTexture(m_target, m_oldTexture); + } + +private: + QOpenGLTextureHelper *m_textureFunctions; + GLenum m_target; + GLint m_oldTexture; +}; + +} // namespace + void QOpenGLTextureHelper::qt_TextureParameteri(GLuint texture, GLenum target, GLenum bindingTarget, GLenum pname, GLint param) { - GLint oldTexture; - glGetIntegerv(bindingTarget, &oldTexture); - glBindTexture(target, texture); + TextureBinder binder(this, texture, target, bindingTarget); glTexParameteri(target, pname, param); - glBindTexture(target, oldTexture); } void QOpenGLTextureHelper::qt_TextureParameteriv(GLuint texture, GLenum target, GLenum bindingTarget, GLenum pname, const GLint *params) { - GLint oldTexture; - glGetIntegerv(bindingTarget, &oldTexture); - glBindTexture(target, texture); + TextureBinder binder(this, texture, target, bindingTarget); glTexParameteriv(target, pname, params); - glBindTexture(target, oldTexture); } void QOpenGLTextureHelper::qt_TextureParameterf(GLuint texture, GLenum target, GLenum bindingTarget, GLenum pname, GLfloat param) { - GLint oldTexture; - glGetIntegerv(bindingTarget, &oldTexture); - glBindTexture(target, texture); + TextureBinder binder(this, texture, target, bindingTarget); glTexParameterf(target, pname, param); - glBindTexture(target, oldTexture); } void QOpenGLTextureHelper::qt_TextureParameterfv(GLuint texture, GLenum target, GLenum bindingTarget, GLenum pname, const GLfloat *params) { - GLint oldTexture; - glGetIntegerv(bindingTarget, &oldTexture); - glBindTexture(target, texture); + TextureBinder binder(this, texture, target, bindingTarget); glTexParameterfv(target, pname, params); - glBindTexture(target, oldTexture); } void QOpenGLTextureHelper::qt_GenerateTextureMipmap(GLuint texture, GLenum target, GLenum bindingTarget) { - GLint oldTexture; - glGetIntegerv(bindingTarget, &oldTexture); - glBindTexture(target, texture); + TextureBinder binder(this, texture, target, bindingTarget); glGenerateMipmap(target); - glBindTexture(target, oldTexture); } void QOpenGLTextureHelper::qt_TextureStorage3D(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth) { - GLint oldTexture; - glGetIntegerv(bindingTarget, &oldTexture); - glBindTexture(target, texture); + TextureBinder binder(this, texture, target, bindingTarget); glTexStorage3D(target, levels, internalFormat, width, height, depth); - glBindTexture(target, oldTexture); } void QOpenGLTextureHelper::qt_TextureStorage2D(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height) { - GLint oldTexture; - glGetIntegerv(bindingTarget, &oldTexture); - glBindTexture(target, texture); + TextureBinder binder(this, texture, target, bindingTarget); glTexStorage2D(target, levels, internalFormat, width, height); - glBindTexture(target, oldTexture); } void QOpenGLTextureHelper::qt_TextureStorage1D(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei levels, GLenum internalFormat, GLsizei width) { - GLint oldTexture; - glGetIntegerv(bindingTarget, &oldTexture); - glBindTexture(target, texture); + TextureBinder binder(this, texture, target, bindingTarget); glTexStorage1D(target, levels, internalFormat, width); - glBindTexture(target, oldTexture); } void QOpenGLTextureHelper::qt_TextureStorage3DMultisample(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations) { - GLint oldTexture; - glGetIntegerv(bindingTarget, &oldTexture); - glBindTexture(target, texture); + TextureBinder binder(this, texture, target, bindingTarget); glTexStorage3DMultisample(target, samples, internalFormat, width, height, depth, fixedSampleLocations); - glBindTexture(target, oldTexture); } void QOpenGLTextureHelper::qt_TextureStorage2DMultisample(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations) { - GLint oldTexture; - glGetIntegerv(bindingTarget, &oldTexture); - glBindTexture(target, texture); + TextureBinder binder(this, texture, target, bindingTarget); glTexStorage2DMultisample(target, samples, internalFormat, width, height, fixedSampleLocations); - glBindTexture(target, oldTexture); } void QOpenGLTextureHelper::qt_TextureImage3D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels) { - GLint oldTexture; - glGetIntegerv(bindingTarget, &oldTexture); - glBindTexture(target, texture); + TextureBinder binder(this, texture, target, bindingTarget); glTexImage3D(target, level, internalFormat, width, height, depth, border, format, type, pixels); - glBindTexture(target, oldTexture); } void QOpenGLTextureHelper::qt_TextureImage2D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) { - // For cubemaps we can't use the standard DSA emulation as it is illegal to - // try to bind a texture to one of the cubemap face targets. So we force the - // target and binding target to the cubemap values in this case. - GLint oldTexture; - - switch (target) { - case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: - case GL_TEXTURE_CUBE_MAP_POSITIVE_X: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: - glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP, &oldTexture); - glBindTexture(GL_TEXTURE_CUBE_MAP, texture); - glTexImage2D(target, level, internalFormat, width, height, border, format, type, pixels); - glBindTexture(GL_TEXTURE_CUBE_MAP, oldTexture); - break; - - default: - glGetIntegerv(bindingTarget, &oldTexture); - glBindTexture(target, texture); - glTexImage2D(target, level, internalFormat, width, height, border, format, type, pixels); - glBindTexture(target, oldTexture); - break; - } + TextureBinder binder(this, texture, target, bindingTarget); + glTexImage2D(target, level, internalFormat, width, height, border, format, type, pixels); } void QOpenGLTextureHelper::qt_TextureImage1D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels) { - GLint oldTexture; - glGetIntegerv(bindingTarget, &oldTexture); - glBindTexture(target, texture); + TextureBinder binder(this, texture, target, bindingTarget); glTexImage1D(target, level, internalFormat, width, border, format, type, pixels); - glBindTexture(target, oldTexture); } void QOpenGLTextureHelper::qt_TextureSubImage3D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels) { - GLint oldTexture; - glGetIntegerv(bindingTarget, &oldTexture); - glBindTexture(target, texture); + TextureBinder binder(this, texture, target, bindingTarget); glTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); - glBindTexture(target, oldTexture); } void QOpenGLTextureHelper::qt_TextureSubImage2D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels) { - // For cubemaps we can't use the standard DSA emulation as it is illegal to - // try to bind a texture to one of the cubemap face targets. So we force the - // target and binding target to the cubemap values in this case. - GLint oldTexture; - - switch (target) { - case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: - case GL_TEXTURE_CUBE_MAP_POSITIVE_X: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: - glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP, &oldTexture); - glBindTexture(GL_TEXTURE_CUBE_MAP, texture); - glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); - glBindTexture(GL_TEXTURE_CUBE_MAP, oldTexture); - break; - - default: - glGetIntegerv(bindingTarget, &oldTexture); - glBindTexture(target, texture); - glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); - glBindTexture(target, oldTexture); - break; - } + TextureBinder binder(this, texture, target, bindingTarget); + glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); } void QOpenGLTextureHelper::qt_TextureSubImage1D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels) { - GLint oldTexture; - glGetIntegerv(bindingTarget, &oldTexture); - glBindTexture(target, texture); + TextureBinder binder(this, texture, target, bindingTarget); glTexSubImage1D(target, level, xoffset, width, format, type, pixels); - glBindTexture(target, oldTexture); } void QOpenGLTextureHelper::qt_TextureImage3DMultisample(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations) { - GLint oldTexture; - glGetIntegerv(bindingTarget, &oldTexture); - glBindTexture(target, texture); + TextureBinder binder(this, texture, target, bindingTarget); glTexImage3DMultisample(target, samples, internalFormat, width, height, depth, fixedSampleLocations); - glBindTexture(target, oldTexture); } void QOpenGLTextureHelper::qt_TextureImage2DMultisample(GLuint texture, GLenum target, GLenum bindingTarget, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations) { - GLint oldTexture; - glGetIntegerv(bindingTarget, &oldTexture); - glBindTexture(target, texture); + TextureBinder binder(this, texture, target, bindingTarget); glTexImage2DMultisample(target, samples, internalFormat, width, height, fixedSampleLocations); - glBindTexture(target, oldTexture); } void QOpenGLTextureHelper::qt_CompressedTextureSubImage1D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits) { - GLint oldTexture; - glGetIntegerv(bindingTarget, &oldTexture); - glBindTexture(target, texture); + TextureBinder binder(this, texture, target, bindingTarget); glCompressedTexSubImage1D(target, level, xoffset, width, format, imageSize, bits); - glBindTexture(target, oldTexture); } void QOpenGLTextureHelper::qt_CompressedTextureSubImage2D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits) { - GLint oldTexture; - glGetIntegerv(bindingTarget, &oldTexture); - glBindTexture(target, texture); + TextureBinder binder(this, texture, target, bindingTarget); glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, bits); - glBindTexture(target, oldTexture); } void QOpenGLTextureHelper::qt_CompressedTextureSubImage3D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits) { - GLint oldTexture; - glGetIntegerv(bindingTarget, &oldTexture); - glBindTexture(target, texture); + TextureBinder binder(this, texture, target, bindingTarget); glCompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, bits); - glBindTexture(target, oldTexture); } void QOpenGLTextureHelper::qt_CompressedTextureImage1D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits) { - GLint oldTexture; - glGetIntegerv(bindingTarget, &oldTexture); - glBindTexture(target, texture); + TextureBinder binder(this, texture, target, bindingTarget); glCompressedTexImage1D(target, level, internalFormat, width, border, imageSize, bits); - glBindTexture(target, oldTexture); } void QOpenGLTextureHelper::qt_CompressedTextureImage2D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits) { - GLint oldTexture; - glGetIntegerv(bindingTarget, &oldTexture); - glBindTexture(target, texture); + TextureBinder binder(this, texture, target, bindingTarget); glCompressedTexImage2D(target, level, internalFormat, width, height, border, imageSize, bits); - glBindTexture(target, oldTexture); } void QOpenGLTextureHelper::qt_CompressedTextureImage3D(GLuint texture, GLenum target, GLenum bindingTarget, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits) { - GLint oldTexture; - glGetIntegerv(bindingTarget, &oldTexture); - glBindTexture(target, texture); + TextureBinder binder(this, texture, target, bindingTarget); glCompressedTexImage3D(target, level, internalFormat, width, height, depth, border, imageSize, bits); - glBindTexture(target, oldTexture); } QT_END_NAMESPACE -- cgit v1.2.3 From a1702da020906e1fb5b293257d87209f1795809b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Tue, 5 Jan 2016 14:09:30 +0000 Subject: Don't detach QGradientStops Change-Id: I1ae84d0ae825e9fb474d4fab45b0c475a3878b25 Reviewed-by: David Faure --- src/gui/painting/qpaintengine_raster.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 207e31d91a..d71297bd60 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -4150,7 +4150,7 @@ public: inline const QRgba64 *getBuffer(const QGradient &gradient, int opacity) { quint64 hash_val = 0; - QGradientStops stops = gradient.stops(); + const QGradientStops stops = gradient.stops(); for (int i = 0; i < stops.size() && i <= 2; i++) hash_val += stops[i].second.rgba64(); -- cgit v1.2.3 From b1dcdc406446a5e1eb5a7e04d984fed91ceb52ec Mon Sep 17 00:00:00 2001 From: Volker Krause Date: Tue, 5 Jan 2016 15:17:11 +0100 Subject: Avoid unnecessary detaching of the pending deletions list. This code seems to be hit three times per frame in a hybrid QQ2/Qt3D app, quickly generating thousands of allocations here via the detach in begin(). Heaptrack confirms they are all gone now. Change-Id: I7d09f3f5c2b24a2590b701216715055751306e82 Reviewed-by: Sean Harmer Reviewed-by: Marc Mutz --- src/gui/kernel/qopenglcontext.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index 85d05959de..3c033ea39e 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -1459,11 +1459,11 @@ void QOpenGLContextGroupPrivate::deletePendingResources(QOpenGLContext *ctx) { QMutexLocker locker(&m_mutex); - QList pending = m_pendingDeletion; + const QList pending = m_pendingDeletion; m_pendingDeletion.clear(); - QList::iterator it = pending.begin(); - QList::iterator end = pending.end(); + QList::const_iterator it = pending.begin(); + QList::const_iterator end = pending.end(); while (it != end) { (*it)->freeResource(ctx); delete *it; -- cgit v1.2.3 From f3114120f2d6f81f424ee542635c2711f66b516b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Szczygie=C5=82?= Date: Tue, 5 Jan 2016 00:58:50 +0100 Subject: QtGui: Don't set a screen to a child window This is a partial revert of eaa3a9d0108cdf692f1686cafefb7b834f0e5af6 Task-number: QTBUG-50081 Change-Id: Ic3dc4daa90d7a968a4ebf45d3029c99a12985686 Reviewed-by: Shawn Rutledge --- src/gui/kernel/qwindow.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 83e8777627..21734f1619 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -609,18 +609,20 @@ void QWindow::setParent(QWindow *parent) } QObject::setParent(parent); + d->parentWindow = parent; - QPlatformWindow *parentPlatformWindow = parent ? parent->d_func()->platformWindow : Q_NULLPTR; - - if (parentPlatformWindow) + if (parent) d->disconnectFromScreen(); else d->connectToScreen(newScreen); - if (d->platformWindow) - d->platformWindow->setParent(parentPlatformWindow); - - d->parentWindow = parent; + if (d->platformWindow) { + if (parent && parent->d_func()->platformWindow) { + d->platformWindow->setParent(parent->d_func()->platformWindow); + } else { + d->platformWindow->setParent(0); + } + } QGuiApplicationPrivate::updateBlockedStatus(this); } -- cgit v1.2.3 From 7e28079484ec12ce0609419262b869354e7678a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Szczygie=C5=82?= Date: Tue, 5 Jan 2016 15:25:12 +0100 Subject: QtGui: Fix obtaining the top level window at a point Find the top level window on the primary virtual desktop first to avoid obtaining a window which doesn't belong to the primary virtual desktop when screen geometry is similar. Change-Id: I78fdfa0b5146d0ba9b912338adeb612c102c4ac3 Reviewed-by: Adam Majer Reviewed-by: Shawn Rutledge --- src/gui/kernel/qguiapplication.cpp | 40 ++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 00245b25b0..00e3e2fcf4 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -964,18 +964,38 @@ qreal QGuiApplication::devicePixelRatio() const */ QWindow *QGuiApplication::topLevelAt(const QPoint &pos) { - QList screens = QGuiApplication::screens(); - QList::const_iterator screen = screens.constBegin(); - QList::const_iterator end = screens.constEnd(); - - while (screen != end) { - if ((*screen)->geometry().contains(pos)) { - const QPoint devicePosition = QHighDpi::toNativePixels(pos, *screen); - return (*screen)->handle()->topLevelAt(devicePosition); + const QList screens = QGuiApplication::screens(); + if (!screens.isEmpty()) { + const QList primaryScreens = screens.first()->virtualSiblings(); + QScreen *windowScreen = Q_NULLPTR; + + // Find the window on the primary virtual desktop first + foreach (QScreen *screen, primaryScreens) { + if (screen->geometry().contains(pos)) { + windowScreen = screen; + break; + } + } + + // If the window is not found on primary virtual desktop, find it on all screens + // except the first which was for sure in the previous loop. Some other screens + // may repeat. Find only when there is more than one virtual desktop. + if (!windowScreen && screens.count() != primaryScreens.count()) { + for (int i = 1; i < screens.size(); ++i) { + QScreen *screen = screens[i]; + if (screen->geometry().contains(pos)) { + windowScreen = screen; + break; + } + } + } + + if (windowScreen) { + const QPoint devicePosition = QHighDpi::toNativePixels(pos, windowScreen); + return windowScreen->handle()->topLevelAt(devicePosition); } - ++screen; } - return 0; + return Q_NULLPTR; } /*! -- cgit v1.2.3 From 7409e3a42bcfdf4d170832efa076a5795423c1d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Szczygie=C5=82?= Date: Tue, 5 Jan 2016 00:05:21 +0100 Subject: QtGui: Don't set screen to a child window when processing screen events Setting a screen to a child window causes a warning message. This patch prevents the debug message by catching incorrect behavior made by QPA earlier. Change-Id: Idf3ac02290a18afc134f19c2b91348dc009ca4ca Reviewed-by: Shawn Rutledge --- src/gui/kernel/qguiapplication.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 00e3e2fcf4..770f847190 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -2090,10 +2090,12 @@ void QGuiApplicationPrivate::processWindowStateChangedEvent(QWindowSystemInterfa void QGuiApplicationPrivate::processWindowScreenChangedEvent(QWindowSystemInterfacePrivate::WindowScreenChangedEvent *wse) { if (QWindow *window = wse->window.data()) { - if (QScreen *screen = wse->screen.data()) - window->d_func()->setTopLevelScreen(screen, false /* recreate */); - else // Fall back to default behavior, and try to find some appropriate screen - window->setScreen(0); + if (window->isTopLevel()) { + if (QScreen *screen = wse->screen.data()) + window->d_func()->setTopLevelScreen(screen, false /* recreate */); + else // Fall back to default behavior, and try to find some appropriate screen + window->setScreen(0); + } // we may have changed scaling, so trigger resize event if needed if (window->handle()) { QWindowSystemInterfacePrivate::GeometryChangeEvent gce(window, QHighDpi::fromNativePixels(window->handle()->geometry(), window), QRect()); -- cgit v1.2.3 From b2203b2490031aa13ed90c73c8414081896b649c Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 7 Jan 2016 10:41:38 +0100 Subject: doc: correct documentation of QT_AUTO_SCREEN_SCALE_FACTOR env var MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I4fa57279b23911893a615fe8a3ce9854d0fec971 Reviewed-by: Topi Reiniƶ --- src/gui/kernel/qhighdpiscaling.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp index a3201aa23f..b0ef2a284f 100644 --- a/src/gui/kernel/qhighdpiscaling.cpp +++ b/src/gui/kernel/qhighdpiscaling.cpp @@ -173,7 +173,7 @@ static inline qreal initialGlobalScaleFactor() include X11, Windows, and Android. There are two APIs for enabling or disabling this behavior: - - The QT_AUTO_SCALE_FACTOR environment variable. + - The QT_AUTO_SCREEN_SCALE_FACTOR environment variable. - The AA_EnableHighDpiScaling and AA_DisableHighDpiScaling application attributes -- cgit v1.2.3 From 6f69a313bd03c4a96f3efcd1ea00068fd5d572e9 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 5 Jan 2016 14:57:35 +0100 Subject: Fix offset and size for native child rtt widgets Render-to-texture widgets that are native children may have a non-zero offset telling the position within the top-level widget. The size is usually different (smaller) than the tlw's size as well. An unfortunate optimization attempt led to ignoring the size for native children with offset (0, 0). This resulted in interesting rendering artifacts whenever such widgets were placed in the top-left corner of the toplevel. This is now corrected. Task-number: QTBUG-48130 Change-Id: If449610c3f3333cb73ae149efaefd7ef42953951 Reviewed-by: Paul Olav Tvete --- src/gui/painting/qplatformbackingstore.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src/gui') diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp index cda2446a5e..4b725fc79f 100644 --- a/src/gui/painting/qplatformbackingstore.cpp +++ b/src/gui/painting/qplatformbackingstore.cpp @@ -371,17 +371,13 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion ®i if (textureId) { if (d_ptr->needsSwizzle) d_ptr->blitter->setSwizzleRB(true); - // offset is usually (0, 0) unless we have native child widgets. - if (offset.isNull()) { - d_ptr->blitter->blit(textureId, QMatrix4x4(), origin); - } else { - // The backingstore is for the entire tlw. offset tells the position of the native child in the tlw. - const QRect srcRect = toBottomLeftRect(deviceWindowRect.translated(offset), d_ptr->textureSize.height()); - const QMatrix3x3 source = QOpenGLTextureBlitter::sourceTransform(deviceRect(srcRect, window), - d_ptr->textureSize, - origin); - d_ptr->blitter->blit(textureId, QMatrix4x4(), source); - } + // The backingstore is for the entire tlw. + // In case of native children offset tells the position relative to the tlw. + const QRect srcRect = toBottomLeftRect(deviceWindowRect.translated(offset), d_ptr->textureSize.height()); + const QMatrix3x3 source = QOpenGLTextureBlitter::sourceTransform(deviceRect(srcRect, window), + d_ptr->textureSize, + origin); + d_ptr->blitter->blit(textureId, QMatrix4x4(), source); if (d_ptr->needsSwizzle) d_ptr->blitter->setSwizzleRB(false); } -- cgit v1.2.3