diff options
author | Gunnar Sletta <gunnar@sletta.org> | 2014-10-15 08:40:20 +0200 |
---|---|---|
committer | Gunnar Sletta <gunnar@sletta.org> | 2014-10-16 08:38:15 +0200 |
commit | b341ccf0a9be27713505b4c6ff748db58fdae91f (patch) | |
tree | 76d8ec76bb84c34e34dffaae87d2a03662875503 /src/quick/items/qquickwindow.cpp | |
parent | e1dfb78667bd7e8dc418e12a9669404adea7e2cb (diff) |
Resolve QQuickItemPrivate::beforePaintNode dynamically.
It will be the 0 unless the item has a direct child with negative z,
which occurs very rarely. Its presence complicates the algorithm used
to solve QTBUG-34255 and it wastes 8 bytes per visual item.
No difference could be noted in a benchmark animating 6000+ sprites.
Task-number: QTBUG-34255
Change-Id: Id0a78a246f0d621a51c8caad23da02b55d59b9bb
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Diffstat (limited to 'src/quick/items/qquickwindow.cpp')
-rw-r--r-- | src/quick/items/qquickwindow.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 5548017ddc..4986996d99 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -2636,6 +2636,19 @@ void QQuickWindowPrivate::updateDirtyNodes() } } +static inline QSGNode *qquickitem_before_paintNode(QQuickItemPrivate *d) +{ + if (!d->extra.isAllocated()) + return 0; + const QList<QQuickItem *> childItems = d->paintOrderChildItems(); + for (int i=0; i<childItems.size(); ++i) { + if (Q_LIKELY(QQuickItemPrivate::get(childItems.at(i))->z() >= 0)) { + return Q_LIKELY(i == 0) ? 0 : QQuickItemPrivate::get(childItems.at(i))->itemNode(); + } + } + return 0; +} + void QQuickWindowPrivate::updateDirtyNode(QQuickItem *item) { QQuickItemPrivate *itemPriv = QQuickItemPrivate::get(item); @@ -2753,10 +2766,6 @@ void QQuickWindowPrivate::updateDirtyNode(QQuickItem *item) itemPriv->childContainerNode()->appendChildNode(childPrivate->itemNode()); } - QSGNode *beforePaintNode = itemPriv->groupNode ? itemPriv->groupNode->lastChild() : 0; - if (beforePaintNode || itemPriv->extra.isAllocated()) - itemPriv->extra.value().beforePaintNode = beforePaintNode; - if (itemPriv->paintNode) itemPriv->childContainerNode()->appendChildNode(itemPriv->paintNode); @@ -2814,8 +2823,9 @@ void QQuickWindowPrivate::updateDirtyNode(QQuickItem *item) itemPriv->paintNode->parent() == itemPriv->childContainerNode()); if (itemPriv->paintNode && itemPriv->paintNode->parent() == 0) { - if (itemPriv->extra.isAllocated() && itemPriv->extra->beforePaintNode) - itemPriv->childContainerNode()->insertChildNodeAfter(itemPriv->paintNode, itemPriv->extra->beforePaintNode); + QSGNode *before = qquickitem_before_paintNode(itemPriv); + if (before) + itemPriv->childContainerNode()->insertChildNodeAfter(itemPriv->paintNode, before); else itemPriv->childContainerNode()->prependChildNode(itemPriv->paintNode); } |