aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickabstractbutton.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-12-11 21:49:53 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2017-12-12 14:39:48 +0000
commitd9e740d2ccf8c1d3caacfcd95537718048e3a7ba (patch)
treed6a5cd642183974e1947275dee199270d3141310 /src/quicktemplates2/qquickabstractbutton.cpp
parent64a01ff5b5d1eaadb1e60013673ac25459b79e14 (diff)
Migitate the performance regression caused by deferred execution
458eb65f7 introduced a performance regression. Before 458eb65f7, qmlbench delegates_button.qml results were around 40 frames on a TX1. After 458eb65f, it dropped to 32. This patch is unfortunately not able to bring it on the original level, but at least improves the results to 37. For QQuickText, it is extremely important that implicitWidth() gets called before the component is completed, to avoid doing implicit size calculation multiple times. Deferred execution caused a performance regression by creating contentItem in "one go". We need to split the deferred execution to two parts so that bindings get first setup, and later enabled upon completion. This way, we utilize QQuickText's performance optimization for implicit size calculation. Task-number: QTBUG-50992 Change-Id: I4bf00af71b6d7dbf1d4b58b00fe547c6c321f8ed Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickabstractbutton.cpp')
-rw-r--r--src/quicktemplates2/qquickabstractbutton.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp
index f87ee0ef..48d5fceb 100644
--- a/src/quicktemplates2/qquickabstractbutton.cpp
+++ b/src/quicktemplates2/qquickabstractbutton.cpp
@@ -133,8 +133,9 @@ QQuickAbstractButtonPrivate::QQuickAbstractButtonPrivate()
QQuickItem *QQuickAbstractButtonPrivate::getContentItem()
{
- executeContentItem();
- return QQuickControlPrivate::getContentItem();
+ if (!contentItem)
+ executeContentItem();
+ return contentItem;
}
void QQuickAbstractButtonPrivate::handlePress(const QPointF &point)
@@ -265,10 +266,18 @@ void QQuickAbstractButtonPrivate::toggle(bool value)
emit q->toggled();
}
-void QQuickAbstractButtonPrivate::executeIndicator()
+static inline QString indicatorName() { return QStringLiteral("indicator"); }
+
+void QQuickAbstractButtonPrivate::executeIndicator(bool complete)
{
- Q_Q(QQuickAbstractButton);
- quickExecuteDeferred(q, QStringLiteral("indicator"), indicator);
+ Q_Q(QQuickControl);
+ if (indicator.wasExecuted())
+ return;
+
+ if (!indicator)
+ quickBeginDeferred(q, indicatorName(), indicator);
+ if (complete)
+ quickCompleteDeferred(q, indicatorName(), indicator);
}
QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
@@ -559,7 +568,8 @@ void QQuickAbstractButton::setAutoRepeat(bool repeat)
QQuickItem *QQuickAbstractButton::indicator() const
{
QQuickAbstractButtonPrivate *d = const_cast<QQuickAbstractButtonPrivate *>(d_func());
- d->executeIndicator();
+ if (!d->indicator)
+ d->executeIndicator();
return d->indicator;
}
@@ -594,9 +604,9 @@ void QQuickAbstractButton::toggle()
void QQuickAbstractButton::componentComplete()
{
Q_D(QQuickAbstractButton);
- d->executeIndicator();
- d->executeBackground();
- d->executeContentItem();
+ d->executeIndicator(true);
+ d->executeBackground(true);
+ d->executeContentItem(true);
QQuickControl::componentComplete();
}