aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/scenegraph
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@nokia.com>2011-05-23 13:39:53 +0200
committerYoann Lopes <yoann.lopes@nokia.com>2011-05-23 13:46:01 +0200
commit7aa14bb332a737490698f2d2381877980cdc25ee (patch)
tree0211969fd7341da56eec987d3dd8928a7f136d53 /src/declarative/scenegraph
parente430f1336881850a73a54a291e0276160d568212 (diff)
Optimize distance-field glyph recycling.
Unused glyphs in the cache should not be overwritten if they are immediatly reused after being unreferenced.
Diffstat (limited to 'src/declarative/scenegraph')
-rw-r--r--src/declarative/scenegraph/qsgdistancefieldglyphcache.cpp9
1 files changed, 9 insertions, 0 deletions
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()) {