Set a non-zero default cacheBuffer.
authorMartin Jones <martin.jones@nokia.com>
Mon, 11 Jun 2012 23:19:35 +0000 (09:19 +1000)
committerQt by Nokia <qt-info@nokia.com>
Tue, 12 Jun 2012 23:41:58 +0000 (01:41 +0200)
The likelihood of constant framerate when flicking is considerably
improved by having a cacheBuffer.  Since there is only a minimal cost
in having a modest cacheBuffer, it is better to have a more optimal
default value - 320 seems a good starting point.

Change-Id: Id3c8a153821573b5b08c6fbd80d34152908d358d
Reviewed-by: Bea Lam <bea.lam@nokia.com>

33 files changed:
src/quick/items/qquickgridview.cpp
src/quick/items/qquickitemview.cpp
src/quick/items/qquicklistview.cpp
tests/auto/quick/qquickgridview/data/addTransitions.qml
tests/auto/quick/qquickgridview/data/displacedTransitions.qml
tests/auto/quick/qquickgridview/data/gridview-initCurrent.qml
tests/auto/quick/qquickgridview/data/gridview-noCurrent.qml
tests/auto/quick/qquickgridview/data/layouts.qml
tests/auto/quick/qquickgridview/data/margins.qml
tests/auto/quick/qquickgridview/data/moveTransitions.qml
tests/auto/quick/qquickgridview/data/multipleDisplaced.qml
tests/auto/quick/qquickgridview/data/multipleTransitions.qml
tests/auto/quick/qquickgridview/data/populateTransitions.qml
tests/auto/quick/qquickgridview/data/removeTransitions.qml
tests/auto/quick/qquickgridview/data/resizeview.qml
tests/auto/quick/qquickgridview/data/unrequestedItems.qml
tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
tests/auto/quick/qquicklistview/data/addTransitions.qml
tests/auto/quick/qquicklistview/data/displacedTransitions.qml
tests/auto/quick/qquicklistview/data/header.qml
tests/auto/quick/qquicklistview/data/listview-enforcerange.qml
tests/auto/quick/qquicklistview/data/listview-noCurrent.qml
tests/auto/quick/qquicklistview/data/listview-sections-package.qml
tests/auto/quick/qquicklistview/data/listview-sections_delegate.qml
tests/auto/quick/qquicklistview/data/margins.qml
tests/auto/quick/qquicklistview/data/moveTransitions.qml
tests/auto/quick/qquicklistview/data/multipleDisplaced.qml
tests/auto/quick/qquicklistview/data/multipleTransitions.qml
tests/auto/quick/qquicklistview/data/populateTransitions.qml
tests/auto/quick/qquicklistview/data/removeTransitions.qml
tests/auto/quick/qquicklistview/data/resizeview.qml
tests/auto/quick/qquicklistview/data/unrequestedItems.qml
tests/auto/quick/qquickvisualdatamodel/data/packageView.qml

index 331f23e..fa1e96c 100644 (file)
@@ -1533,8 +1533,10 @@ void QQuickGridView::setHighlightFollowsCurrentItem(bool autoHighlight)
     area may be created/retained.  The buffered delegates are created asynchronously,
     allowing creation to occur across multiple frames and reducing the
     likelihood of skipping frames.  In order to improve painting performance
-    delegates outside the visible area have their \l visible property set to
-    false until they are moved into the visible area.
+    delegates outside the visible area are not painted.
+
+    The default value of this property is platform dependent, but will usually
+    be a non-zero value.
 
     Note that cacheBuffer is not a pixel buffer - it only maintains additional
     instantiated delegates.
index 26580e0..8b8f935 100644 (file)
 
 #include "qquickitemview_p_p.h"
 #include <QtQuick/private/qquicktransition_p.h>
+#include "qplatformdefs.h"
 
 QT_BEGIN_NAMESPACE
 
