diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-08-08 12:10:44 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-08-08 20:06:57 +0200 |
commit | 268833784bf10715ded1bdfa0d61fc6c67343c16 (patch) | |
tree | d3d4d1a60e26519c7ad50bf5e900c62f1ac81272 /src/quick/scenegraph/qsgadaptationlayer.cpp | |
parent | a0dfd5e52603f6846b46bcdd80e0ca8008a31d2a (diff) |
Improve support for node iteration in the internal API
Added a new node visitor that allows easier traversal of the specialized
node types such as the image or rectangle nodes.
Change-Id: I45a7d3e1513b4a4db9d07998a6bcee9eba34044e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/quick/scenegraph/qsgadaptationlayer.cpp')
-rw-r--r-- | src/quick/scenegraph/qsgadaptationlayer.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/quick/scenegraph/qsgadaptationlayer.cpp b/src/quick/scenegraph/qsgadaptationlayer.cpp index 9826fa8978..ee077dbaf1 100644 --- a/src/quick/scenegraph/qsgadaptationlayer.cpp +++ b/src/quick/scenegraph/qsgadaptationlayer.cpp @@ -291,4 +291,52 @@ void QSGDistanceFieldGlyphCache::updateTexture(GLuint oldTex, GLuint newTex, con } } +void QSGNodeVisitorEx::visitChildren(QSGNode *node) +{ + for (QSGNode *child = node->firstChild(); child; child = child->nextSibling()) { + switch (child->type()) { + case QSGNode::ClipNodeType: { + QSGClipNode *c = static_cast<QSGClipNode*>(child); + visit(c); + visitChildren(c); + endVisit(c); + break; + } + case QSGNode::TransformNodeType: { + QSGTransformNode *c = static_cast<QSGTransformNode*>(child); + visit(c); + visitChildren(c); + endVisit(c); + break; + } + case QSGNode::OpacityNodeType: { + QSGOpacityNode *c = static_cast<QSGOpacityNode*>(child); + visit(c); + visitChildren(c); + endVisit(c); + break; + } + case QSGNode::GeometryNodeType: { + if (child->flags() & QSGNode::IsVisitableNode) { + QSGVisitableNode *v = static_cast<QSGVisitableNode*>(child); + v->accept(this); + } else { + QSGGeometryNode *c = static_cast<QSGGeometryNode*>(child); + visit(c); + visitChildren(c); + endVisit(c); + } + break; + } + case QSGNode::BasicNodeType: { + visitChildren(child); + break; + } + default: + Q_UNREACHABLE(); + break; + } + } +} + QT_END_NAMESPACE |