OpenCoverage

qquickanimatorjob.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/util/qquickanimatorjob.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#include "qquickanimatorjob_p.h"-
43#include "qquickanimator_p.h"-
44#include "qquickanimator_p_p.h"-
45#include <private/qquickwindow_p.h>-
46#include <private/qquickitem_p.h>-
47#if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl)-
48# include <private/qquickopenglshadereffectnode_p.h>-
49# include <private/qquickopenglshadereffect_p.h>-
50# include <private/qquickshadereffect_p.h>-
51#endif-
52#include <private/qanimationgroupjob_p.h>-
53-
54#include <qcoreapplication.h>-
55#include <qdebug.h>-
56-
57QT_BEGIN_NAMESPACE-
58-
59struct QQuickTransformAnimatorHelperStore-
60{-
61 QHash<QQuickItem *, QQuickTransformAnimatorJob::Helper *> store;-
62 QMutex mutex;-
63-
64 QQuickTransformAnimatorJob::Helper *acquire(QQuickItem *item) {-
65 mutex.lock();-
66 QQuickTransformAnimatorJob::Helper *helper = store.value(item);-
67 if (!helper) {
!helperDescription
TRUEevaluated 22 times by 1 test
Evaluated by:
  • tst_examples
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_examples
4-22
68 helper = new QQuickTransformAnimatorJob::Helper();-
69 helper->item = item;-
70 store[item] = helper;-
71 } else {
executed 22 times by 1 test: end of block
Executed by:
  • tst_examples
22
72 ++helper->ref;-
73 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_examples
4
74 mutex.unlock();-
75 return helper;
executed 26 times by 1 test: return helper;
Executed by:
  • tst_examples
26
76 }-
77-
78 void release(QQuickTransformAnimatorJob::Helper *helper) {-
79 mutex.lock();-
80 if (--helper->ref == 0) {
--helper->ref == 0Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • tst_examples
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_examples
4-22
81 store.remove(helper->item);-
82 delete helper;-
83 }
executed 22 times by 1 test: end of block
Executed by:
  • tst_examples
22
84 mutex.unlock();-
85 }
executed 26 times by 1 test: end of block
Executed by:
  • tst_examples
26
86};-
87Q_GLOBAL_STATIC(QQuickTransformAnimatorHelperStore, qquick_transform_animatorjob_helper_store);
executed 2 times by 1 test: end of block
Executed by:
  • tst_examples
executed 2 times by 1 test: guard.store(QtGlobalStatic::Destroyed);
Executed by:
  • tst_examples
executed 52 times by 1 test: return &holder.value;
Executed by:
  • tst_examples
guard.load() =...c::InitializedDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_examples
FALSEnever evaluated
0-52
88-
89QQuickAnimatorProxyJob::QQuickAnimatorProxyJob(QAbstractAnimationJob *job, QObject *item)-
90 : m_controller(nullptr)-
91 , m_internalState(State_Stopped)-
92{-
93 m_job.reset(job);-
94-
95 m_isRenderThreadProxy = true;-
96 m_animation = qobject_cast<QQuickAbstractAnimation *>(item);-
97-
98 setLoopCount(job->loopCount());-
99-
100 // Instead of setting duration to job->duration() we need to set it to -1 so that-
101 // it runs as long as the job is running on the render thread. If we gave it-
102 // an explicit duration, it would be stopped, potentially stopping the RT animation-
103 // prematurely.-
104 // This means that the animation driver will tick on the GUI thread as long-
105 // as the animation is running on the render thread, but this overhead will-
106 // be negligiblie compared to animating and re-rendering the scene on the render thread.-
107 m_duration = -1;-
108-
109 QObject *ctx = findAnimationContext(m_animation);-
110 if (!ctx) {
!ctxDescription
TRUEnever evaluated
FALSEevaluated 32 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
0-32
111 qWarning("QtQuick: unable to find animation context for RT animation...");-
112 return;
never executed: return;
0
113 }-
114-
115 QQuickWindow *window = qobject_cast<QQuickWindow *>(ctx);-
116 if (window) {
windowDescription
TRUEnever evaluated
FALSEevaluated 32 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
0-32
117 setWindow(window);-
118 } else {
never executed: end of block
0
119 QQuickItem *item = qobject_cast<QQuickItem *>(ctx);-
120 if (item->window())
item->window()Description
TRUEevaluated 32 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
FALSEnever evaluated
0-32
121 setWindow(item->window());
executed 32 times by 2 tests: setWindow(item->window());
Executed by:
  • tst_examples
  • tst_qquickanimations
32
122 connect(item, &QQuickItem::windowChanged, this, &QQuickAnimatorProxyJob::windowChanged);-
123 }
executed 32 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
32
124}-
125-
126QQuickAnimatorProxyJob::~QQuickAnimatorProxyJob()-
127{-
128 if (m_job && m_controller)
m_jobDescription
TRUEevaluated 32 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
FALSEnever evaluated
0-32
129 m_controller->cancel(m_job);
never executed: m_controller->cancel(m_job);
0
130 m_job.reset();-
131}
executed 32 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
32
132-
133QObject *QQuickAnimatorProxyJob::findAnimationContext(QQuickAbstractAnimation *a)-
134{-
135 QObject *p = a->parent();-
136 while (p != nullptr && qobject_cast<QQuickWindow *>(p) == nullptr && qobject_cast<QQuickItem *>(p) == nullptr)
p != nullptrDescription
TRUEevaluated 32 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
FALSEnever evaluated
qobject_cast<Q...(p) == nullptrDescription
TRUEevaluated 32 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
FALSEnever evaluated
qobject_cast<Q...(p) == nullptrDescription
TRUEnever evaluated
FALSEevaluated 32 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
0-32
137 p = p->parent();
never executed: p = p->parent();
0
138 return p;
executed 32 times by 2 tests: return p;
Executed by:
  • tst_examples
  • tst_qquickanimations
32
139}-
140-
141void QQuickAnimatorProxyJob::updateCurrentTime(int)-
142{-
143 if (m_internalState != State_Running)
m_internalStat... State_RunningDescription
TRUEnever evaluated
FALSEevaluated 653 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
0-653
144 return;
never executed: return;
0
145-
146 // A proxy which is being ticked should be associated with a window, (see-
147 // setWindow() below). If we get here when there is no more controller we-
148 // have a problem.-
149 Q_ASSERT(m_controller);-
150-
151 // We do a simple check here to see if the animator has run and stopped on-
152 // the render thread. isPendingStart() will perform a check against jobs-
153 // that have been scheduled for start, but that will not yet have entered-
154 // the actual running state.-
155 // Secondly, we make an unprotected read of the job's state to figure out-
156 // if it is running, but this is ok, since we're only reading the state-
157 // and if the render thread should happen to be writing it concurrently,-
158 // we might get the wrong value for this update, but then we'll simply-
159 // pick it up on the next iterationm when the job is stopped and render-
160 // thread is no longer using it.-
161 if (!m_controller->isPendingStart(m_job)
!m_controller-...ngStart(m_job)Description
TRUEevaluated 622 times by 1 test
Evaluated by:
  • tst_qquickanimations
FALSEevaluated 31 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
31-622
162 && !m_job->isRunning()) {
!m_job->isRunning()Description
TRUEnever evaluated
FALSEevaluated 622 times by 1 test
Evaluated by:
  • tst_qquickanimations
0-622
163 stop();-
164 }
never executed: end of block
0
165}
executed 653 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
653
166-
167void QQuickAnimatorProxyJob::updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State)-
168{-
169 if (m_state == Running) {
m_state == RunningDescription
TRUEevaluated 30 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
FALSEevaluated 30 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
30
170 m_internalState = State_Starting;-
171 if (m_controller) {
m_controllerDescription
TRUEevaluated 30 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
FALSEnever evaluated
0-30
172 m_internalState = State_Running;-
173 m_controller->start(m_job);-
174 }
executed 30 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
30
175-
176 } else if (newState == Stopped) {
executed 30 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
newState == StoppedDescription
TRUEevaluated 30 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
FALSEnever evaluated
0-30
177 m_internalState = State_Stopped;-
178 if (m_controller) {
m_controllerDescription
TRUEnever evaluated
FALSEevaluated 30 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
0-30
179 syncBackCurrentValues();-
180 m_controller->cancel(m_job);-
181 }
never executed: end of block
0
182 }
executed 30 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
30
183}
executed 60 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
60
184-
185void QQuickAnimatorProxyJob::debugAnimation(QDebug d) const-
186{-
187 d << "QuickAnimatorProxyJob("<< hex << (const void *) this << dec-
188 << "state:" << state() << "duration:" << duration()-
189 << "proxying: (" << job() << ')';-
190}
never executed: end of block
0
191-
192void QQuickAnimatorProxyJob::windowChanged(QQuickWindow *window)-
193{-
194 setWindow(window);-
195}
executed 32 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
32
196-
197void QQuickAnimatorProxyJob::setWindow(QQuickWindow *window)-
198{-
199 if (!window) {
!windowDescription
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
200 if (m_job && m_controller) {
m_jobDescription
TRUEevaluated 32 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
FALSEnever evaluated
0-32
201 disconnect(m_controller->window(), &QQuickWindow::sceneGraphInitialized,-
202 this, &QQuickAnimatorProxyJob::sceneGraphInitialized);-
203 m_controller->cancel(m_job);-
204 }
executed 4 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
4
205-
206 m_controller = nullptr;-
207 stop();-
208-
209 } else if (!m_controller && m_job) {
executed 32 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
!m_controllerDescription
TRUEevaluated 32 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
FALSEnever evaluated
m_jobDescription
TRUEevaluated 32 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
FALSEnever evaluated
0-32
210 m_controller = QQuickWindowPrivate::get(window)->animationController;-
211 if (window->isSceneGraphInitialized())
window->isScen...hInitialized()Description
TRUEevaluated 28 times by 1 test
Evaluated by:
  • tst_examples
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickanimations
4-28
212 readyToAnimate();
executed 28 times by 1 test: readyToAnimate();
Executed by:
  • tst_examples
28
213 else-
214 connect(window, &QQuickWindow::sceneGraphInitialized, this, &QQuickAnimatorProxyJob::sceneGraphInitialized);
executed 4 times by 1 test: connect(window, &QQuickWindow::sceneGraphInitialized, this, &QQuickAnimatorProxyJob::sceneGraphInitialized);
Executed by:
  • tst_qquickanimations
4
215 }-
216}
executed 64 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
64
217-
218void QQuickAnimatorProxyJob::sceneGraphInitialized()-
219{-
220 disconnect(m_controller->window(), &QQuickWindow::sceneGraphInitialized, this, &QQuickAnimatorProxyJob::sceneGraphInitialized);-
221 readyToAnimate();-
222}
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickanimations
2
223-
224void QQuickAnimatorProxyJob::readyToAnimate()-
225{-
226 Q_ASSERT(m_controller);-
227 if (m_internalState == State_Starting) {
m_internalStat...State_StartingDescription
TRUEnever evaluated
FALSEevaluated 30 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
0-30
228 m_internalState = State_Running;-
229 m_controller->start(m_job);-
230 }
never executed: end of block
0
231}
executed 30 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
30
232-
233static void qquick_syncback_helper(QAbstractAnimationJob *job)-
234{-
235 if (job->isRenderThreadJob()) {
job->isRenderThreadJob()Description
TRUEnever evaluated
FALSEnever evaluated
0
236 static_cast<QQuickAnimatorJob *>(job)->writeBack();-
237-
238 } else if (job->isGroup()) {
never executed: end of block
job->isGroup()Description
TRUEnever evaluated
FALSEnever evaluated
0
239 QAnimationGroupJob *g = static_cast<QAnimationGroupJob *>(job);-
240 for (QAbstractAnimationJob *a = g->firstChild(); a; a = a->nextSibling())
aDescription
TRUEnever evaluated
FALSEnever evaluated
0
241 qquick_syncback_helper(a);
never executed: qquick_syncback_helper(a);
0
242 }
never executed: end of block
0
243-
244}
never executed: end of block
0
245-
246void QQuickAnimatorProxyJob::syncBackCurrentValues()-
247{-
248 if (m_job)
m_jobDescription
TRUEnever evaluated
FALSEnever evaluated
0
249 qquick_syncback_helper(m_job.data());
never executed: qquick_syncback_helper(m_job.data());
0
250}
never executed: end of block
0
251-
252QQuickAnimatorJob::QQuickAnimatorJob()-
253 : m_target(nullptr)-
254 , m_controller(nullptr)-
255 , m_from(0)-
256 , m_to(0)-
257 , m_value(0)-
258 , m_duration(0)-
259 , m_isTransform(false)-
260 , m_isUniform(false)-
261{-
262 m_isRenderThreadJob = true;-
263}
executed 36 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
36
264-
265void QQuickAnimatorJob::debugAnimation(QDebug d) const-
266{-
267 d << "QuickAnimatorJob(" << hex << (const void *) this << dec-
268 << ") state:" << state() << "duration:" << duration()-
269 << "target:" << m_target << "value:" << m_value;-
270}
never executed: end of block
0
271-
272qreal QQuickAnimatorJob::progress(int time) const-
273{-
274 return m_easing.valueForProgress((m_duration == 0) ? qreal(1) : qreal(time) / qreal(m_duration));
executed 22 times by 1 test: return m_easing.valueForProgress((m_duration == 0) ? qreal(1) : qreal(time) / qreal(m_duration));
Executed by:
  • tst_examples
22
275}-
276-
277qreal QQuickAnimatorJob::value() const-
278{-
279 qreal value = m_to;-
280 if (m_controller) {
m_controllerDescription
TRUEnever evaluated
FALSEnever evaluated
0
281 m_controller->lock();-
282 value = m_value;-
283 m_controller->unlock();-
284 }
never executed: end of block
0
285 return value;
never executed: return value;
0
286}-
287-
288void QQuickAnimatorJob::setTarget(QQuickItem *target)-
289{-
290 m_target = target;-
291}
executed 42 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
42
292-
293void QQuickAnimatorJob::initialize(QQuickAnimatorController *controller)-
294{-
295 m_controller = controller;-
296}
executed 36 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
36
297-
298QQuickTransformAnimatorJob::QQuickTransformAnimatorJob()-
299 : m_helper(nullptr)-
300{-
301 m_isTransform = true;-
302}
executed 26 times by 1 test: end of block
Executed by:
  • tst_examples
