From a6faecba1a878f0a741d5015c0c116dd6891af70 Mon Sep 17 00:00:00 2001 From: Elvis Lee Date: Mon, 14 Jan 2013 11:57:22 +0900 Subject: QOpenGLTextureCache : make it possible to skip qgl_byteSwapImage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Improving performance when making texture from QImage, this commit makes it possible to skip qgl_byteSwapImage. If gl_FragColor of fragment shader is properly configured, qgl_byteSwapImage is not required. Ex) gl_FragColor = texture2D(texture, textureCoord).bgra; Change-Id: If1f2d7dc1fc1c4e583cc3f38dec95a9d29417cd2 Reviewed-by: Samuel Rødal --- src/gui/opengl/qopengltexturecache.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/gui/opengl/qopengltexturecache.cpp') diff --git a/src/gui/opengl/qopengltexturecache.cpp b/src/gui/opengl/qopengltexturecache.cpp index fffc3688e3..94b82885ff 100644 --- a/src/gui/opengl/qopengltexturecache.cpp +++ b/src/gui/opengl/qopengltexturecache.cpp @@ -95,9 +95,10 @@ void QOpenGLTextureCacheWrapper::cleanupTexturesForPixmapData(QPlatformPixmap *p cleanupTexturesForCacheKey(pmd->cacheKey()); } -QOpenGLTextureCache::QOpenGLTextureCache(QOpenGLContext *ctx) +QOpenGLTextureCache::QOpenGLTextureCache(QOpenGLContext *ctx, bool useByteSwapImage) : QOpenGLSharedResource(ctx->shareGroup()) , m_cache(64 * 1024) // 64 MB cache + , m_useByteSwapImage(useByteSwapImage) { } @@ -180,7 +181,9 @@ GLuint QOpenGLTextureCache::bindTexture(QOpenGLContext *context, qint64 key, con QImage tx = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); - qgl_byteSwapImage(tx); + // Performance could be improved by skipping qgl_byteSwapImage(). + if (m_useByteSwapImage) + qgl_byteSwapImage(tx); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tx.width(), tx.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, const_cast(tx).bits()); -- cgit v1.2.3