diff options
author | Tor Arne Vestbø <tor.arne.vestbo@digia.com> | 2014-01-27 15:15:12 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-27 20:00:41 +0100 |
commit | 6c5b42b47e4b8b08d5188019171c779b3748236d (patch) | |
tree | e206558ee238e9712127bc9d0f2ec90b23890789 | |
parent | c39e6e89a50b5a3d2618a6c5a20950f19a0f7dfc (diff) |
Move logic for determining native vs. DF text into single factory function
Makes QSGContext::createGlyphNode() the central point of determining which
glyph node to produce, instead of letting the caller call two different
versions of the factory, each one calling the other in various cases and
behind various ifdefs.
Change-Id: I30fb17cceab45d9e13ddf3ece7a65f220c5e5acd
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
-rw-r--r-- | src/quick/items/qquicktextnode.cpp | 8 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgcontext.cpp | 24 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgcontext_p.h | 3 |
3 files changed, 7 insertions, 28 deletions
diff --git a/src/quick/items/qquicktextnode.cpp b/src/quick/items/qquicktextnode.cpp index 18ee1a479d..1133636a74 100644 --- a/src/quick/items/qquicktextnode.cpp +++ b/src/quick/items/qquicktextnode.cpp @@ -144,11 +144,9 @@ QSGGlyphNode *QQuickTextNode::addGlyphs(const QPointF &position, const QGlyphRun { QSGRenderContext *sg = QQuickItemPrivate::get(m_ownerElement)->sceneGraphRenderContext(); QRawFont font = glyphs.rawFont(); - bool smoothScalable = QFontDatabase().isSmoothlyScalable(font.familyName(), - font.styleName()); - QSGGlyphNode *node = m_useNativeRenderer || !smoothScalable - ? sg->sceneGraphContext()->createNativeGlyphNode(sg) - : sg->sceneGraphContext()->createGlyphNode(sg); + bool smoothScalable = QFontDatabase().isSmoothlyScalable(font.familyName(), font.styleName()); + bool preferNativeGlyphNode = m_useNativeRenderer || !smoothScalable; + QSGGlyphNode *node = sg->sceneGraphContext()->createGlyphNode(sg, preferNativeGlyphNode); node->setOwnerElement(m_ownerElement); node->setGlyphs(position + QPointF(0, glyphs.rawFont().ascent()), glyphs); diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp index 829d33a0d7..202ae91ac3 100644 --- a/src/quick/scenegraph/qsgcontext.cpp +++ b/src/quick/scenegraph/qsgcontext.cpp @@ -253,32 +253,14 @@ QSGImageNode *QSGContext::createImageNode() } /*! - Factory function for scene graph backends of the Text elements which supports native - text rendering. Used in special cases where native look and feel is a main objective. -*/ -QSGGlyphNode *QSGContext::createNativeGlyphNode(QSGRenderContext *rc) -{ -#if defined(QT_OPENGL_ES) && !defined(QT_OPENGL_ES_2_ANGLE) - Q_D(QSGContext); - if (d->distanceFieldDisabled) - return new QSGDefaultGlyphNode; - else - return createGlyphNode(rc); -#else - Q_UNUSED(rc); - return new QSGDefaultGlyphNode; -#endif -} - -/*! Factory function for scene graph backends of the Text elements; */ -QSGGlyphNode *QSGContext::createGlyphNode(QSGRenderContext *rc) +QSGGlyphNode *QSGContext::createGlyphNode(QSGRenderContext *rc, bool preferNativeGlyphNode) { Q_D(QSGContext); - if (d->distanceFieldDisabled) { - return createNativeGlyphNode(rc); + if (d->distanceFieldDisabled || preferNativeGlyphNode) { + return new QSGDefaultGlyphNode; } else { QSGDistanceFieldGlyphNode *node = new QSGDistanceFieldGlyphNode(rc); node->setPreferredAntialiasingMode(d->distanceFieldAntialiasing); diff --git a/src/quick/scenegraph/qsgcontext_p.h b/src/quick/scenegraph/qsgcontext_p.h index c1bf78a018..883287e35d 100644 --- a/src/quick/scenegraph/qsgcontext_p.h +++ b/src/quick/scenegraph/qsgcontext_p.h @@ -158,8 +158,7 @@ public: virtual QSGRectangleNode *createRectangleNode(); virtual QSGImageNode *createImageNode(); - virtual QSGGlyphNode *createGlyphNode(QSGRenderContext *rc); - virtual QSGGlyphNode *createNativeGlyphNode(QSGRenderContext *rc); + virtual QSGGlyphNode *createGlyphNode(QSGRenderContext *rc, bool preferNativeGlyphNode); virtual QAnimationDriver *createAnimationDriver(QObject *parent); virtual QSize minimumFBOSize() const; |