summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-02-18 10:41:42 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-02-18 10:41:42 (GMT)
commitc8f43775f1902a0539743446b5fdbb1019ccf209 (patch)
treefc42e041f10fa2364a3a23e029a944105c77ac02 /src/opengl
parent60f3e3abbb9bfd61448a761701159cf880e66c19 (diff)
downloadQt-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')
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp6
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h4
2 files changed, 8 insertions, 2 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)
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
index c60eac1..7108741 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
@@ -176,7 +176,8 @@ public:
useSystemClip(true),
snapToPixelGrid(false),
addOffset(false),
- inverseScale(1)
+ inverseScale(1),
+ lastMaskTextureUsed(0)
{ }
~QGL2PaintEngineExPrivate();
@@ -278,6 +279,7 @@ public:
GLfloat inverseScale;
GLuint lastTextureUsed;
+ GLuint lastMaskTextureUsed;
bool needsSync;
bool multisamplingAlwaysEnabled;