Skip to content

Commit

Permalink
Fixed QQuickPaintedItem texture binding when using Image render target.
Browse files Browse the repository at this point in the history
Change-Id: Ia5c0f8de1109a26471c69267fdd9c9d71325dd39
Reviewed-by: Yoann Lopes <yoann.lopes@nokia.com>
  • Loading branch information
Yoann Lopes authored and Qt by Nokia committed Oct 27, 2011
1 parent 8adc2fa commit e7d9828
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions src/declarative/scenegraph/util/qsgpainternode.cpp
Expand Up @@ -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();
}

Expand Down

0 comments on commit e7d9828

Please sign in to comment.