From 8de9ec760810fea9c9cfccfe575a4693f2f5c024 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 28 Sep 2010 14:31:16 +1000 Subject: Only repopulate the glyph cache when we know something could have changed Reviewed-by: Gunnar Sletta --- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 27 +++++++++++++--------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 42792ac..6b0d2fa 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1499,9 +1499,22 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp staticTextItem->fontEngine->setGlyphCache(ctx, cache); } - cache->setPaintEnginePrivate(this); - cache->populate(staticTextItem->fontEngine, staticTextItem->numGlyphs, staticTextItem->glyphs, - staticTextItem->glyphPositions); + bool recreateVertexArrays = false; + if (staticTextItem->userDataNeedsUpdate) + recreateVertexArrays = true; + else if (staticTextItem->userData == 0) + recreateVertexArrays = true; + else if (staticTextItem->userData->type != QStaticTextUserData::OpenGLUserData) + recreateVertexArrays = true; + + // We only need to update the cache with new glyphs if we are actually going to recreate the vertex arrays. + // If the cache size has changed, we do need to regenerate the vertices, but we don't need to repopulate the + // cache so this text is performed before we test if the cache size has changed. + if (recreateVertexArrays) { + cache->setPaintEnginePrivate(this); + cache->populate(staticTextItem->fontEngine, staticTextItem->numGlyphs, staticTextItem->glyphs, + staticTextItem->glyphPositions); + } if (cache->width() == 0 || cache->height() == 0) return; @@ -1513,14 +1526,6 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp GLfloat dx = 1.0 / cache->width(); GLfloat dy = 1.0 / cache->height(); - bool recreateVertexArrays = false; - if (staticTextItem->userDataNeedsUpdate) - recreateVertexArrays = true; - else if (staticTextItem->userData == 0) - recreateVertexArrays = true; - else if (staticTextItem->userData->type != QStaticTextUserData::OpenGLUserData) - recreateVertexArrays = true; - // Use global arrays by default QGL2PEXVertexArray *vertexCoordinates = &vertexCoordinateArray; QGL2PEXVertexArray *textureCoordinates = &textureCoordinateArray; -- cgit v0.12