From: Yoann Lopes Date: Fri, 21 Oct 2011 11:32:21 +0000 (+0200) Subject: Fixed QQuickPaintedItem texture binding when using Image render target. X-Git-Tag: qt-v5.0.0-alpha1~1275 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e7d9828cd905a1eb95afe5394c2bc3cbbcc5e0d4;p=profile%2Fivi%2Fqtdeclarative.git Fixed QQuickPaintedItem texture binding when using Image render target. Change-Id: Ia5c0f8de1109a26471c69267fdd9c9d71325dd39 Reviewed-by: Yoann Lopes --- diff --git a/src/declarative/scenegraph/util/qsgpainternode.cpp b/src/declarative/scenegraph/util/qsgpainternode.cpp index 1f44750..a89dd75 100644 --- a/src/declarative/scenegraph/util/qsgpainternode.cpp +++ b/src/declarative/scenegraph/util/qsgpainternode.cpp @@ -75,33 +75,38 @@ QSGPainterTexture::QSGPainterTexture() void QSGPainterTexture::bind() { - if (m_dirty_rect.isNull() || m_texture_id == 0) { + if (m_dirty_rect.isNull()) { QSGPlainTexture::bind(); - } else { - glBindTexture(GL_TEXTURE_2D, m_texture_id); + return; + } + + bool oldMipmapsGenerated = m_mipmaps_generated; + m_mipmaps_generated = true; + QSGPlainTexture::bind(); + m_mipmaps_generated = oldMipmapsGenerated; - QImage subImage = m_image.copy(m_dirty_rect); + QImage subImage = m_image.copy(m_dirty_rect); - int w = m_dirty_rect.width(); - int h = m_dirty_rect.height(); + int w = m_dirty_rect.width(); + int h = m_dirty_rect.height(); #ifdef QT_OPENGL_ES - glTexSubImage2D(GL_TEXTURE_2D, 0, m_dirty_rect.x(), m_dirty_rect.y(), w, h, - GL_RGBA, GL_UNSIGNED_BYTE, subImage.constBits()); + glTexSubImage2D(GL_TEXTURE_2D, 0, m_dirty_rect.x(), m_dirty_rect.y(), w, h, + GL_RGBA, GL_UNSIGNED_BYTE, subImage.constBits()); #else - glTexSubImage2D(GL_TEXTURE_2D, 0, m_dirty_rect.x(), m_dirty_rect.y(), w, h, - GL_BGRA, GL_UNSIGNED_BYTE, subImage.constBits()); + glTexSubImage2D(GL_TEXTURE_2D, 0, m_dirty_rect.x(), m_dirty_rect.y(), w, h, + GL_BGRA, GL_UNSIGNED_BYTE, subImage.constBits()); #endif - if (m_has_mipmaps && !m_mipmaps_generated) { - QOpenGLContext *ctx = QOpenGLContext::currentContext(); - ctx->functions()->glGenerateMipmap(GL_TEXTURE_2D); - m_mipmaps_generated = true; - } - - m_dirty_texture = false; - m_dirty_bind_options = false; + if (m_has_mipmaps && !m_mipmaps_generated) { + QOpenGLContext *ctx = QOpenGLContext::currentContext(); + ctx->functions()->glGenerateMipmap(GL_TEXTURE_2D); + m_mipmaps_generated = true; } + + m_dirty_texture = false; + m_dirty_bind_options = false; + m_dirty_rect = QRect(); }