summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2022-06-21 13:38:06 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-06-28 12:08:11 +0000
commit5199ae4c4a73a3323995a34b7de3ad2cd8d4b4b9 (patch)
tree8db5b392dcc7180cc3a7ebf8737dce59be508c6b /src
parentaab4aa0e4676a77cf27d61c4cbb78dcf8fd2e6a9 (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). Task-number: QTBUG-101008 Change-Id: Ie67948b138f578b5f40d6a950c4aa92394a8f09a Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit 20ae170b351947e2cf8137504672fd5645151b9f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/gui/painting/qtextureglyphcache.cpp10
-rw-r--r--src/gui/painting/qtextureglyphcache_p.h3
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();