aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@nokia.com>2012-06-06 17:59:59 +0200
committerQt by Nokia <qt-info@nokia.com>2012-06-08 13:11:24 +0200
commitb2561521b3f2e72fe512e19003b22b39e238a18c (patch)
tree203232b2252994e42f7d7938df0f71edfcc0b7c5 /src/quick/scenegraph
parent2fdc5e044c967ac7044a3b5814110469da20f6e4 (diff)
Fixed glyph margin in QSGDistanceFieldGlyphNode.
The margin was too big in some cases, causing visual artifacts. The margin should never be bigger than the margin used in the glyph cache. Change-Id: Ia6bd3a9d4a98a2a3484d0e5e803de95ca14fffbb Reviewed-by: Yoann Lopes <yoann.lopes@nokia.com>
Diffstat (limited to 'src/quick/scenegraph')
-rw-r--r--src/quick/scenegraph/qsgdistancefieldglyphnode.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode.cpp b/src/quick/scenegraph/qsgdistancefieldglyphnode.cpp
index d6fe6f938c..3f5fb0447a 100644
--- a/src/quick/scenegraph/qsgdistancefieldglyphnode.cpp
+++ b/src/quick/scenegraph/qsgdistancefieldglyphnode.cpp
@@ -213,8 +213,14 @@ void QSGDistanceFieldGlyphNode::updateGeometry()
QVector<ushort> ip;
ip.reserve(indexes.size() * 6);
- QPointF margins(2, 2);
- QPointF texMargins = margins / m_glyph_cache->fontScale(fontPixelSize);
+ qreal maxTexMargin = m_glyph_cache->distanceFieldRadius() / 2;
+ qreal fontScale = m_glyph_cache->fontScale(fontPixelSize);
+ qreal margin = 2;
+ qreal texMargin = margin / fontScale;
+ if (texMargin > maxTexMargin) {
+ texMargin = maxTexMargin;
+ margin = maxTexMargin * fontScale;
+ }
for (int i = 0; i < indexes.size(); ++i) {
const int glyphIndex = indexes.at(i);
@@ -241,14 +247,14 @@ void QSGDistanceFieldGlyphNode::updateGeometry()
QSGDistanceFieldGlyphCache::Metrics metrics = m_glyph_cache->glyphMetrics(glyphIndex, fontPixelSize);
if (!metrics.isNull() && !c.isNull()) {
- metrics.width += margins.x() * 2;
- metrics.height += margins.y() * 2;
- metrics.baselineX -= margins.x();
- metrics.baselineY += margins.y();
- c.xMargin -= texMargins.x();
- c.yMargin -= texMargins.y();
- c.width += texMargins.x() * 2;
- c.height += texMargins.y() * 2;
+ metrics.width += margin * 2;
+ metrics.height += margin * 2;
+ metrics.baselineX -= margin;
+ metrics.baselineY += margin;
+ c.xMargin -= texMargin;
+ c.yMargin -= texMargin;
+ c.width += texMargin * 2;
+ c.height += texMargin * 2;
}
qreal x = position.x() + metrics.baselineX + m_position.x();
@@ -303,6 +309,7 @@ void QSGDistanceFieldGlyphNode::updateGeometry()
subNode->setColor(m_color);
subNode->setStyle(m_style);
subNode->setStyleColor(m_styleColor);
+ subNode->setPreferredAntialiasingMode(m_antialiasingMode);
subNode->setGlyphs(m_originalPosition, subNodeGlyphRun);
subNode->update();
subNode->updateGeometry(); // we have to explicity call this now as preprocess won't be called before it's rendered