26
303-
304QQuickTransformAnimatorJob::~QQuickTransformAnimatorJob()-
305{-
306 if (m_helper)
m_helperDescription
TRUEevaluated 26 times by 1 test
Evaluated by:
  • tst_examples
FALSEnever evaluated
0-26
307 qquick_transform_animatorjob_helper_store()->release(m_helper);
executed 26 times by 1 test: qquick_transform_animatorjob_helper_store()->release(m_helper);
Executed by:
  • tst_examples
26
308}
executed 26 times by 1 test: end of block
Executed by:
  • tst_examples
26
309-
310void QQuickTransformAnimatorJob::setTarget(QQuickItem *item)-
311{-
312 // In the extremely unlikely event that the target of an animator has been-
313 // changed into a new item that sits in the exact same pointer address, we-
314 // want to force syncing it again.-
315 if (m_helper && m_target)
m_helperDescription
TRUEnever evaluated
FALSEevaluated 34 times by 1 test
Evaluated by:
  • tst_examples
m_targetDescription
TRUEnever evaluated
FALSEnever evaluated
0-34
316 m_helper->wasSynced = false;
never executed: m_helper->wasSynced = false;
0
317 QQuickAnimatorJob::setTarget(item);-
318}
executed 34 times by 1 test: end of block
Executed by:
  • tst_examples
