aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@nokia.com>2011-05-05 12:02:20 +0200
committerYoann Lopes <yoann.lopes@nokia.com>2011-05-05 12:03:20 +0200
commit9815adf88c50af4f5249cfa631d9c565f87428c3 (patch)
tree69e93dd3c101f768ba5425ad9ca3805097143a43 /src
parent7983f0df7f734d250d6e4cb1b5d91fa12b2c2df1 (diff)
Makes sub-pixel antialiased distance-field text looks slightly sharper.
Diffstat (limited to 'src')
-rw-r--r--src/declarative/scenegraph/qsgdistancefieldglyphnode_p.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/declarative/scenegraph/qsgdistancefieldglyphnode_p.cpp b/src/declarative/scenegraph/qsgdistancefieldglyphnode_p.cpp
index e332434138..c822810c61 100644
--- a/src/declarative/scenegraph/qsgdistancefieldglyphnode_p.cpp
+++ b/src/declarative/scenegraph/qsgdistancefieldglyphnode_p.cpp
@@ -60,7 +60,7 @@ protected:
virtual const char *vertexShader() const;
virtual const char *fragmentShader() const;
- void updateAlphaRange();
+ virtual void updateAlphaRange();
qreal m_fontScale;
qreal m_matrixScale;
@@ -506,6 +506,8 @@ protected:
virtual const char *vertexShader() const;
virtual const char *fragmentShader() const;
+ void updateAlphaRange();
+
private:
int m_fontScale_id;
int m_vecDelta_id;
@@ -618,6 +620,15 @@ void QSGSubPixelDistanceFieldTextMaterialShader::deactivate()
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
}
+void QSGSubPixelDistanceFieldTextMaterialShader::updateAlphaRange()
+{
+ qreal combinedScale = m_fontScale * m_matrixScale;
+ qreal alphaMin = qMax(0.0, 0.5 - 0.05 / combinedScale);
+ qreal alphaMax = qMin(0.5 + 0.05 / combinedScale, 1.0);
+ m_program.setUniformValue(m_alphaMin_id, GLfloat(alphaMin));
+ m_program.setUniformValue(m_alphaMax_id, GLfloat(alphaMax));
+}
+
void QSGSubPixelDistanceFieldTextMaterialShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect)
{
Q_ASSERT(oldEffect == 0 || newEffect->type() == oldEffect->type());