Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move logic for determining native vs. DF text into single factory fun…
…ction

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>
  • Loading branch information
torarnv authored and The Qt Project committed Jan 27, 2014
1 parent c39e6e8 commit 6c5b42b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 28 deletions.
8 changes: 3 additions & 5 deletions src/quick/items/qquicktextnode.cpp
Expand Up @@ -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);
Expand Down
24 changes: 3 additions & 21 deletions src/quick/scenegraph/qsgcontext.cpp
Expand Up @@ -252,33 +252,15 @@ QSGImageNode *QSGContext::createImageNode()
: new QSGDefaultImageNode;
}

/*!
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);
Expand Down
3 changes: 1 addition & 2 deletions src/quick/scenegraph/qsgcontext_p.h
Expand Up @@ -158,8 +158,7 @@ class Q_QUICK_PRIVATE_EXPORT QSGContext : public QObject

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;
Expand Down

0 comments on commit 6c5b42b

Please sign in to comment.