summaryrefslogtreecommitdiffstats
path: root/examples
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 /examples
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 'examples')
-rw-r--r--examples/quick/scenegraph/graph/linenode.cpp2
-rw-r--r--examples/quick/scenegraph/graph/noisynode.cpp2
-rw-r--r--examples/quick/scenegraph/twotextureproviders/xorblender.cpp4
3 files changed, 4 insertions, 4 deletions
diff --git a/examples/quick/scenegraph/graph/linenode.cpp b/examples/quick/scenegraph/graph/linenode.cpp
index 6cdf063bb9..d63d8112e1 100644
--- a/examples/quick/scenegraph/graph/linenode.cpp
+++ b/examples/quick/scenegraph/graph/linenode.cpp
@@ -79,7 +79,7 @@ public:
return &type;
}
- QSGMaterialShader *createShader() const override
+ QSGMaterialShader *createShader(QSGRendererInterface::RenderMode) const override
{
return new LineShader;
}
diff --git a/examples/quick/scenegraph/graph/noisynode.cpp b/examples/quick/scenegraph/graph/noisynode.cpp
index c35b4ee01e..f8b72bfe67 100644
--- a/examples/quick/scenegraph/graph/noisynode.cpp
+++ b/examples/quick/scenegraph/graph/noisynode.cpp
@@ -90,7 +90,7 @@ public:
return &type;
}
- QSGMaterialShader *createShader() const override
+ QSGMaterialShader *createShader(QSGRendererInterface::RenderMode) const override
{
return new NoisyShader;
}
diff --git a/examples/quick/scenegraph/twotextureproviders/xorblender.cpp b/examples/quick/scenegraph/twotextureproviders/xorblender.cpp
index cb61679141..87ef00aeac 100644
--- a/examples/quick/scenegraph/twotextureproviders/xorblender.cpp
+++ b/examples/quick/scenegraph/twotextureproviders/xorblender.cpp
@@ -69,7 +69,7 @@ class XorBlendMaterial : public QSGMaterial
public:
XorBlendMaterial();
QSGMaterialType *type() const override;
- QSGMaterialShader *createShader() const override;
+ QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override;
int compare(const QSGMaterial *other) const override;
struct {
@@ -93,7 +93,7 @@ XorBlendMaterial::XorBlendMaterial()
setFlag(Blending);
}
-QSGMaterialShader *XorBlendMaterial::createShader() const
+QSGMaterialShader *XorBlendMaterial::createShader(QSGRendererInterface::RenderMode) const
{
return new XorBlendRhiShader;
}