diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2020-08-12 09:27:03 +0200 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2020-08-17 07:09:31 +0200 |
commit | cbbbfe3bff29d8db84771e07ac6f16209b0969d1 (patch) | |
tree | a37c1a23cadc6ae6a0d8e367d0b582768e943e6a /src/quick/scenegraph/qsgadaptationlayer_p.h | |
parent | 0cb02b7ee0f72674640ffe5a0fabc1dacc259de0 (diff) |
Add renderTypeQuality property to Text element
For large scale text, the default distance field size gives
artifacts on certain font features. We already have an environment
variable which overrides this on an application level, but this
will cause all distance fields to be rendered at the high resolution,
whereas you may just want it for one particular text field.
Since this becomes an especially important use case now that we can
embed the text fields in a 3D scene, we add a property which can
be used to tweak the base font size used for generating the
distance fields.
[ChangeLog][QtQuick][Text] Added "renderTypeQuality" property, which
can be used in cases of very large fonts, where Qt's font rasterization
may show some rendering artifacts when using the default quality.
Fixes: QTBUG-84696
Change-Id: Ie4205e82cf441562dcc65a8e432a941a3baeddf3
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/quick/scenegraph/qsgadaptationlayer_p.h')
-rw-r--r-- | src/quick/scenegraph/qsgadaptationlayer_p.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/quick/scenegraph/qsgadaptationlayer_p.h b/src/quick/scenegraph/qsgadaptationlayer_p.h index a59d11430e..020ba3aa4c 100644 --- a/src/quick/scenegraph/qsgadaptationlayer_p.h +++ b/src/quick/scenegraph/qsgadaptationlayer_p.h @@ -396,6 +396,7 @@ public: virtual void setBoundingRect(const QRectF &bounds) { m_bounding_rect = bounds; } virtual void setPreferredAntialiasingMode(AntialiasingMode) = 0; + virtual void setRenderTypeQuality(int renderTypeQuality) { Q_UNUSED(renderTypeQuality) } virtual void update() = 0; @@ -421,7 +422,8 @@ typedef QIntrusiveList<QSGDistanceFieldGlyphConsumer, &QSGDistanceFieldGlyphCons class Q_QUICK_PRIVATE_EXPORT QSGDistanceFieldGlyphCache { public: - QSGDistanceFieldGlyphCache(const QRawFont &font); + QSGDistanceFieldGlyphCache(const QRawFont &font, + int renderTypeQuality); virtual ~QSGDistanceFieldGlyphCache(); struct Metrics { @@ -460,7 +462,7 @@ public: qreal fontScale(qreal pixelSize) const { - return pixelSize / QT_DISTANCEFIELD_BASEFONTSIZE(m_doubleGlyphResolution); + return pixelSize / baseFontSize(); } int distanceFieldRadius() const { @@ -468,6 +470,7 @@ public: } int glyphCount() const { return m_glyphCount; } bool doubleGlyphResolution() const { return m_doubleGlyphResolution; } + int renderTypeQuality() const { return m_renderTypeQuality; } Metrics glyphMetrics(glyph_t glyph, qreal pixelSize); inline TexCoord glyphTexCoord(glyph_t glyph); @@ -521,11 +524,14 @@ protected: GlyphData &glyphData(glyph_t glyph); GlyphData &emptyData(glyph_t glyph); + int baseFontSize() const; + #if defined(QSG_DISTANCEFIELD_CACHE_DEBUG) virtual void saveTexture(QRhiTexture *texture, const QString &nameBase) const = 0; #endif bool m_doubleGlyphResolution; + int m_renderTypeQuality; protected: QRawFont m_referenceFont; |