aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@nokia.com>2011-07-18 13:17:46 +0200
committerQt by Nokia <qt-info@nokia.com>2011-07-20 06:57:44 +0200
commita9b1594576579044c26ef325191a79ffe1df7e27 (patch)
tree2042cdd489f3a19ec08636ebc9c3e7bb3e912976 /src
parent29cf717366623bceb4d4e3009600cfa538529c10 (diff)
Fixed QSGDistanceFieldGlyphNode initialization order.
Change-Id: Id2e8ccf6441ce7e7a2bcdd6f0d50745e7d9ba653 Reviewed-on: http://codereview.qt.nokia.com/1750 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Yoann Lopes <yoann.lopes@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/declarative/items/qsgtextnode.cpp6
-rw-r--r--src/declarative/scenegraph/qsgadaptationlayer_p.h2
-rw-r--r--src/declarative/scenegraph/qsgdefaultglyphnode_p.h2
-rw-r--r--src/declarative/scenegraph/qsgdistancefieldglyphnode.cpp34
-rw-r--r--src/declarative/scenegraph/qsgdistancefieldglyphnode_p.h6
5 files changed, 41 insertions, 9 deletions
diff --git a/src/declarative/items/qsgtextnode.cpp b/src/declarative/items/qsgtextnode.cpp
index 2eb705fbf6..d36db1b6b6 100644
--- a/src/declarative/items/qsgtextnode.cpp
+++ b/src/declarative/items/qsgtextnode.cpp
@@ -162,9 +162,13 @@ QSGGlyphNode *QSGTextNode::addGlyphs(const QPointF &position, const QGlyphRun &g
dfNode->setStyleColor(styleColor);
}
node->setColor(color);
- appendChildNode(node);
}
+ node->update();
+
+ if (node != prevNode)
+ appendChildNode(node);
+
return node;
}
diff --git a/src/declarative/scenegraph/qsgadaptationlayer_p.h b/src/declarative/scenegraph/qsgadaptationlayer_p.h
index 33f664f150..81b17a9000 100644
--- a/src/declarative/scenegraph/qsgadaptationlayer_p.h
+++ b/src/declarative/scenegraph/qsgadaptationlayer_p.h
@@ -112,6 +112,8 @@ public:
virtual void setPreferredAntialiasingMode(AntialiasingMode) = 0;
+ virtual void update() = 0;
+
protected:
QRectF m_bounding_rect;
};
diff --git a/src/declarative/scenegraph/qsgdefaultglyphnode_p.h b/src/declarative/scenegraph/qsgdefaultglyphnode_p.h
index 8d79d1109d..16e267b605 100644
--- a/src/declarative/scenegraph/qsgdefaultglyphnode_p.h
+++ b/src/declarative/scenegraph/qsgdefaultglyphnode_p.h
@@ -65,6 +65,8 @@ public:
virtual void setPreferredAntialiasingMode(AntialiasingMode) { }
+ virtual void update() { }
+
private:
QGlyphRun m_glyphs;
QPointF m_position;
diff --git a/src/declarative/scenegraph/qsgdistancefieldglyphnode.cpp b/src/declarative/scenegraph/qsgdistancefieldglyphnode.cpp
index 343487bd30..26326d0c75 100644
--- a/src/declarative/scenegraph/qsgdistancefieldglyphnode.cpp
+++ b/src/declarative/scenegraph/qsgdistancefieldglyphnode.cpp
@@ -52,6 +52,9 @@ QSGDistanceFieldGlyphNode::QSGDistanceFieldGlyphNode()
, m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 0)
, m_style(QSGText::Normal)
, m_antialiasingMode(GrayAntialiasing)
+ , m_dirtyFont(false)
+ , m_dirtyGeometry(false)
+ , m_dirtyMaterial(false)
{
m_geometry.setDrawingMode(GL_TRIANGLES);
setGeometry(&m_geometry);
@@ -84,7 +87,7 @@ void QSGDistanceFieldGlyphNode::setPreferredAntialiasingMode(AntialiasingMode mo
if (mode == m_antialiasingMode)
return;
m_antialiasingMode = mode;
- updateMaterial();
+ m_dirtyMaterial = true;
}
void QSGDistanceFieldGlyphNode::setGlyphs(const QPointF &position, const QGlyphRun &glyphs)
@@ -93,23 +96,35 @@ void QSGDistanceFieldGlyphNode::setGlyphs(const QPointF &position, const QGlyphR
m_position = QPointF(position.x(), position.y() - font.ascent());
m_glyphs = glyphs;
- updateFont();
- updateGeometry();
- updateMaterial();
-
-#ifdef QML_RUNTIME_TESTING
- description = QLatin1String("glyphs");
-#endif
+ m_dirtyFont = true;
+ m_dirtyGeometry = true;
+ m_dirtyMaterial = true;
}
void QSGDistanceFieldGlyphNode::setStyle(QSGText::TextStyle style)
{
+ if (m_style == style)
+ return;
m_style = style;
+ m_dirtyMaterial = true;
}
void QSGDistanceFieldGlyphNode::setStyleColor(const QColor &color)
{
+ if (m_styleColor == color)
+ return;
m_styleColor = color;
+ m_dirtyMaterial = true;
+}
+
+void QSGDistanceFieldGlyphNode::update()
+{
+ if (m_dirtyFont)
+ updateFont();
+ if (m_dirtyGeometry)
+ updateGeometry();
+ if (m_dirtyMaterial)
+ updateMaterial();
}
void QSGDistanceFieldGlyphNode::updateGeometry()
@@ -225,11 +240,13 @@ void QSGDistanceFieldGlyphNode::updateGeometry()
setBoundingRect(boundingRect);
markDirty(DirtyGeometry);
+ m_dirtyGeometry = false;
}
void QSGDistanceFieldGlyphNode::updateFont()
{
m_glyph_cache = QSGDistanceFieldGlyphCache::get(QGLContext::currentContext(), m_glyphs.rawFont());
+ m_dirtyFont = false;
}
void QSGDistanceFieldGlyphNode::updateMaterial()
@@ -260,6 +277,7 @@ void QSGDistanceFieldGlyphNode::updateMaterial()
m_material->setGlyphCache(m_glyph_cache);
m_material->setColor(m_color);
setMaterial(m_material);
+ m_dirtyMaterial = false;
}
QT_END_NAMESPACE
diff --git a/src/declarative/scenegraph/qsgdistancefieldglyphnode_p.h b/src/declarative/scenegraph/qsgdistancefieldglyphnode_p.h
index 5d6ddd0c15..926a84383c 100644
--- a/src/declarative/scenegraph/qsgdistancefieldglyphnode_p.h
+++ b/src/declarative/scenegraph/qsgdistancefieldglyphnode_p.h
@@ -69,6 +69,8 @@ public:
void setStyle(QSGText::TextStyle style);
void setStyleColor(const QColor &color);
+ virtual void update();
+
private:
void updateGeometry();
void updateFont();
@@ -84,6 +86,10 @@ private:
QSGText::TextStyle m_style;
QColor m_styleColor;
AntialiasingMode m_antialiasingMode;
+
+ uint m_dirtyFont: 1;
+ uint m_dirtyGeometry: 1;
+ uint m_dirtyMaterial: 1;
};
QT_END_HEADER