aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@digia.com>2013-03-21 18:22:09 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-06 10:09:30 +0200
commit8fe9280556897a0d37831aa5169f2a76aa8686d2 (patch)
tree4460dc2376ec1e24553f8026302a51c0b8cc44c4 /src/quick/scenegraph
parenteb6ff7becd41b145932a0fe9961a33f7d71445f1 (diff)
Use correct alpha range for the distance field outlined text.
The alpha treshold values used in the outline shader were hard-coded. It should use the same logic as in the normal text shader, using the ThresholdFunc and the AntialiasingSpreadFunc for calculating these values. Change-Id: I0e6f38644692cc7a8a4cee1e8e60622fe289d615 Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Diffstat (limited to 'src/quick/scenegraph')
-rw-r--r--src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
index d409cea81a..45fc0f5c6d 100644
--- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
@@ -316,7 +316,7 @@ protected:
virtual void initialize();
virtual const char *fragmentShader() const;
- void updateOutlineAlphaRange(int dfRadius);
+ void updateOutlineAlphaRange(ThresholdFunc thresholdFunc, AntialiasingSpreadFunc spreadFunc, int dfRadius);
int m_outlineAlphaMax0_id;
int m_outlineAlphaMax1_id;
@@ -351,14 +351,18 @@ void DistanceFieldOutlineTextMaterialShader::initialize()
m_outlineAlphaMax1_id = program()->uniformLocation("outlineAlphaMax1");
}
-void DistanceFieldOutlineTextMaterialShader::updateOutlineAlphaRange(int dfRadius)
+void DistanceFieldOutlineTextMaterialShader::updateOutlineAlphaRange(ThresholdFunc thresholdFunc,
+ AntialiasingSpreadFunc spreadFunc,
+ int dfRadius)
{
- qreal outlineLimit = qMax(qreal(0.2), qreal(0.5 - 0.5 / dfRadius / m_fontScale));
+ float combinedScale = m_fontScale * m_matrixScale;
+ float base = thresholdFunc(combinedScale);
+ float range = spreadFunc(combinedScale);
+ float outlineLimit = qMax(0.2f, base - 0.5f / dfRadius / m_fontScale);
- qreal combinedScale = m_fontScale * m_matrixScale;
- qreal alphaMin = qMax(0.0, 0.5 - 0.07 / combinedScale);
- qreal styleAlphaMin0 = qMax(0.0, outlineLimit - 0.07 / combinedScale);
- qreal styleAlphaMin1 = qMin(qreal(outlineLimit + 0.07 / combinedScale), alphaMin);
+ float alphaMin = qMax(0.0f, base - range);
+ float styleAlphaMin0 = qMax(0.0f, outlineLimit - range);
+ float styleAlphaMin1 = qMin(outlineLimit + range, alphaMin);
program()->setUniformValue(m_outlineAlphaMax0_id, GLfloat(styleAlphaMin0));
program()->setUniformValue(m_outlineAlphaMax1_id, GLfloat(styleAlphaMin1));
}
@@ -373,7 +377,9 @@ void DistanceFieldOutlineTextMaterialShader::updateState(const RenderState &stat
if (oldMaterial == 0
|| material->fontScale() != oldMaterial->fontScale()
|| state.isMatrixDirty())
- updateOutlineAlphaRange(material->glyphCache()->distanceFieldRadius());
+ updateOutlineAlphaRange(material->glyphCache()->manager()->thresholdFunc(),
+ material->glyphCache()->manager()->antialiasingSpreadFunc(),
+ material->glyphCache()->distanceFieldRadius());
}