diff options
author | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2011-06-10 13:35:37 +0200 |
---|---|---|
committer | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2011-06-10 13:35:37 +0200 |
commit | 71c9da36a71e5cac6312db97169fc641e5d274ea (patch) | |
tree | db210491d0cabfd07e37e5aebcccf3091fa4c66a | |
parent | 50cb4baf0f2a9f8595c372e1172b8849218b6e09 (diff) |
Keep track of the number of geometry nodes in a sub-graph.
If there are no geometry nodes in a sub-graph, there's no need
to update it.
-rw-r--r-- | src/declarative/scenegraph/coreapi/qsgnode.cpp | 19 | ||||
-rw-r--r-- | src/declarative/scenegraph/coreapi/qsgnode.h | 3 |
2 files changed, 18 insertions, 4 deletions
diff --git a/src/declarative/scenegraph/coreapi/qsgnode.cpp b/src/declarative/scenegraph/coreapi/qsgnode.cpp index 370cfa4d7d..b0a5f04035 100644 --- a/src/declarative/scenegraph/coreapi/qsgnode.cpp +++ b/src/declarative/scenegraph/coreapi/qsgnode.cpp @@ -84,6 +84,7 @@ static void qt_print_node_count() QSGNode::QSGNode() : m_parent(0) , m_type(BasicNodeType) + , m_subtreeGeometryCount(0) , m_nodeFlags(OwnedByParent) , m_flags(0) { @@ -93,6 +94,7 @@ QSGNode::QSGNode() QSGNode::QSGNode(NodeType type) : m_parent(0) , m_type(type) + , m_subtreeGeometryCount(type == GeometryNodeType ? 1 : 0) , m_nodeFlags(OwnedByParent) , m_flags(0) { @@ -150,8 +152,6 @@ QSGNode::~QSGNode() /*! - \fn bool QSGNode::isSubtreeBlocked() const - Returns whether this node and its subtree is available for use. Blocked subtrees will not get their dirty states updated and they @@ -161,6 +161,11 @@ QSGNode::~QSGNode() is 0, for instance. */ +bool QSGNode::isSubtreeBlocked() const +{ + return m_subtreeGeometryCount == 0; +} + void QSGNode::destroy() { @@ -360,9 +365,17 @@ void QSGNode::markDirty(DirtyFlags flags) m_flags |= (flags & DirtyPropagationMask); DirtyFlags subtreeFlags = DirtyFlags((flags & DirtyPropagationMask) << 16); + + int geometryCountDiff = 0; + if (flags & DirtyNodeAdded) + geometryCountDiff = m_subtreeGeometryCount; + if (flags & DirtyNodeRemoved) + geometryCountDiff = -m_subtreeGeometryCount; + QSGNode *p = m_parent; while (p) { p->m_flags |= subtreeFlags; + p->m_subtreeGeometryCount += geometryCountDiff; if (p->type() == RootNodeType) static_cast<QSGRootNode *>(p)->notifyNodeChange(this, flags); p = p->m_parent; @@ -920,7 +933,7 @@ void QSGOpacityNode::setCombinedOpacity(qreal opacity) bool QSGOpacityNode::isSubtreeBlocked() const { - return m_combined_opacity < 0.001; + return QSGNode::isSubtreeBlocked() || m_combined_opacity < 0.001; } diff --git a/src/declarative/scenegraph/coreapi/qsgnode.h b/src/declarative/scenegraph/coreapi/qsgnode.h index a391b55bc5..fa45e0f74c 100644 --- a/src/declarative/scenegraph/coreapi/qsgnode.h +++ b/src/declarative/scenegraph/coreapi/qsgnode.h @@ -132,7 +132,7 @@ public: void markDirty(DirtyFlags flags); DirtyFlags dirtyFlags() const { return m_flags; } - virtual bool isSubtreeBlocked() const { return false; } + virtual bool isSubtreeBlocked() const; Flags flags() const { return m_nodeFlags; } void setFlag(Flag, bool = true); @@ -161,6 +161,7 @@ private: QSGNode *m_parent; NodeType m_type; QList<QSGNode *> m_children; + int m_subtreeGeometryCount; Flags m_nodeFlags; DirtyFlags m_flags; |