aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qquickanimatorcontroller_p.h
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@digia.com>2013-11-01 15:49:33 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-06 19:19:34 +0100
commit63e0ffb32a4a432ed57f31388fabff89b05cb8cc (patch)
tree8c4927b577bb47789b85368d55ebee2544938352 /src/quick/util/qquickanimatorcontroller_p.h
parente0458defdfadeb3a1fb92eb12b14fce9191fe1ee (diff)
Refactored Animator internals
Change the design from posting events for starting and stopping to use the scene graph's existing 'sync' point. This gives much higher predictability and makes both ownership and cleanup cleaner and also reduces intermediate states while events are waiting to be delivered. Task-number: QTBUG-34137 Change-Id: I069ac22acbddaa47925b8172ba98ac340fe9bf8d 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.h63
1 files changed, 23 insertions, 40 deletions
diff --git a/src/quick/util/qquickanimatorcontroller_p.h b/src/quick/util/qquickanimatorcontroller_p.h
index ab08bf05db..6223a9938f 100644
--- a/src/quick/util/qquickanimatorcontroller_p.h
+++ b/src/quick/util/qquickanimatorcontroller_p.h
@@ -47,6 +47,7 @@
#include <QtQuick/qquickitem.h>
#include <QtCore/qmutex.h>
+#include <QtCore/qthread.h>
QT_BEGIN_NAMESPACE
@@ -55,27 +56,6 @@ class QQuickAnimatorController : public QObject, public QAnimationJobChangeListe
Q_OBJECT
public:
-
- enum EventType {
- // GUI to RT events
- StartAnimation = QEvent::User + 1,
- StopAnimation,
- DeleteAnimation,
-
- // RT back to GUI events
- AnimationFinished
- };
-
- class Event : public QEvent {
- public:
- Event(QAbstractAnimationJob *j, EventType type)
- : QEvent(QEvent::Type(type))
- , job(j)
- {
- }
- QAbstractAnimationJob *job;
- };
-
QQuickAnimatorController();
~QQuickAnimatorController();
@@ -83,32 +63,35 @@ public:
void beforeNodeSync();
void afterNodeSync();
- bool event(QEvent *);
+ void animationFinished(QAbstractAnimationJob *job);
+ void animationStateChanged(QAbstractAnimationJob *job, QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState);
- void startAnimation(QAbstractAnimationJob *job);
+ void requestSync();
- void animationStateChanged(QAbstractAnimationJob *job,
- QAbstractAnimationJob::State newState,
- QAbstractAnimationJob::State oldState);
+ // 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 lock() { m_mutex.lock(); }
+ void unlock() { m_mutex.unlock(); }
public Q_SLOTS:
- void animationsStarted();
void itemDestroyed(QObject *);
public:
- QList<QAbstractAnimationJob *> starting;
- QList<QAbstractAnimationJob *> stopped;
-
- QSet<QAbstractAnimationJob *> activeRootAnimations;
- QSet<QQuickAnimatorJob *> activeLeafAnimations;
-
- QHash<QQuickItem *, QQuickTransformAnimatorJob::Helper *> transforms;
-
- QSet<QQuickItem *> deletedSinceLastFrame;
-
- QQuickWindow *window;
-
- QMutex mutex;
+ // 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;
+ QQuickWindow *m_window;
+ QMutex m_mutex;
};
QT_END_NAMESPACE