From: Samuel Rødal Date: Tue, 3 Apr 2012 10:13:02 +0000 (+0200) Subject: Properly swizzle texture data before upload in QQuickPaintedItem. X-Git-Tag: 071012131707~693 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=330dbc6bba11f401c9f258aa6281dbdfebfc8602;p=profile%2Fivi%2Fqtdeclarative.git Properly swizzle texture data before upload in QQuickPaintedItem. We already did this properly in QSGPlainTexture, need to do it in QSGPainterTexture as well, or red and blue channels will be swapped on OpenGL ES 2. Change-Id: I8b17a359b80d6c2e3b89d9c1d4c3d388a3ad1081 Reviewed-by: Kim M. Kalland --- diff --git a/src/quick/scenegraph/util/qsgpainternode.cpp b/src/quick/scenegraph/util/qsgpainternode.cpp index 1ea64f6..87a54d3 100644 --- a/src/quick/scenegraph/util/qsgpainternode.cpp +++ b/src/quick/scenegraph/util/qsgpainternode.cpp @@ -73,6 +73,10 @@ QSGPainterTexture::QSGPainterTexture() } +#ifdef QT_OPENGL_ES +extern void qsg_swizzleBGRAToRGBA(QImage *image); +#endif + void QSGPainterTexture::bind() { if (m_dirty_rect.isNull()) { @@ -91,6 +95,7 @@ void QSGPainterTexture::bind() int h = m_dirty_rect.height(); #ifdef QT_OPENGL_ES + qsg_swizzleBGRAToRGBA(&subImage); glTexSubImage2D(GL_TEXTURE_2D, 0, m_dirty_rect.x(), m_dirty_rect.y(), w, h, GL_RGBA, GL_UNSIGNED_BYTE, subImage.constBits()); #else diff --git a/src/quick/scenegraph/util/qsgtexture.cpp b/src/quick/scenegraph/util/qsgtexture.cpp index 24b92fa..7be38ff 100644 --- a/src/quick/scenegraph/util/qsgtexture.cpp +++ b/src/quick/scenegraph/util/qsgtexture.cpp @@ -402,7 +402,7 @@ QSGPlainTexture::~QSGPlainTexture() } #ifdef QT_OPENGL_ES -static void swizzleBGRAToRGBA(QImage *image) +void qsg_swizzleBGRAToRGBA(QImage *image) { const int width = image->width(); const int height = image->height(); @@ -500,7 +500,7 @@ void QSGPlainTexture::bind() updateBindOptions(m_dirty_bind_options); #ifdef QT_OPENGL_ES - swizzleBGRAToRGBA(&tmp); + qsg_swizzleBGRAToRGBA(&tmp); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, tmp.constBits()); #else glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, tmp.constBits());