diff options
author | Martin Jones <martin.jones@nokia.com> | 2012-06-08 11:19:09 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-08 06:17:54 +0200 |
commit | 762b4d90110465aeceb96f44cd06dcda229dfe89 (patch) | |
tree | 5bfba55b60b01a55ea965f0a51ad19ce6c84b004 /src/quick/items/qquickitemview.cpp | |
parent | 9f9b2df76c7677fb3dc82ca617cf0732652b684d (diff) |
Performance should always be better with cacheBuffer
Setting a cacheBuffer introduced more work for the scenegraph due to
cached delegates' visibility being toggled. Changing visibility is
expensive as it is proagated to all children. Introduce a cheap
method of hiding a branch instead.
Also avoid initiating incubation in the same frame as a completed
creation.
Change-Id: I573bcf37f441f96a7502d445be50ef4301f217d5
Reviewed-by: Bea Lam <bea.lam@nokia.com>
Diffstat (limited to 'src/quick/items/qquickitemview.cpp')
-rw-r--r-- | src/quick/items/qquickitemview.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp index 9ea2aad8fb..e48db3d140 100644 --- a/src/quick/items/qquickitemview.cpp +++ b/src/quick/items/qquickitemview.cpp @@ -87,7 +87,7 @@ void FxViewItem::setVisible(bool visible) { if (!visible && transitionableItem && transitionableItem->transitionScheduledOrRunning()) return; - item->setVisible(visible); + QQuickItemPrivate::get(item)->setCulled(!visible); } QQuickItemViewTransitioner::TransitionType FxViewItem::scheduledTransitionType() const @@ -1429,6 +1429,9 @@ QQuickItemViewPrivate::QQuickItemViewPrivate() , fillCacheBuffer(false), inRequest(false), requestedAsync(false) , runDelayedRemoveTransition(false) { + bufferPause.addAnimationChangeListener(this, QAbstractAnimationJob::Completion); + bufferPause.setLoopCount(1); + bufferPause.setDuration(16); } QQuickItemViewPrivate::~QQuickItemViewPrivate() @@ -1636,6 +1639,13 @@ void QQuickItemViewPrivate::mirrorChange() emit q->effectiveLayoutDirectionChanged(); } +void QQuickItemViewPrivate::animationFinished(QAbstractAnimationJob *) +{ + Q_Q(QQuickItemView); + fillCacheBuffer = true; + q->polish(); +} + void QQuickItemViewPrivate::refill() { qreal s = qMax(size(), qreal(0.)); @@ -1651,6 +1661,7 @@ void QQuickItemViewPrivate::refill(qreal from, qreal to) if (!isValid() || !q->isComponentComplete()) return; + bufferPause.stop(); currentChanges.reset(); int prevCount = itemCount; @@ -1667,8 +1678,7 @@ void QQuickItemViewPrivate::refill(qreal from, qreal to) if (added) { // We've already created a new delegate this frame. // Just schedule a buffer refill. - fillCacheBuffer = true; - q->polish(); + bufferPause.start(); } else { if (bufferMode & BufferAfter) fillTo = bufferTo; @@ -2206,7 +2216,7 @@ void QQuickItemView::createdItem(int index, QQuickItem *item) if (d->requestedIndex != index) { item->setParentItem(contentItem()); d->unrequestedItems.insert(item, index); - item->setVisible(false); + QQuickItemPrivate::get(item)->setCulled(true); d->repositionPackageItemAt(item, index); } else { d->requestedIndex = -1; @@ -2224,8 +2234,7 @@ void QQuickItemView::initItem(int index, QQuickItem *item) item->setZ(1); if (d->requestedIndex == index) { if (d->requestedAsync) - item->setVisible(false); - item->setParentItem(contentItem()); + QQuickItemPrivate::get(item)->setCulled(true); d->requestedItem = d->newViewItem(index, item); } } @@ -2248,7 +2257,7 @@ bool QQuickItemViewPrivate::releaseItem(FxViewItem *item) QQuickVisualModel::ReleaseFlags flags = model->release(item->item); if (flags == 0) { // item was not destroyed, and we no longer reference it. - item->item->setVisible(false); + QQuickItemPrivate::get(item->item)->setCulled(true); unrequestedItems.insert(item->item, model->indexOf(item->item, q)); } delete item; |