From 099ae0597df6f6bbd0b9e05d063a4a58c9cae2ff Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Tue, 7 Oct 2014 12:22:26 +0200 Subject: Improve performance of animators. The use of one QCoreApp::postEvent() per completed animation added up to a very large overhead when 1000+ animators were used at the same time. This is very relevant for sprite games and similar and deserves to work at least as good as normal animations. Instead, store the animations to stop and stop then on the gui thread later as a result of frameSwapped. For the benchmark in question this allows for roughly double the amount of animators being started and stopped. Change-Id: Iae3d1ec1502ee1908fdbba708fa9f976aa230064 Reviewed-by: Michael Brasser --- src/quick/util/qquickanimatorcontroller_p.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/quick/util/qquickanimatorcontroller_p.h') diff --git a/src/quick/util/qquickanimatorcontroller_p.h b/src/quick/util/qquickanimatorcontroller_p.h index bd44adf928..b13c174606 100644 --- a/src/quick/util/qquickanimatorcontroller_p.h +++ b/src/quick/util/qquickanimatorcontroller_p.h @@ -43,12 +43,14 @@ QT_BEGIN_NAMESPACE +class QQuickAnimatorControllerGuiThreadEntity; + class QQuickAnimatorController : public QObject, public QAnimationJobChangeListener { Q_OBJECT public: - QQuickAnimatorController(); + QQuickAnimatorController(QQuickWindow *window); ~QQuickAnimatorController(); void advance(); @@ -68,6 +70,9 @@ public: void lock() { m_mutex.lock(); } void unlock() { m_mutex.unlock(); } + + void proxyWasDestroyed(QQuickAnimatorProxyJob *proxy); + void stopProxyJobs(); void windowNodesDestroyed(); public Q_SLOTS: @@ -85,11 +90,25 @@ public: QHash m_transforms; QSet m_deletedSinceLastFrame; QQuickWindow *m_window; + QQuickAnimatorControllerGuiThreadEntity *m_guiEntity; + QSet m_proxiesToStop; QMutex m_mutex; bool m_nodesAreInvalid; }; +class QQuickAnimatorControllerGuiThreadEntity : public QObject +{ + Q_OBJECT +public: + QPointer controller; + +public Q_SLOTS: + void frameSwapped(); +}; + + + QT_END_NAMESPACE #endif // QQUICKANIMATORCONTROLLER_P_H -- cgit v1.2.3