From 47a5c708bf4e555cb8febef583f32c99f7d8ea1e Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 24 Nov 2011 13:48:19 +0100 Subject: Add support for shared glyph cache Use a shared graphics cache to back the distance fields if it is available. Change-Id: Id5e6e7a28e38e349d787e66016b2d0faebc791d7 Reviewed-by: Jiang Jiang --- src/quick/scenegraph/qsgdistancefieldglyphnode.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/quick/scenegraph/qsgdistancefieldglyphnode.cpp') diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode.cpp b/src/quick/scenegraph/qsgdistancefieldglyphnode.cpp index 8f681d2a0b..eb1c1eb22d 100644 --- a/src/quick/scenegraph/qsgdistancefieldglyphnode.cpp +++ b/src/quick/scenegraph/qsgdistancefieldglyphnode.cpp @@ -57,10 +57,10 @@ QSGDistanceFieldGlyphNode::QSGDistanceFieldGlyphNode(QSGDistanceFieldGlyphCacheM , m_dirtyGeometry(false) , m_dirtyMaterial(false) { - setFlag(UsePreprocess); m_geometry.setDrawingMode(GL_TRIANGLES); setGeometry(&m_geometry); setPreferredAntialiasingMode(cacheManager->defaultAntialiasingMode()); + setFlag(UsePreprocess); #ifdef QML_RUNTIME_TESTING description = QLatin1String("glyphs"); #endif @@ -112,9 +112,13 @@ void QSGDistanceFieldGlyphNode::setGlyphs(const QPointF &position, const QGlyphR QSGDistanceFieldGlyphCache *oldCache = m_glyph_cache; m_glyph_cache = m_glyph_cacheManager->cache(m_glyphs.rawFont()); if (m_glyph_cache != oldCache) { - if (oldCache) + Q_ASSERT(ownerElement() != 0); + if (oldCache) { oldCache->unregisterGlyphNode(this); + oldCache->unregisterOwnerElement(ownerElement()); + } m_glyph_cache->registerGlyphNode(this); + m_glyph_cache->registerOwnerElement(ownerElement()); } m_glyph_cache->populate(glyphs.glyphIndexes()); @@ -158,12 +162,13 @@ void QSGDistanceFieldGlyphNode::preprocess() { Q_ASSERT(m_glyph_cache); - m_glyph_cache->update(); - for (int i = 0; i < m_nodesToDelete.count(); ++i) delete m_nodesToDelete.at(i); m_nodesToDelete.clear(); + m_glyph_cache->processPendingGlyphs(); + m_glyph_cache->update(); + if (m_dirtyGeometry) updateGeometry(); } @@ -285,6 +290,7 @@ void QSGDistanceFieldGlyphNode::updateGeometry() QHash::iterator subIt = m_subNodes.find(ite.key()); if (subIt == m_subNodes.end()) { QSGDistanceFieldGlyphNode *subNode = new QSGDistanceFieldGlyphNode(m_glyph_cacheManager); + subNode->setOwnerElement(m_ownerElement); subNode->setColor(m_color); subNode->setStyle(m_style); subNode->setStyleColor(m_styleColor); -- cgit v1.2.3