34
319-
320void QQuickTransformAnimatorJob::preSync()-
321{-
322 // If the target has changed or become null, release and reset the helper-
323 if (m_helper && (m_helper->item != m_target || !m_target)) {
m_helperDescription
TRUEnever evaluated
FALSEevaluated 26 times by 1 test
Evaluated by:
  • tst_examples
m_helper->item != m_targetDescription
TRUEnever evaluated
FALSEnever evaluated
!m_targetDescription
TRUEnever evaluated
FALSEnever evaluated
0-26
324 qquick_transform_animatorjob_helper_store()->release(m_helper);-
325 m_helper = nullptr;-
326 }
never executed: end of block
0
327-
328 if (!m_target) {
!m_targetDescription
TRUEnever evaluated
FALSEevaluated 26 times by 1 test
Evaluated by:
  • tst_examples
0-26
329 invalidate();-
330 return;
never executed: return;
0
331 }-
332-
333 if (!m_helper) {
!m_helperDescription
TRUEevaluated 26 times by 1 test
Evaluated by:
  • tst_examples
FALSEnever evaluated
0-26
334 m_helper = qquick_transform_animatorjob_helper_store()->acquire(m_target);-
335-
336 // This is a bit superfluous, but it ends up being simpler than the-
337 // alternative. When an item happens to land on the same address as a-
338 // previous item, that helper might not have been fully cleaned up by-
339 // the time it gets taken back into use. As an alternative to storing-
340 // connections to each and every item's QObject::destroyed() and-
341 // having to clean those up afterwards, we simply sync all helpers on-
342 // the first run. The sync is only done once for the run of an-
343 // animation and it is a fairly light function (compared to storing-
344 // potentially thousands of connections and managing their lifetime.-
345 m_helper->wasSynced = false;-
346 }
executed 26 times by 1 test: end of block
Executed by:
  • tst_examples
26
347-
348 m_helper->sync();-
349}
executed 26 times by 1 test: end of block
Executed by:
  • tst_examples
