aboutsummaryrefslogtreecommitdiffstats
path: root/src/particles
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/particles
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/particles')
-rw-r--r--src/particles/qquickimageparticle.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/particles/qquickimageparticle.cpp b/src/particles/qquickimageparticle.cpp
index 5f99ff2d95..f30ae6476e 100644
--- a/src/particles/qquickimageparticle.cpp
+++ b/src/particles/qquickimageparticle.cpp
@@ -147,7 +147,8 @@ public:
class TabledMaterial : public ImageMaterial
{
public:
- QSGMaterialShader *createShader() const override {
+ QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override {
+ Q_UNUSED(renderMode);
return new TabledMaterialRhiShader;
}
QSGMaterialType *type() const override { return &m_type; }
@@ -210,7 +211,8 @@ public:
class DeformableMaterial : public ImageMaterial
{
public:
- QSGMaterialShader *createShader() const override {
+ QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override {
+ Q_UNUSED(renderMode);
return new DeformableMaterialRhiShader;
}
QSGMaterialType *type() const override { return &m_type; }
@@ -287,7 +289,8 @@ public:
class SpriteMaterial : public ImageMaterial
{
public:
- QSGMaterialShader *createShader() const override {
+ QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override {
+ Q_UNUSED(renderMode);
return new ParticleSpriteMaterialRhiShader;
}
QSGMaterialType *type() const override { return &m_type; }
@@ -350,7 +353,8 @@ public:
class ColoredMaterial : public ImageMaterial
{
public:
- QSGMaterialShader *createShader() const override {
+ QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override {
+ Q_UNUSED(renderMode);
return new ColoredMaterialRhiShader;
}
QSGMaterialType *type() const override { return &m_type; }
@@ -413,7 +417,8 @@ public:
class SimpleMaterial : public ImageMaterial
{
public:
- QSGMaterialShader *createShader() const override {
+ QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override {
+ Q_UNUSED(renderMode);
return new SimpleMaterialRhiShader;
}
QSGMaterialType *type() const override { return &m_type; }