aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/scenegraph/qsgdistancefieldglyphcache.cpp
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@nokia.com>2011-08-09 11:39:40 +0200
committerQt by Nokia <qt-info@nokia.com>2011-08-09 15:59:10 +0200
commit108c94807a22740d0ecae369846063b4596d3788 (patch)
tree7fc974fb235434d1bc0c906c0a527b968a15f980 /src/declarative/scenegraph/qsgdistancefieldglyphcache.cpp
parent1a84b190bd1a2781d03f13fa43ab92bf34809041 (diff)
Make distance field text more easily configurable.
Custom functions can be provided to compute the distance field threshold value and antialiasing range. Change-Id: Ie2ec8160d81671dedf72f0c72c3a5cbdf04d993a Reviewed-on: http://codereview.qt.nokia.com/2772 Reviewed-by: Yoann Lopes <yoann.lopes@nokia.com> Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Diffstat (limited to 'src/declarative/scenegraph/qsgdistancefieldglyphcache.cpp')
-rw-r--r--src/declarative/scenegraph/qsgdistancefieldglyphcache.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/declarative/scenegraph/qsgdistancefieldglyphcache.cpp b/src/declarative/scenegraph/qsgdistancefieldglyphcache.cpp
index a1df05c2de..90bd8c320d 100644
--- a/src/declarative/scenegraph/qsgdistancefieldglyphcache.cpp
+++ b/src/declarative/scenegraph/qsgdistancefieldglyphcache.cpp
@@ -86,6 +86,21 @@ static inline int qt_next_power_of_two(int v)
return v;
}
+static float defaultThresholdFunc(float glyphScale)
+{
+ static float base = qgetenv("QT_DF_BASE").isEmpty() ? 0.5f : qgetenv("QT_DF_BASE").toFloat();
+ static float baseDev = qgetenv("QT_DF_BASEDEVIATION").isEmpty() ? 0.065f : qgetenv("QT_DF_BASEDEVIATION").toFloat();
+ static float devScaleMin = qgetenv("QT_DF_SCALEFORMAXDEV").isEmpty() ? 0.15f : qgetenv("QT_DF_SCALEFORMAXDEV").toFloat();
+ static float devScaleMax = qgetenv("QT_DF_SCALEFORNODEV").isEmpty() ? 0.3f : qgetenv("QT_DF_SCALEFORNODEV").toFloat();
+ return base - ((qBound(devScaleMin, glyphScale, devScaleMax) - devScaleMin) / (devScaleMax - devScaleMin) * -baseDev + baseDev);
+}
+
+static float defaultAntialiasingSpreadFunc(float glyphScale)
+{
+ static float range = qgetenv("QT_DF_RANGE").isEmpty() ? 0.06f : qgetenv("QT_DF_RANGE").toFloat();
+ return range / glyphScale;
+}
+
namespace
{
enum FillHDir
@@ -808,6 +823,8 @@ QSGDistanceFieldGlyphCache::QSGDistanceFieldGlyphCache(const QGLContext *c, cons
, m_maxTextureSize(0)
, ctx(c)
, m_blitProgram(0)
+ , m_threshold_func(defaultThresholdFunc)
+ , m_antialiasingSpread_func(defaultAntialiasingSpreadFunc)
{
Q_ASSERT(font.isValid());
m_font = font;