aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@nokia.com>2012-01-06 17:11:11 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-09 17:10:55 +0100
commitce08b106c4183946f19de46ad8a83b953ac1efc9 (patch)
treef03d2d73d9bf6410daa9c744307cb8638d828c65
parentf161773a0221393192b20bab25c62a8645e6cdd4 (diff)
Avoid storing a deep copy of the image in the texture object
Change-Id: I605445ea23493fd562a7fe2b3cc841ad21e5b08b Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
-rw-r--r--src/quick/scenegraph/util/qsgtexture.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/quick/scenegraph/util/qsgtexture.cpp b/src/quick/scenegraph/util/qsgtexture.cpp
index 0abbc8dae1..a732c5ab06 100644
--- a/src/quick/scenegraph/util/qsgtexture.cpp
+++ b/src/quick/scenegraph/util/qsgtexture.cpp
@@ -415,11 +415,7 @@ static void swizzleBGRAToRGBA(QImage *image)
void QSGPlainTexture::setImage(const QImage &image)
{
- m_image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
-#ifdef QT_OPENGL_ES
- swizzleBGRAToRGBA(&m_image);
-#endif
-
+ m_image = image;
m_texture_size = image.size();
m_has_alpha = image.hasAlphaChannel();
m_dirty_texture = true;
@@ -496,10 +492,15 @@ void QSGPlainTexture::bind()
int w = m_image.width();
int h = m_image.height();
+ QImage tmp = (m_image.format() == QImage::Format_RGB32 || m_image.format() == QImage::Format_ARGB32_Premultiplied)
+ ? m_image
+ : m_image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
+
#ifdef QT_OPENGL_ES
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_image.constBits());
+ 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, m_image.constBits());
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, tmp.constBits());
#endif
if (m_has_mipmaps) {