OpenCoverage

qquickanimatorcontroller.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/util/qquickanimatorcontroller.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Copyright (C) 2016 Gunnar Sletta <gunnar@sletta.org>-
5** Contact: https://www.qt.io/licensing/-
6**-
7** This file is part of the QtQuick module of the Qt Toolkit.-
8**-
9** $QT_BEGIN_LICENSE:LGPL$-
10** Commercial License Usage-
11** Licensees holding valid commercial Qt licenses may use this file in-
12** accordance with the commercial license agreement provided with the-
13** Software or, alternatively, in accordance with the terms contained in-
14** a written agreement between you and The Qt Company. For licensing terms-
15** and conditions see https://www.qt.io/terms-conditions. For further-
16** information use the contact form at https://www.qt.io/contact-us.-
17**-
18** GNU Lesser General Public License Usage-
19** Alternatively, this file may be used under the terms of the GNU Lesser-
20** General Public License version 3 as published by the Free Software-
21** Foundation and appearing in the file LICENSE.LGPL3 included in the-
22** packaging of this file. Please review the following information to-
23** ensure the GNU Lesser General Public License version 3 requirements-
24** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
25**-
26** GNU General Public License Usage-
27** Alternatively, this file may be used under the terms of the GNU-
28** General Public License version 2.0 or (at your option) the GNU General-
29** Public license version 3 or any later version approved by the KDE Free-
30** Qt Foundation. The licenses are as published by the Free Software-
31** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
32** included in the packaging of this file. Please review the following-
33** information to ensure the GNU General Public License requirements will-
34** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
35** https://www.gnu.org/licenses/gpl-3.0.html.-
36**-
37** $QT_END_LICENSE$-
38**-
39****************************************************************************/-
40-
41#include "qquickanimatorcontroller_p.h"-
42-
43#include <private/qquickwindow_p.h>-
44#include <private/qsgrenderloop_p.h>-
45-
46#include <private/qanimationgroupjob_p.h>-
47-
48#include <QtGui/qscreen.h>-
49-
50#include <QtCore/qcoreapplication.h>-
51-
52QT_BEGIN_NAMESPACE-
53-
54QQuickAnimatorController::~QQuickAnimatorController()-
55{-
56}-
57-
58QQuickAnimatorController::QQuickAnimatorController(QQuickWindow *window)-
59 : m_window(window)-
60{-
61}
executed 5366 times by 90 tests: end of block
Executed by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qqmlcomponent
  • tst_qqmldebugjs
  • tst_qqmlimport
  • tst_qqmltypeloader
  • tst_qquickaccessible
  • tst_qquickage
  • tst_qquickanchors
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickapplication
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdesignersupport
  • tst_qquickdrag
  • tst_qquickdraghandler
  • tst_qquickdroparea
  • ...
5366
62-
63static void qquickanimator_invalidate_jobs(QAbstractAnimationJob *job)-
64{-
65 if (job->isRenderThreadJob()) {
job->isRenderThreadJob()Description
TRUEevaluated 44 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
FALSEevaluated 14 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
14-44
66 static_cast<QQuickAnimatorJob *>(job)->invalidate();-
67 } else if (job->isGroup()) {
executed 44 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
job->isGroup()Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_examples
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickanimations
2-44
68 QAnimationGroupJob *g = static_cast<QAnimationGroupJob *>(job);-
69 for (QAbstractAnimationJob *a = g->firstChild(); a; a = a->nextSibling())
aDescription
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_examples
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_examples
12-24
70 qquickanimator_invalidate_jobs(a);
executed 24 times by 1 test: qquickanimator_invalidate_jobs(a);
Executed by:
  • tst_examples
24
71 }
executed 12 times by 1 test: end of block
Executed by:
  • tst_examples
12
72}
executed 58 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
58
73-
74void QQuickAnimatorController::windowNodesDestroyed()-
75{-
76 for (const QSharedPointer<QAbstractAnimationJob> &toStop : qAsConst(m_rootsPendingStop)) {-
77 qquickanimator_invalidate_jobs(toStop.data());-
78 toStop->stop();-
79 }
executed 4 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
4
80 m_rootsPendingStop.clear();-
81-
82 // Clear animation roots and iterate over a temporary to avoid that job->stop()-
83 // modifies the m_animationRoots and messes with our iteration-
84 const auto roots = m_animationRoots;-
85 m_animationRoots.clear();-
86 for (const QSharedPointer<QAbstractAnimationJob> &job : roots) {-
87 qquickanimator_invalidate_jobs(job.data());-
88-
89 // Stop it and add it to the list of pending start so it might get-
90 // started later on.-
91 job->stop();-
92 m_rootsPendingStart.insert(job);-
93 }
executed 30 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
30
94}
executed 5362 times by 90 tests: end of block
Executed by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qqmlcomponent
  • tst_qqmldebugjs
  • tst_qqmlimport
  • tst_qqmltypeloader
  • tst_qquickaccessible
  • tst_qquickage
  • tst_qquickanchors
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickapplication
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdesignersupport
  • tst_qquickdrag
  • tst_qquickdraghandler
  • tst_qquickdroparea
  • ...
