1// Copyright (C) 2016 The Qt Company Ltd.
2// Copyright (C) 2016 Gunnar Sletta <gunnar@sletta.org>
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#ifndef QQUICKANIMATORCONTROLLER_P_H
6#define QQUICKANIMATORCONTROLLER_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include "qquickanimatorjob_p.h"
20#include <QtQuick/qsgnode.h>
21#include <QtQuick/qquickitem.h>
22
23#include <QtCore/qmutex.h>
24#include <QtCore/qthread.h>
25
26QT_BEGIN_NAMESPACE
27
28class Q_AUTOTEST_EXPORT QQuickAnimatorController : public QObject, public QAnimationJobChangeListener
29{
30 Q_OBJECT
31
32public:
33 QQuickAnimatorController(QQuickWindow *window);
34 ~QQuickAnimatorController();
35
36 void advance();
37 void beforeNodeSync();
38 void afterNodeSync();
39
40 void animationFinished(QAbstractAnimationJob *job) override;
41 void animationStateChanged(QAbstractAnimationJob *job, QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState) override;
42
43 void requestSync();
44
45 // These are called from the GUI thread (the proxy)
46 void start(const QSharedPointer<QAbstractAnimationJob> &job);
47 void cancel(const QSharedPointer<QAbstractAnimationJob> &job);
48 bool isPendingStart(const QSharedPointer<QAbstractAnimationJob> &job) const { return m_rootsPendingStart.contains(value: job); }
49
50 void lock() { m_mutex.lock(); }
51 void unlock() { m_mutex.unlock(); }
52
53 void windowNodesDestroyed();
54
55 QQuickWindow *window() const { return m_window; }
56
57private:
58 friend class tst_Animators;
59
60 void start_helper(QAbstractAnimationJob *job);
61 void cancel_helper(QAbstractAnimationJob *job);
62
63 QSet<QQuickAnimatorJob * > m_runningAnimators;
64 QHash<QAbstractAnimationJob *, QSharedPointer<QAbstractAnimationJob> > m_animationRoots;
65 QSet<QSharedPointer<QAbstractAnimationJob> > m_rootsPendingStop;
66 QSet<QSharedPointer<QAbstractAnimationJob> > m_rootsPendingStart;
67
68 QQuickWindow *m_window;
69 QMutex m_mutex;
70};
71
72
73
74QT_END_NAMESPACE
75
76#endif // QQUICKANIMATORCONTROLLER_P_H
77

source code of qtdeclarative/src/quick/util/qquickanimatorcontroller_p.h