aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2012-04-03 12:13:02 +0200
committerQt by Nokia <qt-info@nokia.com>2012-04-03 12:49:14 +0200
commit330dbc6bba11f401c9f258aa6281dbdfebfc8602 (patch)
tree4e440f9e7e89cbd3ea01fec9f4c787503a18f5f4
parent240a3cd360309c5d525b635e40b12697deca6c0e (diff)
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 <kim.kalland@nokia.com>
-rw-r--r--src/quick/scenegraph/util/qsgpainternode.cpp5
-rw-r--r--src/quick/scenegraph/util/qsgtexture.cpp4
2 files changed, 7 insertions, 2 deletions
diff --git a/src/quick/scenegraph/util/qsgpainternode.cpp b/src/quick/scenegraph/util/qsgpainternode.cpp
index 1ea64f6205..87a54d3124 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 24b92fa98f..7be38ff109 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());