5362
95-
96void QQuickAnimatorController::advance()-
97{-
98 bool running = false;-
99 for (const QSharedPointer<QAbstractAnimationJob> &job : qAsConst(m_animationRoots)) {-
100 if (job->isRunning()) {
job->isRunning()Description
TRUEevaluated 855 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
FALSEnever evaluated
0-855
101 running = true;-
102 break;
executed 855 times by 2 tests: break;
Executed by:
  • tst_examples
  • tst_qquickanimations
855
103 }-
104 }
never executed: end of block
0
105-
106 for (QQuickAnimatorJob *job : qAsConst(m_runningAnimators))-
107 job->commit();
executed 881 times by 2 tests: job->commit();
Executed by:
  • tst_examples
  • tst_qquickanimations
881
108-
109 if (running)
runningDescription
TRUEevaluated 855 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
FALSEevaluated 49768 times by 75 tests
Evaluated by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qqmlcomponent
  • tst_qqmltypeloader
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdraghandler
  • tst_qquickellipseextruder
  • tst_qquickflickable
  • tst_qquickfocusscope
  • tst_qquickfontloader
  • tst_qquickfontloader_static
  • tst_qquickframebufferobject
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgridview
  • ...
855-49768
110 m_window->update();
executed 855 times by 2 tests: m_window->update();
Executed by:
  • tst_examples
  • tst_qquickanimations
855
111}
executed 50623 times by 76 tests: end of block
Executed by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qqmlcomponent
  • tst_qqmltypeloader
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdraghandler
  • tst_qquickellipseextruder
  • tst_qquickflickable
  • tst_qquickfocusscope
  • tst_qquickfontloader
  • tst_qquickfontloader_static
  • tst_qquickframebufferobject
  • tst_qquickfriction
  • tst_qquickgravity
  • ...
50623
112-
113static void qquickanimator_sync_before_start(QAbstractAnimationJob *job)-
114{-
115 if (job->isRenderThreadJob()) {
job->isRenderThreadJob()Description
TRUEevaluated 36 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_examples
6-36
116 static_cast<QQuickAnimatorJob *>(job)->preSync();-
117 } else if (job->isGroup()) {
executed 36 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
job->isGroup()Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_examples
FALSEnever evaluated
0-36
118 QAnimationGroupJob *g = static_cast<QAnimationGroupJob *>(job);-
119 for (QAbstractAnimationJob *a = g->firstChild(); a; a = a->nextSibling())
aDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_examples
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_examples
6-12
120 qquickanimator_sync_before_start(a);
executed 12 times by 1 test: qquickanimator_sync_before_start(a);
Executed by:
  • tst_examples
12
121 }
executed 6 times by 1 test: end of block
Executed by:
  • tst_examples
6
122}
executed 42 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
42
123-
124void QQuickAnimatorController::beforeNodeSync()-
125{-
126 for (const QSharedPointer<QAbstractAnimationJob> &toStop : qAsConst(m_rootsPendingStop)) {-
127 toStop->stop();-
128 m_animationRoots.remove(toStop.data());-
129 }
never executed: end of block
0
130 m_rootsPendingStop.clear();-
131-
132-
133 for (QQuickAnimatorJob *job : qAsConst(m_runningAnimators))-
134 job->preSync();
executed 849 times by 1 test: job->preSync();
Executed by:
  • tst_qquickanimations
849
135-
136 // Start pending jobs-
137 for (const QSharedPointer<QAbstractAnimationJob> &job : qAsConst(m_rootsPendingStart)) {-
138 Q_ASSERT(!job->isRunning());-
139-
140 // We want to make sure that presync is called before-
141 // updateAnimationTime is called the very first time, so before-
142 // starting a tree of jobs, we go through it and call preSync on all-
143 // its animators.-
144 qquickanimator_sync_before_start(job.data());-
145-
146 // The start the job..-
147 job->start();-
148 m_animationRoots.insert(job.data(), job);-
149 }
executed 30 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
30
150 m_rootsPendingStart.clear();-
151-
152 // Issue an update directly on the window to force another render pass.-
153 if (m_animationRoots.size())
m_animationRoots.size()Description
TRUEevaluated 855 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
FALSEevaluated 49764 times by 75 tests
Evaluated by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qqmlcomponent
  • tst_qqmltypeloader
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdraghandler
  • tst_qquickellipseextruder
  • tst_qquickflickable
  • tst_qquickfocusscope
  • tst_qquickfontloader
  • tst_qquickfontloader_static
  • tst_qquickframebufferobject
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgridview
  • ...
855-49764
154 m_window->update();
executed 855 times by 2 tests: m_window->update();
Executed by:
  • tst_examples
  • tst_qquickanimations
855
155}
executed 50619 times by 76 tests: end of block
Executed by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qqmlcomponent
  • tst_qqmltypeloader
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdraghandler
  • tst_qquickellipseextruder
  • tst_qquickflickable
  • tst_qquickfocusscope
  • tst_qquickfontloader
  • tst_qquickfontloader_static
  • tst_qquickframebufferobject
  • tst_qquickfriction
  • tst_qquickgravity
  • ...
