From 7aa14bb332a737490698f2d2381877980cdc25ee Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Mon, 23 May 2011 13:39:53 +0200 Subject: Optimize distance-field glyph recycling. Unused glyphs in the cache should not be overwritten if they are immediatly reused after being unreferenced. --- src/declarative/scenegraph/qsgdistancefieldglyphcache.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/declarative/scenegraph') diff --git a/src/declarative/scenegraph/qsgdistancefieldglyphcache.cpp b/src/declarative/scenegraph/qsgdistancefieldglyphcache.cpp index a21fccefcf..27da408d65 100644 --- a/src/declarative/scenegraph/qsgdistancefieldglyphcache.cpp +++ b/src/declarative/scenegraph/qsgdistancefieldglyphcache.cpp @@ -678,6 +678,15 @@ int QSGDistanceFieldGlyphCache::distanceFieldRadius() const void QSGDistanceFieldGlyphCache::populate(int count, const glyph_t *glyphs) { + // Avoid useless and costly glyph re-generation + if (cacheIsFull() && !m_textureData->unusedGlyphs.isEmpty()) { + for (int i = 0; i < count; ++i) { + glyph_t glyphIndex = glyphs[i]; + if (m_textureData->texCoords.contains(glyphIndex) && m_textureData->unusedGlyphs.contains(glyphIndex)) + m_textureData->unusedGlyphs.remove(glyphIndex); + } + } + for (int i = 0; i < count; ++i) { glyph_t glyphIndex = glyphs[i]; if ((int) glyphIndex >= glyphCount()) { -- cgit v1.2.3