+// Default cacheBuffer for all views.
+#ifndef QML_VIEW_DEFAULTCACHEBUFFER
+#define QML_VIEW_DEFAULTCACHEBUFFER 320
+#endif
 
 FxViewItem::FxViewItem(QQuickItem *i, bool own, bool trackGeometry)
     : item(i)
@@ -1410,7 +1415,7 @@ void QQuickItemView::componentComplete()
 
 QQuickItemViewPrivate::QQuickItemViewPrivate()
     : itemCount(0)
-    , buffer(0), bufferMode(BufferBefore | BufferAfter)
+    , buffer(QML_VIEW_DEFAULTCACHEBUFFER), bufferMode(BufferBefore | BufferAfter)
     , layoutDirection(Qt::LeftToRight), verticalLayoutDirection(QQuickItemView::TopToBottom)
     , moveReason(Other)
     , visibleIndex(0)
index 75d4933..5401abc 100644 (file)
@@ -2094,8 +2094,10 @@ void QQuickListView::setOrientation(QQuickListView::Orientation orientation)
     area may be created/retained.  The buffered delegates are created asynchronously,
     allowing creation to occur across multiple frames and reducing the
     likelihood of skipping frames.  In order to improve painting performance
-    delegates outside the visible area have their \l visible property set to
-    false until they are moved into the visible area.
+    delegates outside the visible area are not painted.
+
+    The default value of this property is platform dependent, but will usually
+    be a non-zero value.
 
     Note that cacheBuffer is not a pixel buffer - it only maintains additional
     instantiated delegates.
