summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qtextureglyphcache.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2022-06-21 13:38:06 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2022-06-27 06:19:39 +0000
commit20ae170b351947e2cf8137504672fd5645151b9f (patch)
tree1db9e349e20077911fb855cc877726b55c0e3033 /src/gui/painting/qtextureglyphcache.cpp
parent9efaf8bae914958a09d29a4cdbf62e345f3e6369 (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/painting/qtextureglyphcache.cpp')
-rw-r--r--src/gui/painting/qtextureglyphcache.cpp10
1 files changed, 9 insertions, 1 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;