diff options
author | Yoann Lopes <yoann.lopes@nokia.com> | 2011-10-21 13:32:21 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-10-27 13:52:27 +0200 |
commit | e7d9828cd905a1eb95afe5394c2bc3cbbcc5e0d4 (patch) | |
tree | 43c3ca443bd901e5d286fc4aa62cfb6db20818f0 | |
parent | 8adc2fa39cd6ef61c4e32ef9843c326262665905 (diff) |
Fixed QQuickPaintedItem texture binding when using Image render target.
Change-Id: Ia5c0f8de1109a26471c69267fdd9c9d71325dd39
Reviewed-by: Yoann Lopes <yoann.lopes@nokia.com>
-rw-r--r-- | src/declarative/scenegraph/util/qsgpainternode.cpp | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/src/declarative/scenegraph/util/qsgpainternode.cpp b/src/declarative/scenegraph/util/qsgpainternode.cpp index 1f44750f98..a89dd75bac 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(); } |