26
350-
351void QQuickTransformAnimatorJob::invalidate()-
352{-
353 if (m_helper)
m_helperDescription
TRUEevaluated 34 times by 1 test
Evaluated by:
  • tst_examples
FALSEnever evaluated
0-34
354 m_helper->node = nullptr;
executed 34 times by 1 test: m_helper->node = nullptr;
Executed by:
  • tst_examples
34
355}
executed 34 times by 1 test: end of block
Executed by:
  • tst_examples
34
356-
357void QQuickTransformAnimatorJob::Helper::sync()-
358{-
359 const quint32 mask = QQuickItemPrivate::Position-
360 | QQuickItemPrivate::BasicTransform-
361 | QQuickItemPrivate::TransformOrigin-
362 | QQuickItemPrivate::Size;-
363-
364 QQuickItemPrivate *d = QQuickItemPrivate::get(item);-
365#if QT_CONFIG(quick_shadereffect)-
366 if (d->extra.isAllocated()
d->extra.isAllocated()Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_examples
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_examples
10-16
367 && d->extra->layer
d->extra->layerDescription
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_examples
0-10
368 && d->extra->layer->enabled()) {
d->extra->layer->enabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
369 d = QQuickItemPrivate::get(d->extra->layer->m_effectSource);-
370 }
never executed: end of block
0
371#endif-
372-
373 quint32 dirty = mask & d->dirtyAttributes;-
374-
375 if (!wasSynced) {
!wasSyncedDescription
TRUEevaluated 26 times by 1 test
Evaluated by:
  • tst_examples
FALSEnever evaluated
0-26
376 dirty = 0xffffffffu;-
377 wasSynced = true;-
378 }
executed 26 times by 1 test: end of block
Executed by:
  • tst_examples
26
379-
380 if (dirty == 0)
dirty == 0Description
TRUEnever evaluated
FALSEevaluated 26 times by 1 test
Evaluated by:
  • tst_examples
0-26
381 return;
never executed: return;
0
382-
383 node = d->itemNode();-
384-
385 if (dirty & QQuickItemPrivate::Position) {
dirty & QQuick...vate::PositionDescription
TRUEevaluated 26 times by 1 test
Evaluated by:
  • tst_examples
FALSEnever evaluated
0-26
386 dx = item->x();-
387 dy = item->y();-
388 }
executed 26 times by 1 test: end of block
Executed by:
  • tst_examples
26
389-
390 if (dirty & QQuickItemPrivate::BasicTransform) {
dirty & QQuick...BasicTransformDescription
TRUEevaluated 26 times by 1 test
Evaluated by:
  • tst_examples
FALSEnever evaluated
0-26
391 scale = item->scale();-
392 rotation = item->rotation();-
393 }
executed 26 times by 1 test: end of block
Executed by:
  • tst_examples
26
394-
395 if (dirty & (QQuickItemPrivate::TransformOrigin | QQuickItemPrivate::Size)) {
dirty & (QQuic...Private::Size)Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • tst_examples
FALSEnever evaluated
0-26
396 QPointF o = item->transformOriginPoint();-
397 ox = o.x();-
398 oy = o.y();-
399 }
executed 26 times by 1 test: end of block
Executed by:
  • tst_examples
26
400}
executed 26 times by 1 test: end of block
Executed by:
  • tst_examples