index 3f47cbd..14ed2dc 100644 (file)
@@ -64,6 +64,7 @@ Rectangle {
         height: 320
         cellWidth: 80
         cellHeight: 60
+        cacheBuffer: 0
         anchors.centerIn: parent
         model: testModel
         delegate: myDelegate
index 4abf401..4c36b76 100644 (file)
@@ -80,6 +80,7 @@ Rectangle {
         height: 320
         cellWidth: 80
         cellHeight: 60
+        cacheBuffer: 0
         model: testModel
         delegate: myDelegate
 
index 624f639..af35d2f 100644 (file)
@@ -57,6 +57,7 @@ Rectangle {
         currentIndex: 35
         cellWidth: 80
         cellHeight: 60
+        cacheBuffer: 0
         delegate: myDelegate
         highlightMoveDuration: 400
         model: testModel
index 600716e..4867075 100644 (file)
@@ -46,6 +46,7 @@ Rectangle {
         currentIndex: -1
         cellWidth: 80
         cellHeight: 60
+        cacheBuffer: 0
         delegate: myDelegate
         model: testModel
     }
index e00351f..f528841 100644 (file)
@@ -51,6 +51,7 @@ Rectangle {
         height: 320
         cellWidth: 80
         cellHeight: 60
+        cacheBuffer: 0
         flow: (testTopToBottom == false) ? GridView.LeftToRight : GridView.TopToBottom
         layoutDirection: (testRightToLeft == true) ? Qt.RightToLeft : Qt.LeftToRight
         verticalLayoutDirection: (testBottomToTop == true) ? GridView.BottomToTop : GridView.TopToBottom
index d369658..e2ee6d6 100644 (file)
@@ -44,6 +44,7 @@ Rectangle {
         height: 320
         cellWidth: 100
         cellHeight: 80
+        cacheBuffer: 0
         leftMargin: 30
         rightMargin: 50
         flow: GridView.TopToBottom
index a91f5a3..8850b46 100644 (file)
@@ -63,6 +63,7 @@ Rectangle {
         height: 320
         cellWidth: 80
         cellHeight: 60
+        cacheBuffer: 0
         anchors.centerIn: parent
         model: testModel
         delegate: myDelegate
index 7c48bf3..973f0ac 100644 (file)
@@ -45,6 +45,7 @@ Rectangle {
         anchors.centerIn: parent
         width: 240
         height: 320
+        cacheBuffer: 0
         cellWidth: 80
         cellHeight: 60
         model: testModel
index cfe0be7..8112fea 100644 (file)
@@ -55,6 +55,7 @@ Rectangle {
         cellWidth: 80
         cellHeight: 60
         anchors.centerIn: parent
+        cacheBuffer: 0
         model: testModel
         delegate: myDelegate
 
index c12d5ac..9060a4b 100644 (file)
@@ -54,6 +54,7 @@ Rectangle {
         height: 320
         cellWidth: 80
         cellHeight: 60
+        cacheBuffer: 0
         model: testModel
         delegate: myDelegate
 
index 3e82cf7..ec9156d 100644 (file)
@@ -65,6 +65,7 @@ Rectangle {
         height: 320
         cellWidth: 80
         cellHeight: 60
+        cacheBuffer: 0
         anchors.centerIn: parent
         model: testModel
         delegate: myDelegate
index 130a0de..eb7fb49 100644 (file)
@@ -13,6 +13,7 @@ Rectangle {
         height: initialHeight
         cellWidth: 80
         cellHeight: 60
+        cacheBuffer: 0
         model: testModel
         delegate: Rectangle {
             objectName: "wrapper"
index 79f845f..bedb90b 100644 (file)
@@ -55,6 +55,7 @@ Item {
         model: visualModel.parts.left
         cellWidth: 60
         cellHeight: 80
+        cacheBuffer: 0
     }
 
     GridView {
@@ -67,5 +68,6 @@ Item {
         model: visualModel.parts.right
         cellWidth: 60
         cellHeight: 80
+        cacheBuffer: 0
     }
 }
index d7eb5b2..9876a36 100644 (file)
@@ -58,6 +58,7 @@
 #include "../shared/viewtestutil.h"
 #include "../shared/visualtestutil.h"
 #include <QtGui/qguiapplication.h>
+#include "qplatformdefs.h"
 
 Q_DECLARE_METATYPE(QQuickGridView::Flow)
 Q_DECLARE_METATYPE(Qt::LayoutDirection)
@@ -2236,7 +2237,11 @@ void tst_QQuickGridView::defaultValues()
     QTRY_COMPARE(obj->highlightFollowsCurrentItem(), true);
     QTRY_VERIFY(obj->flow() == 0);
     QTRY_COMPARE(obj->isWrapEnabled(), false);
-    QTRY_COMPARE(obj->cacheBuffer(), 0);
+#ifdef QML_VIEW_DEFAULTCACHEBUFFER
+    QTRY_COMPARE(obj->cacheBuffer(), QML_VIEW_DEFAULTCACHEBUFFER);
+#else
+    QTRY_COMPARE(obj->cacheBuffer(), 320);
+#endif
     QTRY_COMPARE(obj->cellWidth(), qreal(100)); //### Should 100 be the default?
     QTRY_COMPARE(obj->cellHeight(), qreal(100));
     delete obj;
index 6a7c323..69e6ba1 100644 (file)
@@ -62,6 +62,7 @@ Rectangle {
         anchors.centerIn: parent
         width: 240
         height: 320
+        cacheBuffer: 0
         model: testModel
         delegate: myDelegate
 
index 573bf2b..d83ccfe 100644 (file)
@@ -69,6 +69,7 @@ Rectangle {
         anchors.centerIn: parent
         width: 240
         height: 320
+        cacheBuffer: 0
         model: testModel
         delegate: myDelegate
 
index 1cc4ae0..076bf9c 100644 (file)
@@ -26,6 +26,7 @@ Rectangle {
         focus: true
         width: initialViewWidth
         height: initialViewHeight
+        cacheBuffer: 0
         snapMode: ListView.SnapToItem
         model: testModel
         delegate: myDelegate
index f1bf6c2..f1052b1 100644 (file)
@@ -45,6 +45,7 @@ Rectangle {
         objectName: "list"
         width: 240
         height: 320
+        cacheBuffer: 0
         model: testModel
         delegate: myDelegate
         highlight: myHighlight
index 079966d..cb90300 100644 (file)
@@ -43,6 +43,7 @@ Rectangle {
         currentIndex: -1
         width: 240
         height: 320
+        cacheBuffer: 0
         delegate: myDelegate
         highlightMoveSpeed: 1000
         model: testModel
index 8e5a4c4..e0daf50 100644 (file)
@@ -68,5 +68,6 @@ Rectangle {
         height: 320
         model: visualModel.parts.package
         section.property: "number"
+        cacheBuffer: 0
     }
 }
index 496d8d7..d82ff4c 100644 (file)
@@ -56,6 +56,7 @@ Rectangle {
         objectName: "list"
         width: 240
         height: 320
+        cacheBuffer: 0
         model: testModel
         delegate: myDelegate
         section.property: sectionProperty
index 19bbef5..2d7b7ca 100644 (file)
@@ -41,6 +41,7 @@ Rectangle {
         anchors.fill: parent
         topMargin: 30
         bottomMargin: 50
+        cacheBuffer: 0
         model: testModel
         delegate: myDelegate
     }
index 2f907bd..c4dce99 100644 (file)
@@ -62,6 +62,7 @@ Rectangle {
         anchors.centerIn: parent
         width: 240
         height: 320
+        cacheBuffer: 0
         model: testModel
         delegate: myDelegate
 
index e315270..5893c30 100644 (file)
@@ -44,6 +44,7 @@ Rectangle {
         anchors.centerIn: parent
         width: 240
         height: 320
+        cacheBuffer: 0
         model: testModel
         delegate: myDelegate
 
index c0e888c..4fcc80b 100644 (file)
@@ -53,6 +53,7 @@ Rectangle {
         anchors.centerIn: parent
         width: 240
         height: 320
+        cacheBuffer: 0
         model: testModel
         delegate: myDelegate
 
index 0994e09..84b5b6b 100644 (file)
@@ -52,6 +52,7 @@ Rectangle {
         anchors.centerIn: parent
         width: 240
         height: 320
+        cacheBuffer: 0
         model: testModel
         delegate: myDelegate
 
index a85b217..861cf42 100644 (file)
@@ -64,6 +64,7 @@ Rectangle {
         anchors.centerIn: parent
         width: 240
         height: 320
+        cacheBuffer: 0
         model: testModel
         delegate: myDelegate
 
index 8b13adb..931e7b9 100644 (file)
@@ -12,6 +12,7 @@ Rectangle {
         id: list
         objectName: "list"
         width: 240
+        cacheBuffer: 0
         height: initialHeight
         model: testModel
         delegate: Rectangle {
index 682f383..e3719a8 100644 (file)
@@ -44,6 +44,7 @@ Item {
     ListView {
         id: leftList
         objectName: "leftList"
+        cacheBuffer: 0
         anchors {
             left: parent.left; top: parent.top;
             right: parent.horizontalCenter; bottom: parent.bottom
@@ -54,6 +55,7 @@ Item {
     ListView {
         id: rightList
         objectName: "rightList"
+        cacheBuffer: 0
         anchors {
             left: parent.horizontalCenter; top: parent.top;
             right: parent.right; bottom: parent.bottom
index 682f383..e3719a8 100644 (file)
@@ -44,6 +44,7 @@ Item {
     ListView {
         id: leftList
         objectName: "leftList"
+        cacheBuffer: 0
         anchors {
             left: parent.left; top: parent.top;
             right: parent.horizontalCenter; bottom: parent.bottom
@@ -54,6 +55,7 @@ Item {
     ListView {
         id: rightList
         objectName: "rightList"
+        cacheBuffer: 0
         anchors {
             left: parent.horizontalCenter; top: parent.top;
             right: parent.right; bottom: parent.bottom