aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/util/qsgdistancefieldutil.cpp
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2012-03-05 18:19:20 +1000
committerQt by Nokia <qt-info@nokia.com>2012-03-20 12:35:18 +0100
commitdfdea38c843d1ee915e10ee72e6371ced7cd9bd0 (patch)
tree18317f2fd1ac7e64979283f20dea69fc063563d5 /src/quick/scenegraph/util/qsgdistancefieldutil.cpp
parente20c3516945269a43d070809c08e9797c329306d (diff)
Decouple QSGDistanceFieldGlyphNode from it's cache manager.
To implement a custom distance field glyph node currently it's necessary to also provide a duplicate implementation of QSGContext::createDistanceFieldGlyphCache() as the default implemention references the cache manager created by createGlyphNode(). By isolating references to the cache manager to just createDistanceFieldGlyph() cache it becomes possible to just overwrite createGlyphNode() and still use the default cache. Change-Id: I7261bdbf247966b55512d2671e2ee85239bcca05 Reviewed-by: Yoann Lopes <yoann.lopes@nokia.com>
Diffstat (limited to 'src/quick/scenegraph/util/qsgdistancefieldutil.cpp')
-rw-r--r--src/quick/scenegraph/util/qsgdistancefieldutil.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/quick/scenegraph/util/qsgdistancefieldutil.cpp b/src/quick/scenegraph/util/qsgdistancefieldutil.cpp
index ba19d51911..ecfdf9b03c 100644
--- a/src/quick/scenegraph/util/qsgdistancefieldutil.cpp
+++ b/src/quick/scenegraph/util/qsgdistancefieldutil.cpp
@@ -62,16 +62,10 @@ static float defaultAntialiasingSpreadFunc(float glyphScale)
return range / glyphScale;
}
-QSGDistanceFieldGlyphCacheManager::QSGDistanceFieldGlyphCacheManager(QSGContext *c)
- : sgCtx(c)
- , m_threshold_func(defaultThresholdFunc)
+QSGDistanceFieldGlyphCacheManager::QSGDistanceFieldGlyphCacheManager()
+ : m_threshold_func(defaultThresholdFunc)
, m_antialiasingSpread_func(defaultAntialiasingSpreadFunc)
{
-#ifndef QT_OPENGL_ES
- m_defaultAntialiasingMode = QSGGlyphNode::HighQualitySubPixelAntialiasing;
-#else
- m_defaultAntialiasingMode = QSGGlyphNode::GrayAntialiasing;
-#endif
}
QSGDistanceFieldGlyphCacheManager::~QSGDistanceFieldGlyphCacheManager()
@@ -86,10 +80,17 @@ QSGDistanceFieldGlyphCache *QSGDistanceFieldGlyphCacheManager::cache(const QRawF
.arg(font.styleName())
.arg(font.weight())
.arg(font.style());
- QHash<QString , QSGDistanceFieldGlyphCache *>::iterator cache = m_caches.find(key);
- if (cache == m_caches.end())
- cache = m_caches.insert(key, sgCtx->createDistanceFieldGlyphCache(font));
- return cache.value();
+ return m_caches.value(key, 0);
+}
+
+void QSGDistanceFieldGlyphCacheManager::insertCache(const QRawFont &font, QSGDistanceFieldGlyphCache *cache)
+{
+ QString key = QString::fromLatin1("%1_%2_%3_%4")
+ .arg(font.familyName())
+ .arg(font.styleName())
+ .arg(font.weight())
+ .arg(font.style());
+ m_caches.insert(key, cache);
}
QT_END_NAMESPACE