aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/scenegraph/qsgcontext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/scenegraph/qsgcontext.cpp')
-rw-r--r--src/declarative/scenegraph/qsgcontext.cpp50
1 files changed, 40 insertions, 10 deletions
diff --git a/src/declarative/scenegraph/qsgcontext.cpp b/src/declarative/scenegraph/qsgcontext.cpp
index c5e4a7de24..ce346aa1e0 100644
--- a/src/declarative/scenegraph/qsgcontext.cpp
+++ b/src/declarative/scenegraph/qsgcontext.cpp
@@ -62,6 +62,7 @@
DEFINE_BOOL_CONFIG_OPTION(qmlFlashMode, QML_FLASH_MODE)
DEFINE_BOOL_CONFIG_OPTION(qmlTranslucentMode, QML_TRANSLUCENT_MODE)
+DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD)
/*
Comments about this class from Gunnar:
@@ -90,12 +91,14 @@ public:
: rootNode(0)
, renderer(0)
, gl(0)
+ , distanceFieldCacheManager(0)
, flashMode(qmlFlashMode())
+ , distanceFieldDisabled(qmlDisableDistanceField())
{
renderAlpha = qmlTranslucentMode() ? 0.5 : 1;
}
- ~QSGContextPrivate()
+ ~QSGContextPrivate()
{
}
@@ -108,11 +111,14 @@ public:
QHash<QSGMaterialType *, QSGMaterialShader *> materials;
+ QSGDistanceFieldGlyphCacheManager *distanceFieldCacheManager;
+
QMutex textureMutex;
QList<QSGTexture *> texturesToClean;
bool flashMode;
float renderAlpha;
+ bool distanceFieldDisabled;
};
@@ -142,6 +148,7 @@ QSGContext::~QSGContext()
delete d->rootNode;
cleanupTextures();
qDeleteAll(d->materials.values());
+ delete d->distanceFieldCacheManager;
}
/*!
@@ -286,20 +293,25 @@ QSGImageNode *QSGContext::createImageNode()
*/
QSGGlyphNode *QSGContext::createGlyphNode()
{
+ Q_D(QSGContext);
+
// ### Do something with these before final release...
static bool doSubpixel = qApp->arguments().contains(QLatin1String("--text-subpixel-antialiasing"));
static bool doGray = qApp->arguments().contains(QLatin1String("--text-gray-antialiasing"));
- if (QSGDistanceFieldGlyphCache::distanceFieldEnabled()) {
- QSGGlyphNode *node = new QSGDistanceFieldGlyphNode;
-
- if (doSubpixel)
- node->setPreferredAntialiasingMode(QSGGlyphNode::SubPixelAntialiasing);
- else if (doGray)
- node->setPreferredAntialiasingMode(QSGGlyphNode::GrayAntialiasing);
- return node;
- } else {
+ if (d->distanceFieldDisabled) {
return new QSGDefaultGlyphNode;
+ } else {
+ if (!d->distanceFieldCacheManager) {
+ d->distanceFieldCacheManager = new QSGDistanceFieldGlyphCacheManager(d->gl);
+ if (doSubpixel)
+ d->distanceFieldCacheManager->setDefaultAntialiasingMode(QSGGlyphNode::SubPixelAntialiasing);
+ else if (doGray)
+ d->distanceFieldCacheManager->setDefaultAntialiasingMode(QSGGlyphNode::GrayAntialiasing);
+ }
+
+ QSGGlyphNode *node = new QSGDistanceFieldGlyphNode(d->distanceFieldCacheManager);
+ return node;
}
}
@@ -449,6 +461,24 @@ qreal QSGContext::renderAlpha() const
}
+/*!
+ Sets whether or not the scene graph should use the distance field technique to render text
+ */
+void QSGContext::setDistanceFieldEnabled(bool enabled)
+{
+ d_func()->distanceFieldDisabled = !enabled;
+}
+
+
+/*!
+ Returns true if the scene graph uses the distance field technique to render text
+ */
+bool QSGContext::isDistanceFieldEnabled() const
+{
+ return !d_func()->distanceFieldDisabled;
+}
+
+
/*!
Creates a new animation driver.