diff options
author | Gunnar Sletta <gunnar@sletta.org> | 2014-10-16 10:02:11 +0200 |
---|---|---|
committer | Robin Burchell <robin.burchell@viroteck.net> | 2014-10-17 13:30:08 +0200 |
commit | b876458c60a92066a43e12c93e4ab0ec68b54c71 (patch) | |
tree | ab6b3ded464efbb11ea98d0afd6b340dda11627e /src/quick/util/qquickanimatorjob.cpp | |
parent | 0ce63c97e6deee95c276214eb45b40244de82c7e (diff) |
Remove the "groupNode"
We originally had the groupnode to simplify adding and removing clip /
effect / opacity nodes to the item tree at a time when the renderer
was a bit more trivial and only did a single pass over the tree during
rendering. The runtime cost at the time was negligible. The
QSGBatchRenderer has a bit more logic, so the extra node now costs a
bit more. In addition to extra memory, we need to allocate shadow
nodes for it and put those into the renderer's internal shadownode
hash.
This removal increases the performance of adding / removal of simple
items by ~10% in addition to reducing the number of nodes in the
scene graph by up to 1/3.
Change-Id: I8cd64984f868d75820e25d33dfdbebd4d20651fe
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Diffstat (limited to 'src/quick/util/qquickanimatorjob.cpp')
-rw-r--r-- | src/quick/util/qquickanimatorjob.cpp | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/src/quick/util/qquickanimatorjob.cpp b/src/quick/util/qquickanimatorjob.cpp index fdbffd4709..8c72c09738 100644 --- a/src/quick/util/qquickanimatorjob.cpp +++ b/src/quick/util/qquickanimatorjob.cpp @@ -412,21 +412,33 @@ void QQuickOpacityAnimatorJob::initialize(QQuickAnimatorController *controller) m_opacityNode = d->opacityNode(); if (!m_opacityNode) { m_opacityNode = new QSGOpacityNode(); - d->extra.value().opacityNode = m_opacityNode; - - QSGNode *child = d->clipNode(); - if (!child) - child = d->rootNode(); - if (!child) - child = d->groupNode; - if (child) { + /* The item node subtree is like this + * + * itemNode + * (opacityNode) optional + * (clipNode) optional + * (rootNode) optional + * children / paintNode + * + * If the opacity node doesn't exist, we need to insert it into + * the hierarchy between itemNode and clipNode or rootNode. If + * neither clip or root exists, we need to reparent all children + * from itemNode to opacityNode. + */ + QSGNode *iNode = d->itemNode(); + QSGNode *child = d->childContainerNode(); + if (child != iNode) { if (child->parent()) child->parent()->removeChildNode(child); m_opacityNode->appendChildNode(child); + iNode->appendChildNode(m_opacityNode); + } else { + iNode->reparentChildNodesTo(m_opacityNode); + iNode->appendChildNode(m_opacityNode); } - d->itemNode()->appendChildNode(m_opacityNode); + d->extra.value().opacityNode = m_opacityNode; } } |