diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2022-06-21 13:38:06 +0200 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2022-06-27 06:19:39 +0000 |
commit | 20ae170b351947e2cf8137504672fd5645151b9f (patch) | |
tree | 1db9e349e20077911fb855cc877726b55c0e3033 /src/gui | |
parent | 9efaf8bae914958a09d29a4cdbf62e345f3e6369 (diff) |
Enabler for fractional scaling of text in Qt Quick
As opposed to the raster engine, in Qt Quick we are using
unscaled positions for the glyphs and using the vertex shader
to scale these after the fact. However, when picking the
correct subpixel rendering for each glyph, we would use the
unscaled position's fractional part, meaning that we
essentially rendered the glyphs at the wrong subpixel position.
This was especially visible when doing fractional scaling, e.g.
125%.
Thus we need to get the fraction of the actual on-screen position
instead. This has to be done both when populating the cache for
the Qt Quick case (this enabler adds it as opt-in) and also when
actually selecting the correct rendering of the glyph (change in
Qt Declarative).
Pick-to: 5.15 6.2 6.3 6.4
Task-number: QTBUG-101008
Change-Id: Ie67948b138f578b5f40d6a950c4aa92394a8f09a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/painting/qtextureglyphcache.cpp | 10 | ||||
-rw-r--r-- | src/gui/painting/qtextureglyphcache_p.h | 3 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index 215eb75e32..a67cbfacc1 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -60,7 +60,8 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const glyph_t *glyphs, const QFixedPoint *positions, - QPainter::RenderHints renderHints) + QPainter::RenderHints renderHints, + bool includeGlyphCacheScale) { #ifdef CACHE_DEBUG printf("Populating with %d glyphs\n", numGlyphs); @@ -89,6 +90,9 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, m_cy = padding; } + qreal glyphCacheScaleX = transform().m11(); + qreal glyphCacheScaleY = transform().m22(); + QHash<GlyphAndSubPixelPosition, Coord> listItemCoordinates; int rowHeight = 0; @@ -99,6 +103,10 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, QFixedPoint subPixelPosition; if (supportsSubPixelPositions) { QFixedPoint pos = positions != nullptr ? positions[i] : QFixedPoint(); + if (includeGlyphCacheScale) { + pos = QFixedPoint(QFixed::fromReal(pos.x.toReal() * glyphCacheScaleX), + QFixed::fromReal(pos.y.toReal() * glyphCacheScaleY)); + } subPixelPosition = fontEngine->subPixelPositionFor(pos); if (!verticalSubPixelPositions) subPixelPosition.y = 0; diff --git a/src/gui/painting/qtextureglyphcache_p.h b/src/gui/painting/qtextureglyphcache_p.h index bf6b07f36f..4c18b30285 100644 --- a/src/gui/painting/qtextureglyphcache_p.h +++ b/src/gui/painting/qtextureglyphcache_p.h @@ -78,7 +78,8 @@ public: int numGlyphs, const glyph_t *glyphs, const QFixedPoint *positions, - QPainter::RenderHints renderHints = QPainter::RenderHints()); + QPainter::RenderHints renderHints = QPainter::RenderHints(), + bool includeGlyphCacheScale = false); bool hasPendingGlyphs() const { return !m_pendingGlyphs.isEmpty(); } void fillInPendingGlyphs(); |