aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/qsgadaptationlayer.cpp
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@nokia.com>2011-12-13 11:18:33 +0100
committerQt by Nokia <qt-info@nokia.com>2011-12-14 09:06:21 +0100
commit17bffaa4d447959f08e16ca9a45885f631a16cc0 (patch)
treed5a014dd626e2fc07179938eedde661357cb5663 /src/quick/scenegraph/qsgadaptationlayer.cpp
parent22a8387aeab93fd086b297443945487677aef280 (diff)
More distance-field cache refactoring.
The distance field glyph node now uses preprocess(). The glyph cache is updated at that time, then when all the glyphs are ready the node's geometry is updated. addGlyphPositions and addGlyphTextures in QSGDistanceFieldGlyphCache have been renamed to setGlyphsPosition and setGlyphsTexture to reflect the fact that they can be used to update existing glyphs. For example when a glyph has moved to a different texture. When an existing glyph is updated, all nodes containing that glyph are invalidated and their geometries are reconstructed with the new values. Change-Id: I7758313155f48811e6027434e6c9a1c3df5dfab7 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Diffstat (limited to 'src/quick/scenegraph/qsgadaptationlayer.cpp')
-rw-r--r--src/quick/scenegraph/qsgadaptationlayer.cpp37
1 files changed, 29 insertions, 8 deletions
diff --git a/src/quick/scenegraph/qsgadaptationlayer.cpp b/src/quick/scenegraph/qsgadaptationlayer.cpp
index 972bff80e0..57c0990f1d 100644
--- a/src/quick/scenegraph/qsgadaptationlayer.cpp
+++ b/src/quick/scenegraph/qsgadaptationlayer.cpp
@@ -228,8 +228,10 @@ void QSGDistanceFieldGlyphCache::update()
storeGlyphs(distanceFields);
}
-void QSGDistanceFieldGlyphCache::addGlyphPositions(const QList<GlyphPosition> &glyphs)
+void QSGDistanceFieldGlyphCache::setGlyphsPosition(const QList<GlyphPosition> &glyphs)
{
+ QVector<quint32> invalidatedGlyphs;
+
int count = glyphs.count();
for (int i = 0; i < count; ++i) {
GlyphPosition glyph = glyphs.at(i);
@@ -244,11 +246,22 @@ void QSGDistanceFieldGlyphCache::addGlyphPositions(const QList<GlyphPosition> &g
c.width = br.width();
c.height = br.height();
+ if (m_cacheData->texCoords.contains(glyph.glyph))
+ invalidatedGlyphs.append(glyph.glyph);
+
m_cacheData->texCoords.insert(glyph.glyph, c);
}
+
+ if (!invalidatedGlyphs.isEmpty()) {
+ QLinkedList<QSGDistanceFieldGlyphNode *>::iterator it = m_cacheData->m_registeredNodes.begin();
+ while (it != m_cacheData->m_registeredNodes.end()) {
+ (*it)->invalidateGlyphs(invalidatedGlyphs);
+ ++it;
+ }
+ }
}
-void QSGDistanceFieldGlyphCache::addGlyphTextures(const QVector<glyph_t> &glyphs, const Texture &tex)
+void QSGDistanceFieldGlyphCache::setGlyphsTexture(const QVector<glyph_t> &glyphs, const Texture &tex)
{
int i = m_cacheData->textures.indexOf(tex);
if (i == -1) {
@@ -259,14 +272,22 @@ void QSGDistanceFieldGlyphCache::addGlyphTextures(const QVector<glyph_t> &glyphs
}
Texture *texture = &(m_cacheData->textures[i]);
+ QVector<quint32> invalidatedGlyphs;
+
int count = glyphs.count();
- for (int j = 0; j < count; ++j)
- m_cacheData->glyphTextures.insert(glyphs.at(j), texture);
+ for (int j = 0; j < count; ++j) {
+ glyph_t glyphIndex = glyphs.at(j);
+ if (m_cacheData->glyphTextures.contains(glyphIndex))
+ invalidatedGlyphs.append(glyphIndex);
+ m_cacheData->glyphTextures.insert(glyphIndex, texture);
+ }
- QLinkedList<QSGDistanceFieldGlyphNode *>::iterator it = m_cacheData->m_registeredNodes.begin();
- while (it != m_cacheData->m_registeredNodes.end()) {
- (*it)->updateGeometry();
- ++it;
+ if (!invalidatedGlyphs.isEmpty()) {
+ QLinkedList<QSGDistanceFieldGlyphNode *>::iterator it = m_cacheData->m_registeredNodes.begin();
+ while (it != m_cacheData->m_registeredNodes.end()) {
+ (*it)->invalidateGlyphs(invalidatedGlyphs);
+ ++it;
+ }
}
}