From f46cb7033fc3bfc17c4ccf9125d670810322a0f5 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 21 Aug 2010 05:40:37 +0200 Subject: bindTexture: Replace texture if painting is active on pixmap/image MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes an issue with WebKit canvases not updating after the first frame since there's always a QPainter open on their backing store. Reviewed-by: Samuel Rødal --- src/opengl/qgl.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 1802107..51187cf 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -2287,11 +2287,19 @@ QImage QGLContextPrivate::convertToGLFormat(const QImage &image, bool force_prem QGLTexture *QGLContextPrivate::bindTexture(const QImage &image, GLenum target, GLint format, QGLContext::BindOptions options) { + Q_Q(QGLContext); + const qint64 key = image.cacheKey(); QGLTexture *texture = textureCacheLookup(key, target); if (texture) { - glBindTexture(target, texture->id); - return texture; + if (image.paintingActive()) { + // A QPainter is active on the image - take the safe route and replace the texture. + q->deleteTexture(texture->id); + texture = 0; + } else { + glBindTexture(target, texture->id); + return texture; + } } if (!texture) @@ -2557,14 +2565,19 @@ QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target, } #else Q_UNUSED(pd); - Q_UNUSED(q); #endif const qint64 key = pixmap.cacheKey(); QGLTexture *texture = textureCacheLookup(key, target); if (texture) { - glBindTexture(target, texture->id); - return texture; + if (pixmap.paintingActive()) { + // A QPainter is active on the pixmap - take the safe route and replace the texture. + q->deleteTexture(texture->id); + texture = 0; + } else { + glBindTexture(target, texture->id); + return texture; + } } #if defined(Q_WS_X11) -- cgit v0.12