aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquicktumbler_p_p.h
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-10-30 15:17:25 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2017-11-02 08:33:30 +0000
commit6f89cf6370daa443169d24ce45a925000b6e0248 (patch)
tree199a3fa13b698fa93cdf99e7214309fcae456927 /src/quicktemplates2/qquicktumbler_p_p.h
parente02ebcdb0b10b1c9f077d813c08d83e0d17ca6b5 (diff)
Optimize QQuickTumbler
Listen to the relevant view changes once in QQuickTumbler and cache the offset/contentY instead of every QQuickTumblerAttached instance doing its own geometry and child tracking, and cache the view offset or contentY so that they are readily available while calculating displacements for attached property objects. This gives a 5% boost (40->42 frames in qmlbench) on TX1 in release mode. Change-Id: If1a77468e812e65bc07f32216ff9bf2e1dc5b935 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquicktumbler_p_p.h')
-rw-r--r--src/quicktemplates2/qquicktumbler_p_p.h37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/quicktemplates2/qquicktumbler_p_p.h b/src/quicktemplates2/qquicktumbler_p_p.h
index 0dcae762..fe8a4ad2 100644
--- a/src/quicktemplates2/qquicktumbler_p_p.h
+++ b/src/quicktemplates2/qquicktumbler_p_p.h
@@ -50,11 +50,10 @@
#include <QtQuick/private/qquickitemchangelistener_p.h>
#include <QtQuickTemplates2/private/qquickcontrol_p_p.h>
+#include <QtQuickTemplates2/private/qquicktumbler_p.h>
QT_BEGIN_NAMESPACE
-class QQuickTumbler;
-
class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickTumblerPrivate : public QQuickControlPrivate, public QQuickItemChangeListener
{
Q_DECLARE_PUBLIC(QQuickTumbler)
@@ -84,6 +83,10 @@ public:
QQuickItem *view;
QQuickItem *viewContentItem;
ContentItemType viewContentItemType;
+ union {
+ qreal viewOffset; // PathView
+ qreal viewContentY; // ListView
+ };
int currentIndex;
int pendingCurrentIndex;
bool ignoreCurrentIndexChanges;
@@ -94,6 +97,10 @@ public:
void _q_updateItemWidths();
void _q_onViewCurrentIndexChanged();
void _q_onViewCountChanged();
+ void _q_onViewOffsetChanged();
+ void _q_onViewContentYChanged();
+
+ void calculateDisplacements();
void disconnectFromView();
void setupViewData(QQuickItem *newControlContentItem);
@@ -107,6 +114,32 @@ public:
void itemChildAdded(QQuickItem *, QQuickItem *) override;
void itemChildRemoved(QQuickItem *, QQuickItem *) override;
+ void itemGeometryChanged(QQuickItem *, QQuickGeometryChange , const QRectF &) override;
+};
+
+class QQuickTumblerAttachedPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickTumblerAttached)
+
+public:
+ QQuickTumblerAttachedPrivate();
+
+ static QQuickTumblerAttachedPrivate *get(QQuickTumblerAttached *attached)
+ {
+ return attached->d_func();
+ }
+
+ void init(QQuickItem *delegateItem);
+
+ void calculateDisplacement();
+ void emitIfDisplacementChanged(qreal oldDisplacement, qreal newDisplacement);
+
+ // The Tumbler that contains the delegate. Required to calculated the displacement.
+ QPointer<QQuickTumbler> tumbler;
+ // The index of the delegate. Used to calculate the displacement.
+ int index;
+ // The displacement for our delegate.
+ qreal displacement;
};
QT_END_NAMESPACE