From 458eb65f730178bc93ba7b18f0e4dd2a13efad2e Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 6 Sep 2017 12:48:55 +0200 Subject: Buttons: defer the execution of the delegates In practice, deferring the execution of the delegates (until accessed) means that the default delegate item does not get created at all, when a custom control replaces it at construction time. Button { background: Rectangle { ... } } Before, such custom Button would never be faster than the original one, because the default delegate was first created and then thrown away at construction time. Originally, this was not considered a huge problem, because the plan was to keep the default delegates so light- weight that it wouldn't matter. However, then came the fancy styles with shadows and effects and thus, heavier default delegates. There's also a growing demand for more features, and the default delegates are slowly getting heavier... Now, after this patch, if you replace a heavy default delegate with a light and simple custom delegate, the result is a much faster control. For example, replacing Material style Button's background, which has a shadow effect, with a plain Rectangle gives a ~10x boost, because the default background with its heavy shadow effect is not executed at all. At the same time, deferring the execution of the default delegates avoids troubles with asynchronous incubation, because we don't need to destroy an object in the middle of the incubation process. Task-number: QTBUG-50992 Change-Id: I2274bff99b9ff126d3748278d58d859222910c98 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickabstractbutton_p_p.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/quicktemplates2/qquickabstractbutton_p_p.h') diff --git a/src/quicktemplates2/qquickabstractbutton_p_p.h b/src/quicktemplates2/qquickabstractbutton_p_p.h index 39af6896..5a2a52c7 100644 --- a/src/quicktemplates2/qquickabstractbutton_p_p.h +++ b/src/quicktemplates2/qquickabstractbutton_p_p.h @@ -67,6 +67,8 @@ public: return button->d_func(); } + QQuickItem *getContentItem() override; + void handlePress(const QPointF &point) override; void handleMove(const QPointF &point) override; void handleRelease(const QPointF &point) override; @@ -85,6 +87,8 @@ public: void toggle(bool value); + void executeIndicator(); + QString text; bool down; bool explicitDown; @@ -100,7 +104,7 @@ public: int repeatTimer; QPointF pressPoint; Qt::MouseButtons pressButtons; - QQuickItem *indicator; + QQuickDeferredPointer indicator; QQuickButtonGroup *group; }; -- cgit v1.2.3 From d9e740d2ccf8c1d3caacfcd95537718048e3a7ba Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 11 Dec 2017 21:49:53 +0100 Subject: 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 --- src/quicktemplates2/qquickabstractbutton_p_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/quicktemplates2/qquickabstractbutton_p_p.h') diff --git a/src/quicktemplates2/qquickabstractbutton_p_p.h b/src/quicktemplates2/qquickabstractbutton_p_p.h index 5a2a52c7..0d8eab81 100644 --- a/src/quicktemplates2/qquickabstractbutton_p_p.h +++ b/src/quicktemplates2/qquickabstractbutton_p_p.h @@ -87,7 +87,7 @@ public: void toggle(bool value); - void executeIndicator(); + void executeIndicator(bool complete = false); QString text; bool down; -- cgit v1.2.3 From 6b89293b99e763589181fd1f75470712f52cee3c Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 14 Dec 2017 20:00:46 +0100 Subject: Control: defer the execution of the content item Tumbler is excluded because test_customContentItemAtConstruction() starts failing if deferred execution is enabled for the content item. Task-number: QTBUG-50992 Change-Id: I11022c3c380311396453cf6229e068e4aae2d82a Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickabstractbutton_p_p.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/quicktemplates2/qquickabstractbutton_p_p.h') diff --git a/src/quicktemplates2/qquickabstractbutton_p_p.h b/src/quicktemplates2/qquickabstractbutton_p_p.h index 0d8eab81..6634971e 100644 --- a/src/quicktemplates2/qquickabstractbutton_p_p.h +++ b/src/quicktemplates2/qquickabstractbutton_p_p.h @@ -67,8 +67,6 @@ public: return button->d_func(); } - QQuickItem *getContentItem() override; - void handlePress(const QPointF &point) override; void handleMove(const QPointF &point) override; void handleRelease(const QPointF &point) override; -- cgit v1.2.3