From b876458c60a92066a43e12c93e4ab0ec68b54c71 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 16 Oct 2014 10:02:11 +0200 Subject: 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 --- src/quick/util/qquickanimatorjob.cpp | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'src/quick/util') 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; } } -- cgit v1.2.3