26
401-
402void QQuickTransformAnimatorJob::Helper::commit()-
403{-
404 if (!wasChanged || !node)
!wasChangedDescription
TRUEevaluated 22 times by 1 test
Evaluated by:
  • tst_examples
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_examples
!nodeDescription
TRUEnever evaluated
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_examples
0-22
405 return;
executed 22 times by 1 test: return;
Executed by:
  • tst_examples
22
406-
407 QMatrix4x4 m;-
408 m.translate(dx, dy);-
409 m.translate(ox, oy);-
410 m.scale(scale);-
411 m.rotate(rotation, 0, 0, 1);-
412 m.translate(-ox, -oy);-
413 node->setMatrix(m);-
414-
415 wasChanged = false;-
416}
executed 22 times by 1 test: end of block
Executed by:
  • tst_examples
22
417-
418void QQuickTransformAnimatorJob::commit()-
419{-
420 if (m_helper)
m_helperDescription
TRUEevaluated 44 times by 1 test
Evaluated by:
  • tst_examples
FALSEnever evaluated
0-44
421 m_helper->commit();
executed 44 times by 1 test: m_helper->commit();
Executed by:
  • tst_examples
44
422}
executed 44 times by 1 test: end of block
Executed by:
  • tst_examples
44
423-
424void QQuickXAnimatorJob::writeBack()-
425{-
426 if (m_target)
m_targetDescription
TRUEnever evaluated
FALSEnever evaluated
0
427 m_target->setX(value());
never executed: m_target->setX(value());
0
428}
never executed: end of block
0
429-
430void QQuickXAnimatorJob::updateCurrentTime(int time)-
431{-
432#if QT_CONFIG(opengl)-
433 Q_ASSERT(!m_controller || !m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread());-
434#endif-
435 if (!m_helper)
!m_helperDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_examples
0-4
436 return;
never executed: return;
0
437-
438 m_value = m_from + (m_to - m_from) * progress(time);-
439 m_helper->dx = m_value;-
440 m_helper->wasChanged = true;-
441}
executed 4 times by 1 test: end of block
Executed by:
  • tst_examples
