diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-02-18 10:41:42 (GMT) |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-02-18 10:41:42 (GMT) |
commit | c8f43775f1902a0539743446b5fdbb1019ccf209 (patch) | |
tree | fc42e041f10fa2364a3a23e029a944105c77ac02 /src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | |
parent | 60f3e3abbb9bfd61448a761701159cf880e66c19 (diff) | |
download | Qt-c8f43775f1902a0539743446b5fdbb1019ccf209.zip Qt-c8f43775f1902a0539743446b5fdbb1019ccf209.tar.gz Qt-c8f43775f1902a0539743446b5fdbb1019ccf209.tar.bz2 |
Optimization for text drawing on OpenGL
Only call glBindTexture() if the glyph cache texture is not already
bound. This can potentially give performance improvement of around 30%.
Reviewed-by: Gunnar
Diffstat (limited to 'src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp')
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 74ec97b..fe6d15c 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1596,7 +1596,10 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp //### TODO: Gamma correction glActiveTexture(GL_TEXTURE0 + QT_MASK_TEXTURE_UNIT); - glBindTexture(GL_TEXTURE_2D, cache->texture()); + if (lastMaskTextureUsed != cache->texture()) { + glBindTexture(GL_TEXTURE_2D, cache->texture()); + lastMaskTextureUsed = cache->texture(); + } updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, false); shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::MaskTexture), QT_MASK_TEXTURE_UNIT); @@ -1861,6 +1864,7 @@ void QGL2PaintEngineEx::ensureActive() d->transferMode(BrushDrawingMode); glViewport(0, 0, d->width, d->height); d->needsSync = false; + d->lastMaskTextureUsed = 0; d->shaderManager->setDirty(); d->ctx->d_func()->syncGlState(); for (int i = 0; i < 3; ++i) |