50619
156-
157void QQuickAnimatorController::afterNodeSync()-
158{-
159 for (QQuickAnimatorJob *job : qAsConst(m_runningAnimators))-
160 job->postSync();
executed 881 times by 2 tests: job->postSync();
Executed by:
  • tst_examples
  • tst_qquickanimations
881
161}
executed 50619 times by 76 tests: end of block
Executed by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qqmlcomponent
  • tst_qqmltypeloader
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdraghandler
  • tst_qquickellipseextruder
  • tst_qquickflickable
  • tst_qquickfocusscope
  • tst_qquickfontloader
  • tst_qquickfontloader_static
  • tst_qquickframebufferobject
  • tst_qquickfriction
  • tst_qquickgravity
  • ...
50619
162-
163void QQuickAnimatorController::animationFinished(QAbstractAnimationJob *job)-
164{-
165 m_animationRoots.remove(job);-
166}
never executed: end of block
0
167-
168void QQuickAnimatorController::animationStateChanged(QAbstractAnimationJob *job,-
169 QAbstractAnimationJob::State newState,-
170 QAbstractAnimationJob::State oldState)-
171{-
172 Q_ASSERT(job->isRenderThreadJob());-
173 QQuickAnimatorJob *animator = static_cast<QQuickAnimatorJob *>(job);-
174 if (newState == QAbstractAnimationJob::Running) {
newState == QA...onJob::RunningDescription
TRUEevaluated 32 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
FALSEevaluated 32 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
32
175 m_runningAnimators.insert(animator);-
176 } else if (oldState == QAbstractAnimationJob::Running) {
executed 32 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
oldState == QA...onJob::RunningDescription
TRUEevaluated 32 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
FALSEnever evaluated
0-32
177 animator->commit();-
178 m_runningAnimators.remove(animator);-
179 }
executed 32 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
32
180}
executed 64 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
64
181-
182-
183void QQuickAnimatorController::requestSync()-
184{-
185 // Force a "sync" pass as the newly started animation needs to sync properties from GUI.-
186 m_window->maybeUpdate();-
187}
executed 30 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
30
188-
189// All this is being executed on the GUI thread while the animator controller-
190// is locked.-
191void QQuickAnimatorController::start_helper(QAbstractAnimationJob *job)-
192{-
193 if (job->isRenderThreadJob()) {
job->isRenderThreadJob()Description
TRUEevaluated 36 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_examples
6-36
194 QQuickAnimatorJob *j = static_cast<QQuickAnimatorJob *>(job);-
195 j->addAnimationChangeListener(this, QAbstractAnimationJob::StateChange);-
196 j->initialize(this);-
197 } else if (job->isGroup()) {
executed 36 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
job->isGroup()Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_examples
FALSEnever evaluated
0-36
198 QAnimationGroupJob *g = static_cast<QAnimationGroupJob *>(job);-
199 for (QAbstractAnimationJob *a = g->firstChild(); a; a = a->nextSibling())
aDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_examples
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_examples
6-12
200 start_helper(a);
executed 12 times by 1 test: start_helper(a);
Executed by:
  • tst_examples
12
201 }
executed 6 times by 1 test: end of block
Executed by:
  • tst_examples
6
202}
executed 42 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
42
203-
204// Called by the proxy when it is time to kick off an animation job-
205void QQuickAnimatorController::start(const QSharedPointer<QAbstractAnimationJob> &job)-
206{-
207 m_rootsPendingStart.insert(job);-
208 m_rootsPendingStop.remove(job);-
209 job->addAnimationChangeListener(this, QAbstractAnimationJob::Completion);-
210 start_helper(job.data());-
211 requestSync();-
212}
executed 30 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
30
213-
214-
215// Called by the proxy when it is time to stop an animation job.-
216void QQuickAnimatorController::cancel(const QSharedPointer<QAbstractAnimationJob> &job)-
217{-
218 m_rootsPendingStart.remove(job);-
219 m_rootsPendingStop.insert(job);-
220}
executed 4 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
4
221-
222-
223QT_END_NAMESPACE-
224-
225#include "moc_qquickanimatorcontroller_p.cpp"-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0