4
442-
443void QQuickYAnimatorJob::writeBack()-
444{-
445 if (m_target)
m_targetDescription
TRUEnever evaluated
FALSEnever evaluated
0
446 m_target->setY(value());
never executed: m_target->setY(value());
0
447}
never executed: end of block
0
448-
449void QQuickYAnimatorJob::updateCurrentTime(int time)-
450{-
451#if QT_CONFIG(opengl)-
452 Q_ASSERT(!m_controller || !m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread());-
453#endif-
454 if (!m_helper)
!m_helperDescription
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_examples
0-6
455 return;
never executed: return;
0
456-
457 m_value = m_from + (m_to - m_from) * progress(time);-
458 m_helper->dy = m_value;-
459 m_helper->wasChanged = true;-
460}
executed 6 times by 1 test: end of block
Executed by:
  • tst_examples
6
461-
462void QQuickScaleAnimatorJob::writeBack()-
463{-
464 if (m_target)
m_targetDescription
TRUEnever evaluated
FALSEnever evaluated
0
465 m_target->setScale(value());
never executed: m_target->setScale(value());
0
466}
never executed: end of block
0
467-
468void QQuickScaleAnimatorJob::updateCurrentTime(int time)-
469{-
470#if QT_CONFIG(opengl)-
471 Q_ASSERT(!m_controller || !m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread());-
472#endif-
473 if (!m_helper)
!m_helperDescription
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_examples
0-8
474 return;
never executed: return;
0
475-
476 m_value = m_from + (m_to - m_from) * progress(time);-
477 m_helper->scale = m_value;-
478 m_helper->wasChanged = true;-
479}
executed 8 times by 1 test: end of block
Executed by:
  • tst_examples
8
480-
481-
482QQuickRotationAnimatorJob::QQuickRotationAnimatorJob()-
483 : m_direction(QQuickRotationAnimator::Numerical)-
484{-
485}
executed 4 times by 1 test: end of block
Executed by:
  • tst_examples
4
486-
487extern QVariant _q_interpolateShortestRotation(qreal &f, qreal &t, qreal progress);-
488extern QVariant _q_interpolateClockwiseRotation(qreal &f, qreal &t, qreal progress);-
489extern QVariant _q_interpolateCounterclockwiseRotation(qreal &f, qreal &t, qreal progress);-
490-
491void QQuickRotationAnimatorJob::updateCurrentTime(int time)-
492{-
493#if QT_CONFIG(opengl)-
494 Q_ASSERT(!m_controller || !m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread());-
495#endif-
496 if (!m_helper)
!m_helperDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_examples
0-4
497 return;
never executed: return;
0
498-
499 float t = progress(time);-
500-
501 switch (m_direction) {-
502 case QQuickRotationAnimator::Clockwise:
never executed: case QQuickRotationAnimator::Clockwise:
0
503 m_value = _q_interpolateClockwiseRotation(m_from, m_to, t).toFloat();-
504 // The logic in _q_interpolateClockwise comes out a bit wrong-
505 // for the case of X->0 where 0<X<360. It ends on 360 which it-
506 // shouldn't.-
507 if (t == 1)
t == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
508 m_value = m_to;
never executed: m_value = m_to;
0
509 break;
never executed: break;
0
510 case QQuickRotationAnimator::Counterclockwise:
never executed: case QQuickRotationAnimator::Counterclockwise:
0
511 m_value = _q_interpolateCounterclockwiseRotation(m_from, m_to, t).toFloat();-
512 break;
never executed: break;
0
513 case QQuickRotationAnimator::Shortest:
never executed: case QQuickRotationAnimator::Shortest:
0
514 m_value = _q_interpolateShortestRotation(m_from, m_to, t).toFloat();-
515 break;
never executed: break;
0
516 case QQuickRotationAnimator::Numerical:
executed 4 times by 1 test: case QQuickRotationAnimator::Numerical:
Executed by:
  • tst_examples
4
517 m_value = m_from + (m_to - m_from) * t;-
518 break;
executed 4 times by 1 test: break;
Executed by:
  • tst_examples
4
519 }-
520 m_helper->rotation = m_value;-
521 m_helper->wasChanged = true;-
522}
executed 4 times by 1 test: end of block
Executed by:
  • tst_examples
