diff options
author | Gunnar Sletta <gunnar@sletta.org> | 2014-10-07 12:22:26 +0200 |
---|---|---|
committer | Gunnar Sletta <gunnar@sletta.org> | 2014-10-10 21:10:52 +0200 |
commit | 099ae0597df6f6bbd0b9e05d063a4a58c9cae2ff (patch) | |
tree | ccfaf743aa3a572d362927131311787dd98c599b /src/quick/util/qquickanimatorcontroller_p.h | |
parent | 7f5a59c2025022f99dff9fa030c892adb4473d6a (diff) |
Improve performance of animators.v5.4.0-beta1
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 <michael.brasser@live.com>
Diffstat (limited to 'src/quick/util/qquickanimatorcontroller_p.h')
-rw-r--r-- | src/quick/util/qquickanimatorcontroller_p.h | 21 |
1 files changed, 20 insertions, 1 deletions
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<QQuickItem *, QQuickTransformAnimatorJob::Helper *> m_transforms; QSet<QQuickItem *> m_deletedSinceLastFrame; QQuickWindow *m_window; + QQuickAnimatorControllerGuiThreadEntity *m_guiEntity; + QSet<QQuickAnimatorProxyJob *> m_proxiesToStop; QMutex m_mutex; bool m_nodesAreInvalid; }; +class QQuickAnimatorControllerGuiThreadEntity : public QObject +{ + Q_OBJECT +public: + QPointer<QQuickAnimatorController> controller; + +public Q_SLOTS: + void frameSwapped(); +}; + + + QT_END_NAMESPACE #endif // QQUICKANIMATORCONTROLLER_P_H |