| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/animations/qabstractanimationjob_p.h |
| Source code | Switch to Preprocessed file |
| Line | Source | Count |
|---|---|---|
| 1 | /**************************************************************************** | - |
| 2 | ** | - |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | - |
| 4 | ** Contact: https://www.qt.io/licensing/ | - |
| 5 | ** | - |
| 6 | ** This file is part of the QtQml module of the Qt Toolkit. | - |
| 7 | ** | - |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
| 9 | ** Commercial License Usage | - |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
| 11 | ** accordance with the commercial license agreement provided with the | - |
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | - |
| 16 | ** | - |
| 17 | ** GNU Lesser General Public License Usage | - |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
| 19 | ** General Public License version 3 as published by the Free Software | - |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - |
| 21 | ** packaging of this file. Please review the following information to | - |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | - |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - |
| 24 | ** | - |
| 25 | ** GNU General Public License Usage | - |
| 26 | ** Alternatively, this file may be used under the terms of the GNU | - |
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | - |
| 28 | ** Public license version 3 or any later version approved by the KDE Free | - |
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | - |
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - |
| 31 | ** included in the packaging of this file. Please review the following | - |
| 32 | ** information to ensure the GNU General Public License requirements will | - |
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - |
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - |
| 35 | ** | - |
| 36 | ** $QT_END_LICENSE$ | - |
| 37 | ** | - |
| 38 | ****************************************************************************/ | - |
| 39 | - | |
| 40 | #ifndef QABSTRACTANIMATIONJOB_P_H | - |
| 41 | #define QABSTRACTANIMATIONJOB_P_H | - |
| 42 | - | |
| 43 | // | - |
| 44 | // W A R N I N G | - |
| 45 | // ------------- | - |
| 46 | // | - |
| 47 | // This file is not part of the Qt API. It exists purely as an | - |
| 48 | // implementation detail. This header file may change from version to | - |
| 49 | // version without notice, or even be removed. | - |
| 50 | // | - |
| 51 | // We mean it. | - |
| 52 | // | - |
| 53 | - | |
| 54 | #include <private/qtqmlglobal_p.h> | - |
| 55 | #include <QtCore/QObject> | - |
| 56 | #include <QtCore/private/qabstractanimation_p.h> | - |
| 57 | #include <vector> | - |
| 58 | - | |
| 59 | QT_REQUIRE_CONFIG(qml_animation); | - |
| 60 | - | |
| 61 | QT_BEGIN_NAMESPACE | - |
| 62 | - | |
| 63 | class QAnimationGroupJob; | - |
| 64 | class QAnimationJobChangeListener; | - |
| 65 | class QQmlAnimationTimer; | - |
| 66 | - | |
| 67 | class Q_QML_PRIVATE_EXPORT QAbstractAnimationJob | - |
| 68 | { | - |
| 69 | Q_DISABLE_COPY(QAbstractAnimationJob) | - |
| 70 | public: | - |
| 71 | enum Direction { | - |
| 72 | Forward, | - |
| 73 | Backward | - |
| 74 | }; | - |
| 75 | - | |
| 76 | enum State { | - |
| 77 | Stopped, | - |
| 78 | Paused, | - |
| 79 | Running | - |
| 80 | }; | - |
| 81 | - | |
| 82 | QAbstractAnimationJob(); | - |
| 83 | virtual ~QAbstractAnimationJob(); | - |
| 84 | - | |
| 85 | //definition | - |
| 86 | inline QAnimationGroupJob *group() const {return m_group;} executed 10 times by 2 tests: return m_group;Executed by:
| 10 |
| 87 | - | |
| 88 | inline int loopCount() const {return m_loopCount;} executed 1532967 times by 19 tests: return m_loopCount;Executed by:
| 1532967 |
| 89 | void setLoopCount(int loopCount); | - |
| 90 | - | |
| 91 | int totalDuration() const; | - |
| 92 | virtual int duration() const {return 0;} executed 2 times by 1 test: return 0;Executed by:
| 2 |
| 93 | - | |
| 94 | inline QAbstractAnimationJob::Direction direction() const {return m_direction;} executed 84716 times by 36 tests: return m_direction;Executed by:
| 84716 |
| 95 | void setDirection(QAbstractAnimationJob::Direction direction); | - |
| 96 | - | |
| 97 | //state | - |
| 98 | inline int currentTime() const {return m_totalCurrentTime;} executed 107186 times by 28 tests: return m_totalCurrentTime;Executed by:
| 107186 |
| 99 | inline int currentLoopTime() const {return m_currentTime;} executed 10780 times by 31 tests: return m_currentTime;Executed by:
| 10780 |
| 100 | inline int currentLoop() const {return m_currentLoop;} executed 244 times by 5 tests: return m_currentLoop;Executed by:
| 244 |
| 101 | inline QAbstractAnimationJob::State state() const {return m_state;} executed 280316 times by 26 tests: return m_state;Executed by:
| 280316 |
| 102 | inline bool isRunning() { return m_state == Running; } executed 96938 times by 24 tests: return m_state == Running;Executed by:
| 96938 |
| 103 | inline bool isStopped() { return m_state == Stopped; } executed 292096 times by 29 tests: return m_state == Stopped;Executed by:
| 292096 |
| 104 | inline bool isPaused() { return m_state == Paused; } executed 35360 times by 16 tests: return m_state == Paused;Executed by:
| 35360 |
| 105 | void setDisableUserControl(); | - |
| 106 | void setEnableUserControl(); | - |
| 107 | bool userControlDisabled() const; | - |
| 108 | - | |
| 109 | void setCurrentTime(int msecs); | - |
| 110 | - | |
| 111 | void start(); | - |
| 112 | void pause(); | - |
| 113 | void resume(); | - |
| 114 | void stop(); | - |
| 115 | - | |
| 116 | enum ChangeType { | - |
| 117 | Completion = 0x01, | - |
| 118 | StateChange = 0x02, | - |
| 119 | CurrentLoop = 0x04, | - |
| 120 | CurrentTime = 0x08 | - |
| 121 | }; | - |
| 122 | Q_DECLARE_FLAGS(ChangeTypes, ChangeType) | - |
| 123 | - | |
| 124 | void addAnimationChangeListener(QAnimationJobChangeListener *listener, QAbstractAnimationJob::ChangeTypes); | - |
| 125 | void removeAnimationChangeListener(QAnimationJobChangeListener *listener, QAbstractAnimationJob::ChangeTypes); | - |
| 126 | QAbstractAnimationJob *nextSibling() const { return m_nextSibling; } executed 2154723 times by 21 tests: return m_nextSibling;Executed by:
| 2154723 |
| 127 | QAbstractAnimationJob *previousSibling() const { return m_previousSibling; } executed 78800 times by 21 tests: return m_previousSibling;Executed by:
| 78800 |
| 128 | - | |
| 129 | bool isGroup() const { return m_isGroup; } executed 26 times by 2 tests: return m_isGroup;Executed by:
| 26 |
| 130 | bool isRenderThreadJob() const { return m_isRenderThreadJob; } executed 206 times by 2 tests: return m_isRenderThreadJob;Executed by:
| 206 |
| 131 | bool isRenderThreadProxy() const { return m_isRenderThreadProxy; } executed 54 times by 3 tests: return m_isRenderThreadProxy;Executed by:
| 54 |
| 132 | - | |
| 133 | protected: | - |
| 134 | virtual void updateCurrentTime(int) {} | - |
| 135 | virtual void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState); | - |
| 136 | virtual void updateDirection(QAbstractAnimationJob::Direction direction); | - |
| 137 | virtual void topLevelAnimationLoopChanged() {} | - |
| 138 | - | |
| 139 | virtual void debugAnimation(QDebug d) const; | - |
| 140 | - | |
| 141 | void fireTopLevelAnimationLoopChanged(); | - |
| 142 | - | |
| 143 | void setState(QAbstractAnimationJob::State state); | - |
| 144 | - | |
| 145 | void finished(); | - |
| 146 | void stateChanged(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState); | - |
| 147 | void currentLoopChanged(); | - |
| 148 | void directionChanged(QAbstractAnimationJob::Direction); | - |
| 149 | void currentTimeChanged(int currentTime); | - |
| 150 | - | |
| 151 | //definition | - |
| 152 | int m_loopCount; | - |
| 153 | QAnimationGroupJob *m_group; | - |
| 154 | QAbstractAnimationJob::Direction m_direction; | - |
| 155 | - | |
| 156 | //state | - |
| 157 | QAbstractAnimationJob::State m_state; | - |
| 158 | int m_totalCurrentTime; | - |
| 159 | int m_currentTime; | - |
| 160 | int m_currentLoop; | - |
| 161 | //records the finish time for an uncontrolled animation (used by animation groups) | - |
| 162 | int m_uncontrolledFinishTime; | - |
| 163 | int m_currentLoopStartTime; // used together with m_uncontrolledFinishTime | - |
| 164 | - | |
| 165 | struct ChangeListener { | - |
| 166 | ChangeListener(QAnimationJobChangeListener *l, QAbstractAnimationJob::ChangeTypes t) : listener(l), types(t) {} executed 30445 times by 36 tests: end of blockExecuted by:
| 30445 |
| 167 | QAnimationJobChangeListener *listener; | - |
| 168 | QAbstractAnimationJob::ChangeTypes types; | - |
| 169 | bool operator==(const ChangeListener &other) const { return listener == other.listener && types == other.types; } executed 10636 times by 9 tests: return listener == other.listener && types == other.types;Executed by:
| 10636 |
| 170 | }; | - |
| 171 | std::vector<ChangeListener> changeListeners; | - |
| 172 | - | |
| 173 | QAbstractAnimationJob *m_nextSibling; | - |
| 174 | QAbstractAnimationJob *m_previousSibling; | - |
| 175 | QQmlAnimationTimer *m_timer = nullptr; | - |
| 176 | - | |
| 177 | bool *m_wasDeleted; | - |
| 178 | bool m_hasRegisteredTimer:1; | - |
| 179 | bool m_isPause:1; | - |
| 180 | bool m_isGroup:1; | - |
| 181 | bool m_disableUserControl:1; | - |
| 182 | bool m_hasCurrentTimeChangeListeners:1; | - |
| 183 | bool m_isRenderThreadJob:1; | - |
| 184 | bool m_isRenderThreadProxy:1; | - |
| 185 | - | |
| 186 | friend class QQmlAnimationTimer; | - |
| 187 | friend class QAnimationGroupJob; | - |
| 188 | friend Q_QML_PRIVATE_EXPORT QDebug operator<<(QDebug, const QAbstractAnimationJob *job); | - |
| 189 | }; | - |
| 190 | - | |
| 191 | class Q_QML_PRIVATE_EXPORT QAnimationJobChangeListener | - |
| 192 | { | - |
| 193 | public: | - |
| 194 | virtual ~QAnimationJobChangeListener(); | - |
| 195 | virtual void animationFinished(QAbstractAnimationJob *) {} | - |
| 196 | virtual void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State, QAbstractAnimationJob::State) {} | - |
| 197 | virtual void animationCurrentLoopChanged(QAbstractAnimationJob *) {} | - |
| 198 | virtual void animationCurrentTimeChanged(QAbstractAnimationJob *, int) {} | - |
| 199 | }; | - |
| 200 | - | |
| 201 | class Q_QML_PRIVATE_EXPORT QQmlAnimationTimer : public QAbstractAnimationTimer | - |
| 202 | { | - |
| 203 | Q_OBJECT | - |
| 204 | private: | - |
| 205 | QQmlAnimationTimer(); | - |
| 206 | - | |
| 207 | public: | - |
| 208 | static QQmlAnimationTimer *instance(); | - |
| 209 | static QQmlAnimationTimer *instance(bool create); | - |
| 210 | - | |
| 211 | void registerAnimation(QAbstractAnimationJob *animation, bool isTopLevel); | - |
| 212 | void unregisterAnimation(QAbstractAnimationJob *animation); | - |
| 213 | - | |
| 214 | /* | - |
| 215 | this is used for updating the currentTime of all animations in case the pause | - |
| 216 | timer is active or, otherwise, only of the animation passed as parameter. | - |
| 217 | */ | - |
| 218 | void ensureTimerUpdate(); | - |
| 219 | - | |
| 220 | /* | - |
| 221 | this will evaluate the need of restarting the pause timer in case there is still | - |
| 222 | some pause animations running. | - |
| 223 | */ | - |
| 224 | void updateAnimationTimer(); | - |
| 225 | - | |
| 226 | void restartAnimationTimer() override; | - |
| 227 | void updateAnimationsTime(qint64 timeStep) override; | - |
| 228 | - | |
| 229 | //useful for profiling/debugging | - |
| 230 | int runningAnimationCount() override { return animations.count(); } executed 6 times by 1 test: return animations.count();Executed by:
| 6 |
| 231 | - | |
| 232 | bool hasStartAnimationPending() const { return startAnimationPending; } executed 302 times by 8 tests: return startAnimationPending;Executed by:
| 302 |
| 233 | - | |
| 234 | public Q_SLOTS: | - |
| 235 | void startAnimations(); | - |
| 236 | void stopTimer(); | - |
| 237 | - | |
| 238 | private: | - |
| 239 | qint64 lastTick; | - |
| 240 | int currentAnimationIdx; | - |
| 241 | bool insideTick; | - |
| 242 | bool startAnimationPending; | - |
| 243 | bool stopTimerPending; | - |
| 244 | - | |
| 245 | QList<QAbstractAnimationJob*> animations, animationsToStart; | - |
| 246 | - | |
| 247 | // this is the count of running animations that are not a group neither a pause animation | - |
| 248 | int runningLeafAnimations; | - |
| 249 | QList<QAbstractAnimationJob*> runningPauseAnimations; | - |
| 250 | - | |
| 251 | void registerRunningAnimation(QAbstractAnimationJob *animation); | - |
| 252 | void unregisterRunningAnimation(QAbstractAnimationJob *animation); | - |
| 253 | - | |
| 254 | int closestPauseAnimationTimeToFinish(); | - |
| 255 | }; | - |
| 256 | - | |
| 257 | Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractAnimationJob::ChangeTypes) | - |
| 258 | - | |
| 259 | Q_QML_PRIVATE_EXPORT QDebug operator<<(QDebug, const QAbstractAnimationJob *job); | - |
| 260 | - | |
| 261 | QT_END_NAMESPACE | - |
| 262 | - | |
| 263 | #endif // QABSTRACTANIMATIONJOB_P_H | - |
| Source code | Switch to Preprocessed file |