aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-06-09 10:57:35 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-06-15 10:20:21 +0200
commit90bf30376c94b2fcf99e2d8382b40e8881be47be (patch)
treefc7dac6b58b45afc7676c7dae82ce36ee78b2542 /src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h
parenta8d357761dbf74cbdc72348be6c655cafb745ff2 (diff)
Anisotropic antialiasing for distance field text
For perspective transforms, we need to find the sample range in the glyph cache per pixel. We can do this by getting the gradient of the distance field at the specific pixel. This will ensure proper antialiasing with any projection, but has the limitation that when glyph contours become thinner than a pixel, they may disappear or become too emphasized, because the hardware-gradient - based on neighbouring fragments - is not reliable at that scale. So we should only default to this when we detect that the text is child of a 3D scene. To make this smooth, we need to know the mode of the renderer when creating the shader. So QSGMaterial::createShader() now takes a render mode that we can use to customize behavior based on whether it is rendering into a 2D or 3D scene. [ChangeLog][QtQuick] The QSGMaterial::createShader() virtual function has been extended to take a render mode argument, which can be used for any customizations needed in the case where the shader will be used in combination with 3D perspective transformations. Fixes: QTBUG-84695 Change-Id: I5a18a4edbdfa07e8f9d506c42bb20e8eb580927d Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h')
-rw-r--r--src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h b/src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h
index ee1ed8f337..e4e20166b5 100644
--- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h
+++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h
@@ -67,7 +67,7 @@ public:
~QSGDistanceFieldTextMaterial();
QSGMaterialType *type() const override;
- QSGMaterialShader *createShader() const override;
+ QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override;
int compare(const QSGMaterial *other) const override;
virtual void setColor(const QColor &color);
@@ -104,7 +104,7 @@ public:
~QSGDistanceFieldStyledTextMaterial();
QSGMaterialType *type() const override = 0;
- QSGMaterialShader *createShader() const override = 0;
+ QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override = 0;
int compare(const QSGMaterial *other) const override;
void setStyleColor(const QColor &color);
@@ -121,7 +121,7 @@ public:
~QSGDistanceFieldOutlineTextMaterial();
QSGMaterialType *type() const override;
- QSGMaterialShader *createShader() const override;
+ QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override;
};
class Q_QUICK_PRIVATE_EXPORT QSGDistanceFieldShiftedStyleTextMaterial : public QSGDistanceFieldStyledTextMaterial
@@ -131,7 +131,7 @@ public:
~QSGDistanceFieldShiftedStyleTextMaterial();
QSGMaterialType *type() const override;
- QSGMaterialShader *createShader() const override;
+ QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override;
int compare(const QSGMaterial *other) const override;
void setShift(const QPointF &shift) { m_shift = shift; }
@@ -145,7 +145,7 @@ class Q_QUICK_PRIVATE_EXPORT QSGHiQSubPixelDistanceFieldTextMaterial : public QS
{
public:
QSGMaterialType *type() const override;
- QSGMaterialShader *createShader() const override;
+ QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override;
void setColor(const QColor &color) override { m_color = QVector4D(color.redF(), color.greenF(), color.blueF(), color.alphaF()); }
};
@@ -153,7 +153,7 @@ class Q_QUICK_PRIVATE_EXPORT QSGLoQSubPixelDistanceFieldTextMaterial : public QS
{
public:
QSGMaterialType *type() const override;
- QSGMaterialShader *createShader() const override;
+ QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override;
void setColor(const QColor &color) override { m_color = QVector4D(color.redF(), color.greenF(), color.blueF(), color.alphaF()); }
};