4
523-
524void QQuickRotationAnimatorJob::writeBack()-
525{-
526 if (m_target)
m_targetDescription
TRUEnever evaluated
FALSEnever evaluated
0
527 m_target->setRotation(value());
never executed: m_target->setRotation(value());
0
528}
never executed: end of block
0
529-
530-
531QQuickOpacityAnimatorJob::QQuickOpacityAnimatorJob()-
532 : m_opacityNode(nullptr)-
533{-
534}
executed 6 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
6
535-
536void QQuickOpacityAnimatorJob::postSync()-
537{-
538 if (!m_target) {
!m_targetDescription
TRUEevaluated 847 times by 1 test
Evaluated by:
  • tst_qquickanimations
FALSEevaluated 8 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
8-847
539 invalidate();-
540 return;
executed 847 times by 1 test: return;
Executed by:
  • tst_qquickanimations
847
541 }-
542-
543 QQuickItemPrivate *d = QQuickItemPrivate::get(m_target);-
544#if QT_CONFIG(quick_shadereffect)-
545 if (d->extra.isAllocated()
d->extra.isAllocated()Description
TRUEevaluated 4 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
FALSEevaluated 4 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
4
546 && d->extra->layer
d->extra->layerDescription
TRUEnever evaluated
FALSEevaluated 4 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
0-4
547 && d->extra->layer->enabled()) {
d->extra->layer->enabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
548 d = QQuickItemPrivate::get(d->extra->layer->m_effectSource);-
549 }
never executed: end of block
0
550#endif-
551-
552 m_opacityNode = d->opacityNode();-
553-
554 if (!m_opacityNode) {
!m_opacityNodeDescription
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickanimations
2-6
555 m_opacityNode = new QSGOpacityNode();-
556-
557 /* The item node subtree is like this-
558 *-
559 * itemNode-
560 * (opacityNode) optional-
561 * (clipNode) optional-
562 * (rootNode) optional-
563 * children / paintNode-
564 *-
565 * If the opacity node doesn't exist, we need to insert it into-
566 * the hierarchy between itemNode and clipNode or rootNode. If-
567 * neither clip or root exists, we need to reparent all children-
568 * from itemNode to opacityNode.-
569 */-
570 QSGNode *iNode = d->itemNode();-
571 QSGNode *child = d->childContainerNode();-
572 if (child != iNode) {
child != iNodeDescription
TRUEnever evaluated
FALSEevaluated 6 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
0-6
573 if (child->parent())
child->parent()Description
TRUEnever evaluated
FALSEnever evaluated
0
574 child->parent()->removeChildNode(child);
never executed: child->parent()->removeChildNode(child);
0
575 m_opacityNode->appendChildNode(child);-
576 iNode->appendChildNode(m_opacityNode);-
577 } else {
never executed: end of block
0
578 iNode->reparentChildNodesTo(m_opacityNode);-
579 iNode->appendChildNode(m_opacityNode);-
580 }
executed 6 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
6
581-
582 d->extra.value().opacityNode = m_opacityNode;-
583 }
executed 6 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
6
584 Q_ASSERT(m_opacityNode);-
585}
executed 8 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
8
586-
587void QQuickOpacityAnimatorJob::invalidate()-
588{-
589 m_opacityNode = nullptr;-
590}
executed 853 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimations
853
591-
592void QQuickOpacityAnimatorJob::writeBack()-
593{-
594 if (m_target)
m_targetDescription
TRUEnever evaluated
FALSEnever evaluated
0
595 m_target->setOpacity(value());
never executed: m_target->setOpacity(value());
0
596}
never executed: end of block
0
597-
598void QQuickOpacityAnimatorJob::updateCurrentTime(int time)-
599{-
600#if QT_CONFIG(opengl)-
601 Q_ASSERT(!m_controller || !m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread());-
602#endif-
603-
604 if (!m_opacityNode)
!m_opacityNodeDescription
TRUEevaluated 628 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
FALSEnever evaluated
0-628
605 return;
executed 628 times by 2 tests: return;
Executed by:
  • tst_examples
  • tst_qquickanimations
628
606-
607 m_value = m_from + (m_to - m_from) * progress(time);-
608 m_opacityNode->setOpacity(m_value);-
609}
never executed: end of block
0
610-
611-
612#if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl)-
613QQuickUniformAnimatorJob::QQuickUniformAnimatorJob()-
614 : m_node(nullptr)-
615 , m_uniformIndex(-1)-
616 , m_uniformType(-1)-
617{-
618 m_isUniform = true;-
619}
executed 4 times by 1 test: end of block
Executed by:
  • tst_examples
