summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-02-04 09:43:52 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-02-04 09:43:52 (GMT)
commit2ac3bffd816d9fbe9646b6126b4a882f391b466f (patch)
tree8ba1ed8007bee0feaa949afd54dc688e339df7c3 /src/opengl
parent8aa94f13be95392d0bba911105bb118b48321a15 (diff)
downloadQt-2ac3bffd816d9fbe9646b6126b4a882f391b466f.zip
Qt-2ac3bffd816d9fbe9646b6126b4a882f391b466f.tar.gz
Qt-2ac3bffd816d9fbe9646b6126b4a882f391b466f.tar.bz2
Small optimization for QStaticText when used with index arrays
Don't recalculate the index array when the glyphs are simply moved.
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index d82d335..d20c258 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -1349,7 +1349,13 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp
textureCoordinateArray.clear();
#if defined(QSTATICTEXT_USE_INDEXARRAY)
- indices.clear();
+ QStaticTextUserData *uData = staticTextItem->userData;
+ QOpenGLStaticTextUserData *openGlUserData = uData != 0
+ && uData->type == QStaticTextUserData::OpenGLUserData
+ ? static_cast<QOpenGLStaticTextUserData *>(uData)
+ : 0;
+ bool updateIndices = openGlUserData == 0
+ || openGlUserData->indices.size() < staticTextItem->numGlyphs;
int j=0;
#endif
@@ -1362,8 +1368,10 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp
textureCoordinateArray.addRect(QRectF(c.x*dx, c.y*dy, c.w * dx, c.h * dy));
#if defined(QSTATICTEXT_USE_INDEXARRAY)
- for (int k=0; k<6; ++k)
- indices.append(j++);
+ if (updateIndices) {
+ for (int k=0; k<6; ++k)
+ indices.append(j++);
+ }
#endif
}
@@ -1390,7 +1398,8 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp
textureCoordinateArray.data(), GL_STATIC_DRAW);
#if defined(QSTATICTEXT_USE_INDEXARRAY)
- userData->indices = indices;
+ if (updateIndices)
+ userData->indices = indices;
#endif
// If a new user data has been created, make sure we delete the old