aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qquickanimatorcontroller_p.h
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar@sletta.org>2016-08-23 12:38:14 +0200
committerGunnar Sletta <gunnar@sletta.org>2016-10-12 18:12:28 +0000
commitae80962806f44fc9f58de14d62229771b836cb93 (patch)
treee73a36fb943640a66e14c15a3582265ebbe9e306 /src/quick/util/qquickanimatorcontroller_p.h
parentebb8e81050b40645f0e80f0ec59773790928df75 (diff)
Redo animator internals
The animators have suffered from crashes at runtime and instability during testing which have led them to not live up to their potential. This change brings some new concepts to try to make the situation a bit better: Firstly, the ownership of the render thread animation job is maintained using a QSharedPointer, greatly simplifying the management of that object. For the most part it will be deleted on the render thread, but if not, then that is ok too. Secondly, the proxy job is no longer tied to the animation controller. It simply starts the job on the render thread and polls to see if it has completed and only then performs the write back into the source item. Thirdly, the transform helper object which unifies x, y, scale and rotation animators into one matrix has been moved out of the controller and is striclty managed by the transform jobs. Finally, the qmlbench testcase indicates this new implementation is almost 10% faster than the old one, so the addition of shared pointers have not caused any significant performance additions. Change-Id: I51bbc43f716f8635fea97a08f2367e10cde95499 Reviewed-by: Michael Brasser <michael.brasser@live.com> Reviewed-by: Anton Kudryavtsev <a.kudryavtsev@netris.ru>
Diffstat (limited to 'src/quick/util/qquickanimatorcontroller_p.h')
-rw-r--r--src/quick/util/qquickanimatorcontroller_p.h44
1 files changed, 14 insertions, 30 deletions
diff --git a/src/quick/util/qquickanimatorcontroller_p.h b/src/quick/util/qquickanimatorcontroller_p.h
index b63518abad..1ec44ccc9d 100644
--- a/src/quick/util/qquickanimatorcontroller_p.h
+++ b/src/quick/util/qquickanimatorcontroller_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2016 Gunnar Sletta <gunnar@sletta.org>
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQuick module of the Qt Toolkit.
@@ -60,8 +61,6 @@
QT_BEGIN_NAMESPACE
-class QQuickAnimatorControllerGuiThreadEntity;
-
class QQuickAnimatorController : public QObject, public QAnimationJobChangeListener
{
Q_OBJECT
@@ -80,50 +79,35 @@ public:
void requestSync();
// These are called from the GUI thread (the proxy)
- void startJob(QQuickAnimatorProxyJob *proxy, QAbstractAnimationJob *job);
- void stopJob(QQuickAnimatorProxyJob *proxy, QAbstractAnimationJob *job);
- void deleteJob(QAbstractAnimationJob *job);
+ void start(const QSharedPointer<QAbstractAnimationJob> &job);
+ void cancel(const QSharedPointer<QAbstractAnimationJob> &job);
+ bool isPendingStart(const QSharedPointer<QAbstractAnimationJob> &job) const { return m_rootsPendingStart.contains(job); }
void lock() { m_mutex.lock(); }
void unlock() { m_mutex.unlock(); }
-
void proxyWasDestroyed(QQuickAnimatorProxyJob *proxy);
void stopProxyJobs();
void windowNodesDestroyed();
-public Q_SLOTS:
- void itemDestroyed(QObject *);
+ QQuickWindow *window() const { return m_window; }
+
+private:
+ void start_helper(QAbstractAnimationJob *job);
+ void cancel_helper(QAbstractAnimationJob *job);
public:
- // These are manipulated from the GUI thread and should only
- // be updated during the sync() phase.
- QHash<QAbstractAnimationJob *, QQuickAnimatorProxyJob *> m_starting;
- QHash<QAbstractAnimationJob *, QQuickAnimatorProxyJob *> m_stopping;
- QSet<QAbstractAnimationJob *> m_deleting;
-
- QHash<QAbstractAnimationJob *, QQuickAnimatorProxyJob *> m_animatorRoots;
- QSet<QQuickAnimatorJob *> m_activeLeafAnimations;
- QHash<QQuickItem *, QQuickTransformAnimatorJob::Helper *> m_transforms;
- QSet<QQuickItem *> m_deletedSinceLastFrame;
+ QSet<QQuickAnimatorJob * > m_runningAnimators;
+ QHash<QAbstractAnimationJob *, QSharedPointer<QAbstractAnimationJob> > m_animationRoots;
+ QSet<QSharedPointer<QAbstractAnimationJob> > m_rootsPendingStop;
+ QSet<QSharedPointer<QAbstractAnimationJob> > m_rootsPendingStart;
+
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