4
620-
621void QQuickUniformAnimatorJob::setTarget(QQuickItem *target)-
622{-
623 QQuickShaderEffect* effect = qobject_cast<QQuickShaderEffect*>(target);-
624 if (effect && effect->isOpenGLShaderEffect())
effectDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_examples
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_examples
effect->isOpenGLShaderEffect()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_examples
FALSEnever evaluated
0-4
625 m_target = target;
executed 4 times by 1 test: m_target = target;
Executed by:
  • tst_examples
4
626}
executed 6 times by 1 test: end of block
Executed by:
  • tst_examples
6
627-
628void QQuickUniformAnimatorJob::invalidate()-
629{-
630 m_node = nullptr;-
631 m_uniformIndex = -1;-
632 m_uniformType = -1;-
633}
executed 4 times by 1 test: end of block
Executed by:
  • tst_examples
4
634-
635void QQuickUniformAnimatorJob::postSync()-
636{-
637 if (!m_target) {
!m_targetDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_examples
0-4
638 invalidate();-
639 return;
never executed: return;
0
640 }-
641-
642 m_node = static_cast<QQuickOpenGLShaderEffectNode *>(QQuickItemPrivate::get(m_target)->paintNode);-
643-
644 if (m_node && m_uniformIndex == -1 && m_uniformType == -1) {
m_nodeDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_examples
FALSEnever evaluated
m_uniformIndex == -1Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_examples
FALSEnever evaluated
m_uniformType == -1Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_examples
FALSEnever evaluated
0-4
645 QQuickOpenGLShaderEffectMaterial *material =-
646 static_cast<QQuickOpenGLShaderEffectMaterial *>(m_node->material());-
647 bool found = false;-
648 for (int t=0; !found && t<QQuickOpenGLShaderEffectMaterialKey::ShaderTypeCount; ++t) {
!foundDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_examples
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_examples
t<QQuickOpenGL...haderTypeCountDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_examples
FALSEnever evaluated
0-8
649 const QVector<QQuickOpenGLShaderEffectMaterial::UniformData> &uniforms = material->uniforms[t];-
650 for (int i=0; i<uniforms.size(); ++i) {
i<uniforms.size()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_examples
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_examples
4-8
651 if (uniforms.at(i).name == m_uniform) {
uniforms.at(i)...e == m_uniformDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_examples
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_examples
4
652 m_uniformIndex = i;-
653 m_uniformType = t;-
654 found = true;-
655 break;
executed 4 times by 1 test: break;
Executed by:
  • tst_examples
4
656 }-
657 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_examples
4
658 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_examples
8
659 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_examples
4
660-
661}
executed 4 times by 1 test: end of block
Executed by:
  • tst_examples
4
662-
663void QQuickUniformAnimatorJob::updateCurrentTime(int time)-
664{-
665 if (!m_controller)
!m_controllerDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_examples
0-4
666 return;
never executed: return;
0
667-
668 if (!m_node || m_uniformIndex == -1 || m_uniformType == -1)
!m_nodeDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_examples
FALSEnever evaluated
m_uniformIndex == -1Description
TRUEnever evaluated
FALSEnever evaluated
m_uniformType == -1Description
TRUEnever evaluated
FALSEnever evaluated
0-4
669 return;
executed 4 times by 1 test: return;
Executed by:
  • tst_examples
4
670-
671 m_value = m_from + (m_to - m_from) * progress(time);-
672-
673 QQuickOpenGLShaderEffectMaterial *material =-
674 static_cast<QQuickOpenGLShaderEffectMaterial *>(m_node->material());-
675 material->uniforms[m_uniformType][m_uniformIndex].value = m_value;-
676 // As we're not touching the nodes, we need to explicitly mark it dirty.-
677 // Otherwise, the renderer will abort repainting if this was the only-
678 // change in the graph currently rendering.-
679 m_node->markDirty(QSGNode::DirtyMaterial);-
680}
never executed: end of block
0
681-
682void QQuickUniformAnimatorJob::writeBack()-
683{-
684 if (m_target)
m_targetDescription
TRUEnever evaluated
FALSEnever evaluated
0
685 m_target->setProperty(m_uniform, value());
never executed: m_target->setProperty(m_uniform, value());
0
686}
never executed: end of block
0
687#endif-
688-
689QT_END_NAMESPACE-
690-
691#include "moc_qquickanimatorjob_p.cpp"-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0