From b271abeaf11c9fe0a05d8405f03f6a20218214ed Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Fri, 16 Mar 2012 12:09:29 +0100 Subject: Use a single distance-field cache instance for all sizes of a given font. Previously we had a different cache instance for each font size, but they all shared the same textures and positions. Only the glyph metrics were specific to each font size. The metrics for each font sizes are now calculated by scaling the metrics of the distance-field size (54px). Change-Id: I0d9016990dedd93318893506afb1dba7a5249e2e Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/quick/scenegraph/qsgdistancefieldglyphnode.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/quick/scenegraph/qsgdistancefieldglyphnode.cpp') diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode.cpp b/src/quick/scenegraph/qsgdistancefieldglyphnode.cpp index a86e663755..56c79b1975 100644 --- a/src/quick/scenegraph/qsgdistancefieldglyphnode.cpp +++ b/src/quick/scenegraph/qsgdistancefieldglyphnode.cpp @@ -200,6 +200,7 @@ void QSGDistanceFieldGlyphNode::updateGeometry() const QVector indexes = m_glyphs.glyphIndexes(); const QVector positions = m_glyphs.positions(); + qreal fontPixelSize = m_glyphs.rawFont().pixelSize(); QVector vp; vp.reserve(indexes.size() * 4); @@ -207,8 +208,7 @@ void QSGDistanceFieldGlyphNode::updateGeometry() ip.reserve(indexes.size() * 6); QPointF margins(2, 2); - QPointF texMargins = margins / m_glyph_cache->fontScale(); - + QPointF texMargins = margins / m_glyph_cache->fontScale(fontPixelSize); for (int i = 0; i < indexes.size(); ++i) { const int glyphIndex = indexes.at(i); @@ -232,7 +232,7 @@ void QSGDistanceFieldGlyphNode::updateGeometry() continue; } - QSGDistanceFieldGlyphCache::Metrics metrics = m_glyph_cache->glyphMetrics(glyphIndex); + QSGDistanceFieldGlyphCache::Metrics metrics = m_glyph_cache->glyphMetrics(glyphIndex, fontPixelSize); if (!metrics.isNull() && !c.isNull()) { metrics.width += margins.x() * 2; @@ -356,6 +356,8 @@ void QSGDistanceFieldGlyphNode::updateMaterial() } m_material->setGlyphCache(m_glyph_cache); + if (m_glyph_cache) + m_material->setFontScale(m_glyph_cache->fontScale(m_glyphs.rawFont().pixelSize())); m_material->setColor(m_color); setMaterial(m_material); m_dirtyMaterial = false; -- cgit v1.2.3