Properly swizzle texture data before upload in QQuickPaintedItem.
authorSamuel Rødal <samuel.rodal@nokia.com>
Tue, 3 Apr 2012 10:13:02 +0000 (12:13 +0200)
committerQt by Nokia <qt-info@nokia.com>
Tue, 3 Apr 2012 10:49:14 +0000 (12:49 +0200)
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 <kim.kalland@nokia.com>
src/quick/scenegraph/util/qsgpainternode.cpp
src/quick/scenegraph/util/qsgtexture.cpp

index 1ea64f6..87a54d3 100644 (file)
@@ -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
index 24b92fa..7be38ff 100644 (file)
@@ -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());