OpenCoverage

qquickanimatedsprite.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickanimatedsprite.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4QQuickAnimatedSprite::QQuickAnimatedSprite(QQuickItem *parent) :-
5 QQuickItem(*(new QQuickAnimatedSpritePrivate), parent)-
6{-
7 QQuickAnimatedSpritePrivate * const d = d_func();-
8 d->m_sprite = new QQuickSprite(this);-
9-
10 setFlag(ItemHasContents);-
11 connect(this, qFlagLocation("2""widthChanged()" "\0" __FILE__ ":" "288"),-
12 this, qFlagLocation("1""reset()" "\0" __FILE__ ":" "289"));-
13 connect(this, qFlagLocation("2""heightChanged()" "\0" __FILE__ ":" "290"),-
14 this, qFlagLocation("1""reset()" "\0" __FILE__ ":" "291"));-
15}
executed 18 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
18
16-
17bool QQuickAnimatedSprite::running() const-
18{-
19 const QQuickAnimatedSpritePrivate * const d = d_func();-
20 return
executed 288 times by 1 test: return d->m_running;
Executed by:
  • tst_qquickanimatedsprite
d->m_running;
executed 288 times by 1 test: return d->m_running;
Executed by:
  • tst_qquickanimatedsprite
288
21}-
22-
23bool QQuickAnimatedSprite::interpolate() const-
24{-
25 const QQuickAnimatedSpritePrivate * const d = d_func();-
26 return
executed 4 times by 1 test: return d->m_interpolate;
Executed by:
  • tst_qquickanimatedsprite
d->m_interpolate;
executed 4 times by 1 test: return d->m_interpolate;
Executed by:
  • tst_qquickanimatedsprite
4
27}-
28-
29QUrl QQuickAnimatedSprite::source() const-
30{-
31 const QQuickAnimatedSpritePrivate * const d = d_func();-
32 return
never executed: return d->m_sprite->source();
d->m_sprite->source();
never executed: return d->m_sprite->source();
0
33}-
34-
35bool QQuickAnimatedSprite::reverse() const-
36{-
37 const QQuickAnimatedSpritePrivate * const d = d_func();-
38 return
never executed: return d->m_sprite->reverse();
d->m_sprite->reverse();
never executed: return d->m_sprite->reverse();
0
39}-
40-
41bool QQuickAnimatedSprite::frameSync() const-
42{-
43 const QQuickAnimatedSpritePrivate * const d = d_func();-
44 return
never executed: return d->m_sprite->frameSync();
d->m_sprite->frameSync();
never executed: return d->m_sprite->frameSync();
0
45}-
46-
47int QQuickAnimatedSprite::frameCount() const-
48{-
49 const QQuickAnimatedSpritePrivate * const d = d_func();-
50 return
executed 6 times by 1 test: return d->m_sprite->frames();
Executed by:
  • tst_qquickanimatedsprite
d->m_sprite->frames();
executed 6 times by 1 test: return d->m_sprite->frames();
Executed by:
  • tst_qquickanimatedsprite
6
51}-
52-
53int QQuickAnimatedSprite::frameHeight() const-
54{-
55 const QQuickAnimatedSpritePrivate * const d = d_func();-
56 return
executed 651 times by 1 test: return d->m_sprite->frameHeight();
Executed by:
  • tst_qquickanimatedsprite
d->m_sprite->frameHeight();
executed 651 times by 1 test: return d->m_sprite->frameHeight();
Executed by:
  • tst_qquickanimatedsprite
651
57}-
58-
59int QQuickAnimatedSprite::frameWidth() const-
60{-
61 const QQuickAnimatedSpritePrivate * const d = d_func();-
62 return
executed 28 times by 1 test: return d->m_sprite->frameWidth();
Executed by:
  • tst_qquickanimatedsprite
d->m_sprite->frameWidth();
executed 28 times by 1 test: return d->m_sprite->frameWidth();
Executed by:
  • tst_qquickanimatedsprite
28
63}-
64-
65int QQuickAnimatedSprite::frameX() const-
66{-
67 const QQuickAnimatedSpritePrivate * const d = d_func();-
68 return
never executed: return d->m_sprite->frameX();
d->m_sprite->frameX();
never executed: return d->m_sprite->frameX();
0
69}-
70-
71int QQuickAnimatedSprite::frameY() const-
72{-
73 const QQuickAnimatedSpritePrivate * const d = d_func();-
74 return
never executed: return d->m_sprite->frameY();
d->m_sprite->frameY();
never executed: return d->m_sprite->frameY();
0
75}-
76-
77qreal QQuickAnimatedSprite::frameRate() const-
78{-
79 const QQuickAnimatedSpritePrivate * const d = d_func();-
80 return
never executed: return d->m_sprite->frameRate();
d->m_sprite->frameRate();
never executed: return d->m_sprite->frameRate();
0
81}-
82-
83int QQuickAnimatedSprite::frameDuration() const-
84{-
85 const QQuickAnimatedSpritePrivate * const d = d_func();-
86 return
never executed: return d->m_sprite->frameDuration();
d->m_sprite->frameDuration();
never executed: return d->m_sprite->frameDuration();
0
87}-
88-
89int QQuickAnimatedSprite::loops() const-
90{-
91 const QQuickAnimatedSpritePrivate * const d = d_func();-
92 return
executed 12 times by 1 test: return d->m_loops;
Executed by:
  • tst_qquickanimatedsprite
d->m_loops;
executed 12 times by 1 test: return d->m_loops;
Executed by:
  • tst_qquickanimatedsprite
12
93}-
94-
95bool QQuickAnimatedSprite::paused() const-
96{-
97 const QQuickAnimatedSpritePrivate * const d = d_func();-
98 return
executed 8 times by 1 test: return d->m_paused;
Executed by:
  • tst_qquickanimatedsprite
d->m_paused;
executed 8 times by 1 test: return d->m_paused;
Executed by:
  • tst_qquickanimatedsprite
8
99}-
100-
101int QQuickAnimatedSprite::currentFrame() const-
102{-
103 const QQuickAnimatedSpritePrivate * const d = d_func();-
104 return
executed 16 times by 1 test: return d->m_curFrame;
Executed by:
  • tst_qquickanimatedsprite
d->m_curFrame;
executed 16 times by 1 test: return d->m_curFrame;
Executed by:
  • tst_qquickanimatedsprite
16
105}-
106-
107bool QQuickAnimatedSprite::isCurrentFrameChangedConnected()-
108{-
109 do { QObject *sender = (this); void (QQuickAnimatedSprite::*signal)(int) = &QQuickAnimatedSprite::currentFrameChanged; static QMetaMethod method = QMetaMethod::fromSignal(signal); static int signalIdx = QMetaObjectPrivate::signalIndex(method); return
executed 556 times by 1 test: return QObjectPrivate::get(sender)->isSignalConnected(signalIdx);
Executed by:
  • tst_qquickanimatedsprite
QObjectPrivate::get(sender)->isSignalConnected(signalIdx);
executed 556 times by 1 test: return QObjectPrivate::get(sender)->isSignalConnected(signalIdx);
Executed by:
  • tst_qquickanimatedsprite
} while (0);
556
110}
never executed: end of block
0
111-
112void QQuickAnimatedSprite::reloadImage()-
113{-
114 if (!isComponentComplete()
!isComponentComplete()Description
TRUEevaluated 46 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
)
6-46
115 return;
executed 46 times by 1 test: return;
Executed by:
  • tst_qquickanimatedsprite
46
116 createEngine();-
117}
executed 6 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
6
118-
119void QQuickAnimatedSprite::componentComplete()-
120{-
121 const QQuickAnimatedSpritePrivate * const d = d_func();-
122 createEngine();-
123 QQuickItem::componentComplete();-
124 if (d->m_running
d->m_runningDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
)
8-10
125 start();
executed 10 times by 1 test: start();
Executed by:
  • tst_qquickanimatedsprite
10
126}
executed 18 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
18
127-
128void QQuickAnimatedSprite::start()-
129{-
130 QQuickAnimatedSpritePrivate * const d = d_func();-
131 d->m_running = true;-
132 if (!isComponentComplete()
!isComponentComplete()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
)
8-18
133 return;
executed 8 times by 1 test: return;
Executed by:
  • tst_qquickanimatedsprite
8
134 d->m_curLoop = 0;-
135 d->m_timestamp.start();-
136 if (d->m_spriteEngine
d->m_spriteEngineDescription
TRUEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEnever evaluated
) {
0-18
137 d->m_spriteEngine->stop(0);-
138 d->m_spriteEngine->updateSprites(0);-
139 d->m_spriteEngine->start(0);-
140 }
executed 18 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
18
141 currentFrameChanged(0);-
142 runningChanged(true);-
143 maybeUpdate();-
144}
executed 18 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
18
145-
146void QQuickAnimatedSprite::stop()-
147{-
148 QQuickAnimatedSpritePrivate * const d = d_func();-
149 d->m_running = false;-
150 if (!isComponentComplete()
!isComponentComplete()Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
)
2-16
151 return;
executed 16 times by 1 test: return;
Executed by:
  • tst_qquickanimatedsprite
16
152 d->m_pauseOffset = 0;-
153 runningChanged(false);-
154 maybeUpdate();-
155}
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
2
156-
157-
158-
159-
160-
161-
162void QQuickAnimatedSprite::advance(int frames)-
163{-
164 QQuickAnimatedSpritePrivate * const d = d_func();-
165 if (!frames
!framesDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
166 return;
never executed: return;
0
167-
168 d->m_curFrame += frames;-
169 while (d->m_curFrame < 0
d->m_curFrame < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
170 d->m_curFrame += d->m_spriteEngine->maxFrames();
never executed: d->m_curFrame += d->m_spriteEngine->maxFrames();
0
171 d->m_curFrame = d->m_curFrame % d->m_spriteEngine->maxFrames();-
172 currentFrameChanged(d->m_curFrame);-
173 maybeUpdate();-
174}
never executed: end of block
0
175-
176void QQuickAnimatedSprite::maybeUpdate()-
177{-
178 QQuickItemPrivate *priv = QQuickItemPrivate::get(this);-
179 const QLazilyAllocated<QQuickItemPrivate::ExtraData> &extraData = priv->extra;-
180 if ((extraData.isAllocated()
extraData.isAllocated()Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 1563 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
&& extraData->effectRefCount > 0
extraData->effectRefCount > 0Description
TRUEnever evaluated
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
) || priv->effectiveVisible
priv->effectiveVisibleDescription
TRUEevaluated 1585 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEnever evaluated
)
0-1585
181 update();
executed 1585 times by 1 test: update();
Executed by:
  • tst_qquickanimatedsprite
1585
182}
executed 1585 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
1585
183void QQuickAnimatedSprite::pause()-
184{-
185 QQuickAnimatedSpritePrivate * const d = d_func();-
186-
187 if (d->m_paused
d->m_pausedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
188 return;
never executed: return;
0
189 d->m_pauseOffset = d->m_timestamp.elapsed();-
190 d->m_paused = true;-
191 pausedChanged(true);-
192 maybeUpdate();-
193}
never executed: end of block
0
194void QQuickAnimatedSprite::resume()-
195{-
196 QQuickAnimatedSpritePrivate * const d = d_func();-
197-
198 if (!d->m_paused
!d->m_pausedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
199 return;
never executed: return;
0
200 d->m_pauseOffset = d->m_pauseOffset - d->m_timestamp.elapsed();-
201 d->m_paused = false;-
202 pausedChanged(false);-
203 maybeUpdate();-
204}
never executed: end of block
0
205-
206void QQuickAnimatedSprite::setRunning(bool arg)-
207{-
208 QQuickAnimatedSpritePrivate * const d = d_func();-
209-
210 if (d->m_running != arg
d->m_running != argDescription
TRUEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEnever evaluated
) {
0-18
211 if (d->m_running
d->m_runningDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
)
8-10
212 stop();
executed 10 times by 1 test: stop();
Executed by:
  • tst_qquickanimatedsprite
10
213 else-
214 start();
executed 8 times by 1 test: start();
Executed by:
  • tst_qquickanimatedsprite
8
215 }-
216}
executed 18 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
18
217-
218void QQuickAnimatedSprite::setPaused(bool arg)-
219{-
220 const QQuickAnimatedSpritePrivate * const d = d_func();-
221-
222 if (d->m_paused != arg
d->m_paused != argDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
223 if (d->m_paused
d->m_pausedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
224 resume();
never executed: resume();
0
225 else-
226 pause();
never executed: pause();
0
227 }-
228}
never executed: end of block
0
229-
230void QQuickAnimatedSprite::setInterpolate(bool arg)-
231{-
232 QQuickAnimatedSpritePrivate * const d = d_func();-
233-
234 if (d->m_interpolate != arg
d->m_interpolate != argDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEnever evaluated
) {
0-2
235 d->m_interpolate = arg;-
236 interpolateChanged(arg);-
237 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
2
238}
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
2
239-
240void QQuickAnimatedSprite::setSource(QUrl arg)-
241{-
242 QQuickAnimatedSpritePrivate * const d = d_func();-
243-
244 if (d->m_sprite->m_source != arg
d->m_sprite->m_source != argDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEnever evaluated
) {
0-20
245 const qreal targetDevicePixelRatio = (window()
window()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
? window()->effectiveDevicePixelRatio() : (static_cast<QGuiApplication *>(QCoreApplication::instance()))->devicePixelRatio());
2-18
246 d->m_sprite->setDevicePixelRatio(targetDevicePixelRatio);-
247 d->m_sprite->setSource(arg);-
248 sourceChanged(arg);-
249 reloadImage();-
250 }
executed 20 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
20
251}
executed 20 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
20
252-
253void QQuickAnimatedSprite::setReverse(bool arg)-
254{-
255 QQuickAnimatedSpritePrivate * const d = d_func();-
256-
257 if (d->m_sprite->m_reverse != arg
d->m_sprite->m_reverse != argDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
258 d->m_sprite->setReverse(arg);-
259 reverseChanged(arg);-
260 }
never executed: end of block
0
261}
never executed: end of block
0
262-
263void QQuickAnimatedSprite::setFrameSync(bool arg)-
264{-
265 QQuickAnimatedSpritePrivate * const d = d_func();-
266-
267 if (d->m_sprite->m_frameSync != arg
d->m_sprite->m...ameSync != argDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
) {
2-10
268 d->m_sprite->setFrameSync(arg);-
269 frameSyncChanged(arg);-
270 if (d->m_running
d->m_runningDescription
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
)
0-10
271 restart();
never executed: restart();
0
272 }
executed 10 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
10
273}
executed 12 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
12
274-
275void QQuickAnimatedSprite::setFrameCount(int arg)-
276{-
277 QQuickAnimatedSpritePrivate * const d = d_func();-
278-
279 if (d->m_sprite->m_frames != arg
d->m_sprite->m_frames != argDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEnever evaluated
) {
0-16
280 d->m_sprite->setFrameCount(arg);-
281 frameCountChanged(arg);-
282 reloadImage();-
283 }
executed 16 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
16
284}
executed 16 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
16
285-
286void QQuickAnimatedSprite::setFrameHeight(int arg)-
287{-
288 QQuickAnimatedSpritePrivate * const d = d_func();-
289-
290 if (d->m_sprite->m_frameHeight != arg
d->m_sprite->m...eHeight != argDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEnever evaluated
) {
0-8
291 d->m_sprite->setFrameHeight(arg);-
292 frameHeightChanged(arg);-
293 setImplicitHeight(frameHeight());-
294 reloadImage();-
295 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
8
296}
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
8
297-
298void QQuickAnimatedSprite::setFrameWidth(int arg)-
299{-
300 QQuickAnimatedSpritePrivate * const d = d_func();-
301-
302 if (d->m_sprite->m_frameWidth != arg
d->m_sprite->m...meWidth != argDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEnever evaluated
) {
0-8
303 d->m_sprite->setFrameWidth(arg);-
304 frameWidthChanged(arg);-
305 setImplicitWidth(frameWidth());-
306 reloadImage();-
307 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
8
308}
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
8
309-
310void QQuickAnimatedSprite::setFrameX(int arg)-
311{-
312 QQuickAnimatedSpritePrivate * const d = d_func();-
313-
314 if (d->m_sprite->m_frameX != arg
d->m_sprite->m_frameX != argDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
315 d->m_sprite->setFrameX(arg);-
316 frameXChanged(arg);-
317 reloadImage();-
318 }
never executed: end of block
0
319}
never executed: end of block
0
320-
321void QQuickAnimatedSprite::setFrameY(int arg)-
322{-
323 QQuickAnimatedSpritePrivate * const d = d_func();-
324-
325 if (d->m_sprite->m_frameY != arg
d->m_sprite->m_frameY != argDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
326 d->m_sprite->setFrameY(arg);-
327 frameYChanged(arg);-
328 reloadImage();-
329 }
never executed: end of block
0
330}
never executed: end of block
0
331-
332void QQuickAnimatedSprite::setFrameRate(qreal arg)-
333{-
334 QQuickAnimatedSpritePrivate * const d = d_func();-
335-
336 if (d->m_sprite->m_frameRate != arg
d->m_sprite->m...ameRate != argDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
337 d->m_sprite->setFrameRate(arg);-
338 frameRateChanged(arg);-
339 if (d->m_running
d->m_runningDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
340 restart();
never executed: restart();
0
341 }
never executed: end of block
0
342}
never executed: end of block
0
343-
344void QQuickAnimatedSprite::setFrameDuration(int arg)-
345{-
346 QQuickAnimatedSpritePrivate * const d = d_func();-
347-
348 if (d->m_sprite->m_frameDuration != arg
d->m_sprite->m...uration != argDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEnever evaluated
) {
0-10
349 d->m_sprite->setFrameDuration(arg);-
350 frameDurationChanged(arg);-
351 if (d->m_running
d->m_runningDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
)
2-8
352 restart();
executed 8 times by 1 test: restart();
Executed by:
  • tst_qquickanimatedsprite
8
353 }
executed 10 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
10
354}
executed 10 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
10
355-
356void QQuickAnimatedSprite::resetFrameRate()-
357{-
358 setFrameRate(-1.0);-
359}
never executed: end of block
0
360-
361void QQuickAnimatedSprite::resetFrameDuration()-
362{-
363 setFrameDuration(-1);-
364}
never executed: end of block
0
365-
366void QQuickAnimatedSprite::setLoops(int arg)-
367{-
368 QQuickAnimatedSpritePrivate * const d = d_func();-
369-
370 if (d->m_loops != arg
d->m_loops != argDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
) {
2-14
371 d->m_loops = arg;-
372 loopsChanged(arg);-
373 }
executed 14 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
14
374}
executed 16 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
16
375-
376void QQuickAnimatedSprite::setCurrentFrame(int arg)-
377{-
378 QQuickAnimatedSpritePrivate * const d = d_func();-
379-
380 if (d->m_curFrame != arg
d->m_curFrame != argDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
381 d->m_curFrame = arg;-
382 currentFrameChanged(arg);-
383 update();-
384 }
never executed: end of block
0
385}
never executed: end of block
0
386-
387void QQuickAnimatedSprite::createEngine()-
388{-
389 QQuickAnimatedSpritePrivate * const d = d_func();-
390-
391 if (d->m_spriteEngine
d->m_spriteEngineDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
)
6-18
392 delete d->m_spriteEngine;
executed 6 times by 1 test: delete d->m_spriteEngine;
Executed by:
  • tst_qquickanimatedsprite
6
393 QList<QQuickSprite*> spriteList;-
394 spriteList << d->m_sprite;-
395 d->m_spriteEngine = new QQuickSpriteEngine(QList<QQuickSprite*>(spriteList), this);-
396 d->m_spriteEngine->startAssemblingImage();-
397 reset();-
398}
executed 24 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
24
399-
400QSGSpriteNode* QQuickAnimatedSprite::initNode()-
401{-
402 QQuickAnimatedSpritePrivate * const d = d_func();-
403-
404 if (!d->m_spriteEngine
!d->m_spriteEngineDescription
TRUEnever evaluated
FALSEevaluated 30 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
) {
0-30
405 qmlWarning(this) << "No sprite engine...";-
406 return
never executed: return nullptr;
nullptr;
never executed: return nullptr;
0
407 } else if (d->m_spriteEngine->status() == QQuickPixmap::Null
d->m_spriteEng...ckPixmap::NullDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 28 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
) {
2-28
408 d->m_spriteEngine->startAssemblingImage();-
409 maybeUpdate();-
410 return
executed 2 times by 1 test: return nullptr;
Executed by:
  • tst_qquickanimatedsprite
nullptr;
executed 2 times by 1 test: return nullptr;
Executed by:
  • tst_qquickanimatedsprite
2
411 } else if (d->m_spriteEngine->status() == QQuickPixmap::Loading
d->m_spriteEng...ixmap::LoadingDescription
TRUEnever evaluated
FALSEevaluated 28 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
) {
0-28
412 maybeUpdate();-
413 return
never executed: return nullptr;
nullptr;
never executed: return nullptr;
0
414 }-
415-
416 QImage image = d->m_spriteEngine->assembledImage(d->sceneGraphRenderContext()->maxTextureSize());-
417 if (image.isNull()
image.isNull()Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
)
10-18
418 return
executed 10 times by 1 test: return nullptr;
Executed by:
  • tst_qquickanimatedsprite
nullptr;
executed 10 times by 1 test: return nullptr;
Executed by:
  • tst_qquickanimatedsprite
10
419 setImplicitWidth(frameWidth());-
420 setImplicitHeight(frameHeight());-
421-
422 QSGSpriteNode *node = d->sceneGraphContext()->createSpriteNode();-
423-
424 d->m_sheetSize = QSize(image.size() / image.devicePixelRatioF());-
425 node->setTexture(window()->createTextureFromImage(image));-
426 d->m_spriteEngine->start(0);-
427 node->setTime(0.0f);-
428 node->setSourceA(QPoint(d->m_spriteEngine->spriteX(), d->m_spriteEngine->spriteY()));-
429 node->setSourceB(QPoint(d->m_spriteEngine->spriteX(), d->m_spriteEngine->spriteY()));-
430 node->setSpriteSize(QSize(d->m_spriteEngine->spriteWidth(), d->m_spriteEngine->spriteHeight()));-
431 node->setSheetSize(d->m_sheetSize);-
432 node->setSize(QSizeF(width(), height()));-
433 return
executed 18 times by 1 test: return node;
Executed by:
  • tst_qquickanimatedsprite
node;
executed 18 times by 1 test: return node;
Executed by:
  • tst_qquickanimatedsprite
18
434}-
435-
436void QQuickAnimatedSprite::reset()-
437{-
438 QQuickAnimatedSpritePrivate * const d = d_func();-
439 d->m_pleaseReset = true;-
440 maybeUpdate();-
441}
executed 60 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
60
442-
443QSGNode *QQuickAnimatedSprite::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)-
444{-
445 QQuickAnimatedSpritePrivate * const d = d_func();-
446-
447 if (d->m_pleaseReset
d->m_pleaseResetDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 941 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
) {
20-941
448 delete oldNode;-
449-
450 oldNode = nullptr;-
451 d->m_pleaseReset = false;-
452 }
executed 20 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
20
453-
454 QSGSpriteNode *node = static_cast<QSGSpriteNode *>(oldNode);-
455 if (!node
!nodeDescription
TRUEevaluated 30 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 931 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
)
30-931
456 node = initNode();
executed 30 times by 1 test: node = initNode();
Executed by:
  • tst_qquickanimatedsprite
30
457-
458 if (node
nodeDescription
TRUEevaluated 949 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
)
12-949
459 prepareNextFrame(node);
executed 949 times by 1 test: prepareNextFrame(node);
Executed by:
  • tst_qquickanimatedsprite
949
460-
461 if (d->m_running
d->m_runningDescription
TRUEevaluated 939 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
&& !d->m_paused
!d->m_pausedDescription
TRUEevaluated 939 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEnever evaluated
)
0-939
462 maybeUpdate();
executed 939 times by 1 test: maybeUpdate();
Executed by:
  • tst_qquickanimatedsprite
939
463-
464 return
executed 961 times by 1 test: return node;
Executed by:
  • tst_qquickanimatedsprite
node;
executed 961 times by 1 test: return node;
Executed by:
  • tst_qquickanimatedsprite
961
465}-
466-
467void QQuickAnimatedSprite::prepareNextFrame(QSGSpriteNode *node)-
468{-
469 QQuickAnimatedSpritePrivate * const d = d_func();-
470-
471 int timeInt = d->m_timestamp.elapsed() + d->m_pauseOffset;-
472 qreal time = timeInt / 1000.;-
473-
474 int frameAt;-
475 qreal progress = 0.0;-
476 int lastFrame = d->m_curFrame;-
477 if (d->m_running
d->m_runningDescription
TRUEevaluated 935 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 14 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
&& !d->m_paused
!d->m_pausedDescription
TRUEevaluated 935 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEnever evaluated
) {
0-935
478 const int nColumns = d->m_sheetSize.width() / d->m_spriteEngine->spriteWidth();-
479-
480 d->m_spriteEngine->updateSprites(timeInt);-
481-
482-
483 qreal animT = d->m_spriteEngine->spriteStart()/1000.0;-
484 const int frameCountInRow = d->m_spriteEngine->spriteFrames();-
485 const qreal frameDuration = d->m_spriteEngine->spriteDuration() / frameCountInRow;-
486 if (frameDuration > 0
frameDuration > 0Description
TRUEevaluated 623 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 312 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
) {
312-623
487 qreal frame = (time - animT)/(frameDuration / 1000.0);-
488 bool lastLoop = d->m_loops > 0
d->m_loops > 0Description
TRUEevaluated 586 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 37 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
&& d->m_curLoop == d->m_loops-1
d->m_curLoop == d->m_loops-1Description
TRUEevaluated 187 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 399 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
;
37-586
489-
490 const int max = lastLoop
lastLoopDescription
TRUEevaluated 187 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 436 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
? frameCountInRow - 1 : frameCountInRow;
187-436
491 frame = qBound(qreal(0.0), frame, qreal(max));-
492 double intpart;-
493 progress = std::modf(frame,&intpart);-
494 frameAt = (int)intpart;-
495 const int rowIndex = d->m_spriteEngine->spriteY()/frameHeight();-
496 const int newFrame = rowIndex * nColumns + frameAt;-
497 if (d->m_curFrame > newFrame
d->m_curFrame > newFrameDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 617 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
)
6-617
498 d->m_curLoop++;
executed 6 times by 1 test: d->m_curLoop++;
Executed by:
  • tst_qquickanimatedsprite
6
499 d->m_curFrame = newFrame;-
500 }
executed 623 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
else {
623
501 d->m_curFrame++;-
502 if (d->m_curFrame >= d->m_spriteEngine->maxFrames()
d->m_curFrame ...e->maxFrames()Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 294 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
) {
18-294
503 d->m_curFrame = 0;-
504 d->m_curLoop++;-
505 }
executed 18 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
18
506 frameAt = d->m_curFrame % nColumns;-
507 if (frameAt == 0
frameAt == 0Description
TRUEevaluated 30 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 282 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
)
30-282
508 d->m_spriteEngine->advance();
executed 30 times by 1 test: d->m_spriteEngine->advance();
Executed by:
  • tst_qquickanimatedsprite
30
509 progress = 0;-
510 }
executed 312 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
312
511 if (d->m_loops > 0
d->m_loops > 0Description
TRUEevaluated 898 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 37 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
&& d->m_curLoop >= d->m_loops
d->m_curLoop >= d->m_loopsDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 890 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
) {
8-898
512 frameAt = 0;-
513 d->m_running = false;-
514 runningChanged(false);-
515 finished();-
516 maybeUpdate();-
517 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
8
518 }
executed 935 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
else {
935
519 frameAt = d->m_curFrame;-
520 }
executed 14 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
14
521 if (d->m_curFrame != lastFrame
d->m_curFrame != lastFrameDescription
TRUEevaluated 556 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 393 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
) {
393-556
522 if (isCurrentFrameChangedConnected()
isCurrentFrame...gedConnected()Description
TRUEevaluated 516 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 40 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
)
40-516
523 currentFrameChanged(d->m_curFrame);
executed 516 times by 1 test: currentFrameChanged(d->m_curFrame);
Executed by:
  • tst_qquickanimatedsprite
516
524 maybeUpdate();-
525 }
executed 556 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
556
526-
527 qreal frameCount = d->m_spriteEngine->spriteFrames();-
528 bool reverse = d->m_spriteEngine->sprite()->reverse();-
529 if (reverse
reverseDescription
TRUEnever evaluated
FALSEevaluated 949 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
)
0-949
530 frameAt = (frameCount - 1) - frameAt;
never executed: frameAt = (frameCount - 1) - frameAt;
0
531-
532 int w = d->m_spriteEngine->spriteWidth();-
533 int h = d->m_spriteEngine->spriteHeight();-
534 int x1;-
535 int y1;-
536 if (d->m_paused
d->m_pausedDescription
TRUEnever evaluated
FALSEevaluated 949 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
) {
0-949
537 int spriteY = d->m_spriteEngine->spriteY();-
538 if (reverse
reverseDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
539 int rows = d->m_spriteEngine->maxFrames() * d->m_spriteEngine->spriteWidth() / d->m_sheetSize.width();-
540 spriteY -= rows * d->m_spriteEngine->spriteHeight();-
541 frameAt = (frameCount - 1) - frameAt;-
542 }
never executed: end of block
0
543-
544 int position = frameAt * d->m_spriteEngine->spriteWidth() + d->m_spriteEngine->spriteX();-
545 int row = position / d->m_sheetSize.width();-
546-
547 x1 = (position - (row * d->m_sheetSize.width()));-
548 y1 = (row * d->m_spriteEngine->spriteHeight() + spriteY);-
549 }
never executed: end of block
else {
0
550 x1 = d->m_spriteEngine->spriteX() + frameAt * w;-
551 y1 = d->m_spriteEngine->spriteY();-
552 }
executed 949 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
949
553-
554-
555-
556-
557 int x2;-
558 int y2;-
559 if (reverse
reverseDescription
TRUEnever evaluated
FALSEevaluated 949 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
) {
0-949
560 if (frameAt > 0
frameAt > 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
561 x2 = x1 - w;-
562 y2 = y1;-
563 }
never executed: end of block
else {
0
564 x2 = 1.0 - w;-
565 y2 = y1 - h;-
566 if (y2 < 0.0
y2 < 0.0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
567-
568 int maxRowFrames = d->m_sheetSize.width() / d->m_spriteEngine->spriteWidth();-
569 if (d->m_spriteEngine->maxFrames() % maxRowFrames
d->m_spriteEng...% maxRowFramesDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
570 x2 = ((d->m_spriteEngine->maxFrames() % maxRowFrames) - 1) * w;
never executed: x2 = ((d->m_spriteEngine->maxFrames() % maxRowFrames) - 1) * w;
0
571-
572 y2 = 1.0 - h;-
573 }
never executed: end of block
0
574 }
never executed: end of block
0
575 } else {-
576 if (frameAt < (frameCount-1)
frameAt < (frameCount-1)Description
TRUEevaluated 863 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 86 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
) {
86-863
577 x2 = x1 + w;-
578 y2 = y1;-
579 }
executed 863 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
else {
863
580 x2 = 0.0;-
581 y2 = y1 + h;-
582 if (y2 >= 1.0
y2 >= 1.0Description
TRUEevaluated 86 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEnever evaluated
)
0-86
583 y2 = 0.0;
executed 86 times by 1 test: y2 = 0.0;
Executed by:
  • tst_qquickanimatedsprite
86
584 }
executed 86 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
86
585 }-
586-
587 node->setSourceA(QPoint(x1, y1));-
588 node->setSourceB(QPoint(x2, y2));-
589 node->setSpriteSize(QSize(w, h));-
590 node->setTime(d->m_interpolate ? progress : 0.0);-
591 node->setSize(QSizeF(width(), height()));-
592 node->setFiltering(smooth() ? QSGTexture::Linear : QSGTexture::Nearest);-
593 node->update();-
594}
executed 949 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
949
595-
596-
597-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.0