From d594799f1e31e7cf0de7d01a2afa2c8cc06c7fd4 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 19 Mar 2010 14:57:25 +0100 Subject: 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 --- src/opengl/qgl.cpp | 11 +++++++++-- 1 file 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); -- cgit v0.12