diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2011-03-17 14:19:02 (GMT) |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2011-03-21 09:11:19 (GMT) |
commit | 410ddbf93f16a948ed28bbfe177433b3d138bd8c (patch) | |
tree | 54a341c9e351d27db9393d06093718d75c836f25 /src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp | |
parent | 25a2df08706679d89780fae9216508ef0f094221 (diff) | |
download | Qt-410ddbf93f16a948ed28bbfe177433b3d138bd8c.zip Qt-410ddbf93f16a948ed28bbfe177433b3d138bd8c.tar.gz Qt-410ddbf93f16a948ed28bbfe177433b3d138bd8c.tar.bz2 |
Optimized glyph uploads in GL texture cache.
Avoid doing a lot of glTexSubImage2D calls in favor of doing a single
call (even if it involves an additional image copy).
Reviewed-by: Eskil
Diffstat (limited to 'src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp')
-rw-r--r-- | src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp index 4362c0a..9e8e828 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp @@ -339,8 +339,19 @@ void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph, QFixed sub // by converting it to a format with four bytes per pixel. Another is to copy one line at a // time. - for (int i = 0; i < maskHeight; ++i) - glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y + i, maskWidth, 1, GL_ALPHA, GL_UNSIGNED_BYTE, mask.scanLine(i)); + if (!ctx->d_ptr->workaround_brokenAlphaTexSubImage_init) { + // don't know which driver versions exhibit this bug, so be conservative for now + const QByteArray versionString(reinterpret_cast<const char*>(glGetString(GL_VERSION))); + ctx->d_ptr->workaround_brokenAlphaTexSubImage = versionString.indexOf("NVIDIA") >= 0; + ctx->d_ptr->workaround_brokenAlphaTexSubImage_init = true; + } + + if (ctx->d_ptr->workaround_brokenAlphaTexSubImage) { + for (int i = 0; i < maskHeight; ++i) + glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y + i, maskWidth, 1, GL_ALPHA, GL_UNSIGNED_BYTE, mask.scanLine(i)); + } else { + glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, maskWidth, maskHeight, GL_ALPHA, GL_UNSIGNED_BYTE, mask.bits()); + } } } |