summaryrefslogtreecommitdiffstats
path: root/src/opengl/qgl.cpp
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar@trolltech.com>2010-03-19 13:57:25 (GMT)
committerGunnar Sletta <gunnar@trolltech.com>2010-03-19 13:59:23 (GMT)
commitd594799f1e31e7cf0de7d01a2afa2c8cc06c7fd4 (patch)
tree2ace47cc0502a34d50eeb263e9b046c5c19d41e7 /src/opengl/qgl.cpp
parent83b8d1aef2a840838bbe530794e1dd004e3a22d5 (diff)
downloadQt-d594799f1e31e7cf0de7d01a2afa2c8cc06c7fd4.zip
Qt-d594799f1e31e7cf0de7d01a2afa2c8cc06c7fd4.tar.gz
Qt-d594799f1e31e7cf0de7d01a2afa2c8cc06c7fd4.tar.bz2
Make an attemt to upload QPixmap in the most optimal format on 16-bit
On 16-bit configs, using 16-bit textures gives us quite a bit of performance extra, so making this extra effort prior to uploading it seems worth it. Reviewed-by: Samuel
Diffstat (limited to 'src/opengl/qgl.cpp')
-rw-r--r--src/opengl/qgl.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 5908f14..7aba25a 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -2453,8 +2453,15 @@ QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target,
}
#endif
- if (!texture)
- texture = bindTexture(pixmap.toImage(), target, format, key, options);
+ if (!texture) {
+ QImage image = pixmap.toImage();
+ // If the system depth is 16 and the pixmap doesn't have an alpha channel
+ // then we convert it to RGB16 in the hope that it gets uploaded as a 16
+ // bit texture which is much faster to access than a 32-bit one.
+ if (pixmap.depth() == 16 && !image.hasAlphaChannel() )
+ image = image.convertToFormat(QImage::Format_RGB16);
+ texture = bindTexture(image, target, format, key, options);
+ }
// NOTE: bindTexture(const QImage&, GLenum, GLint, const qint64, bool) should never return null
Q_ASSERT(texture);