OpenCoverage

qquickanimatedsprite.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickanimatedsprite.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtQuick module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qquickanimatedsprite_p.h"-
41#include "qquickanimatedsprite_p_p.h"-
42#include "qquicksprite_p.h"-
43#include "qquickspriteengine_p.h"-
44#include <QtQuick/private/qsgcontext_p.h>-
45#include <QtQuick/private/qquickitem_p.h>-
46#include <private/qsgadaptationlayer_p.h>-
47#include <private/qqmlglobal_p.h>-
48#include <QtQuick/qsgnode.h>-
49#include <QtQuick/qsgtexturematerial.h>-
50#include <QtQuick/qsgtexture.h>-
51#include <QtQuick/qquickwindow.h>-
52#include <QtQml/qqmlinfo.h>-
53#include <QFile>-
54#include <cmath>-
55#include <qmath.h>-
56#include <QDebug>-
57-
58QT_BEGIN_NAMESPACE-
59-
60/*!-
61 \qmltype AnimatedSprite-
62 \instantiates QQuickAnimatedSprite-
63 \inqmlmodule QtQuick-
64 \inherits Item-
65 \ingroup qtquick-visual-
66 \brief Draws a sprite animation.-
67-
68 AnimatedSprite provides rendering and control over animations which are provided-
69 as multiple frames in the same image file. You can play it at a fixed speed, at the-
70 frame rate of your display, or manually advance and control the progress.-
71-
72 Consider the following sprite sheet:-
73-
74 \image animatedsprite-loading.png-
75-
76 It can be divided up into four frames:-
77-
78 \image animatedsprite-loading-frames.png-
79-
80 To play each of these frames at a speed of 500 milliseconds per frame, the-
81 following code can be used:-
82-
83 \table-
84 \header-
85 \li Code-
86 \li Result-
87 \row-
88 \li-
89 \code-
90 AnimatedSprite {-
91 source: "loading.png"-
92 frameWidth: 64-
93 frameHeight: 64-
94 frameCount: 4-
95 frameDuration: 500-
96 }-
97 \endcode-
98 \li-
99 \image animatedsprite-loading-interpolated.gif-
100 \endtable-
101-
102 By default, the frames are interpolated (blended together) to make the-
103 animation appear smoother. To disable this, set \l interpolate to \c false:-
104-
105 \table-
106 \header-
107 \li Code-
108 \li Result-
109 \row-
110 \li-
111 \code-
112 AnimatedSprite {-
113 source: "loading.png"-
114 frameWidth: 64-
115 frameHeight: 64-
116 frameCount: 4-
117 frameDuration: 500-
118 interpolate: false-
119 }-
120 \endcode-
121 \li-
122 \image animatedsprite-loading.gif-
123 \endtable-
124-
125 To control how AnimatedSprite responds to being scaled, use the-
126 \l {Item::}{smooth} property.-
127-
128 Note that unlike \l SpriteSequence, the AnimatedSprite type does not use-
129 \l Sprite to define multiple animations, but instead encapsulates a-
130 single animation itself.-
131-
132 \sa {Sprite Animations}-
133*/-
134-
135/*!-
136 \qmlproperty bool QtQuick::AnimatedSprite::running-
137-
138 Whether the sprite is animating or not.-
139-
140 Default is true-
141*/-
142-
143/*!-
144 \qmlproperty bool QtQuick::AnimatedSprite::interpolate-
145-
146 If true, interpolation will occur between sprite frames to make the-
147 animation appear smoother.-
148-
149 Default is true.-
150*/-
151-
152/*!-
153 \qmlproperty qreal QtQuick::AnimatedSprite::frameRate-
154-
155 Frames per second to show in the animation. Values less than or equal to \c 0 are invalid.-
156-
157 If \c frameRate is valid, it will be used to calculate the duration of the frames.-
158 If not, and \l frameDuration is valid, \c frameDuration will be used.-
159-
160 Changing this parameter will restart the animation.-
161*/-
162-
163/*!-
164 \qmlproperty int QtQuick::AnimatedSprite::frameDuration-
165-
166 Duration of each frame of the animation in milliseconds. Values less than or equal to \c 0 are invalid.-
167-
168 If frameRate is valid, it will be used to calculate the duration of the frames.-
169 If not, and \l frameDuration is valid, \c frameDuration will be used.-
170-
171 Changing this parameter will restart the animation.-
172*/-
173-
174/*!-
175 \qmlproperty int QtQuick::AnimatedSprite::frameCount-
176-
177 Number of frames in this AnimatedSprite.-
178*/-
179/*!-
180 \qmlproperty int QtQuick::AnimatedSprite::frameHeight-
181-
182 Height of a single frame in this AnimatedSprite.-
183-
184 May be omitted if it is the only sprite in the file.-
185*/-
186/*!-
187 \qmlproperty int QtQuick::AnimatedSprite::frameWidth-
188-
189 Width of a single frame in this AnimatedSprite.-
190-
191 May be omitted if it is the only sprite in the file.-
192*/-
193/*!-
194 \qmlproperty int QtQuick::AnimatedSprite::frameX-
195-
196 The X coordinate in the image file of the first frame of the AnimatedSprite.-
197-
198 May be omitted if the first frame starts in the upper left corner of the file.-
199*/-
200/*!-
201 \qmlproperty int QtQuick::AnimatedSprite::frameY-
202-
203 The Y coordinate in the image file of the first frame of the AnimatedSprite.-
204-
205 May be omitted if the first frame starts in the upper left corner of the file.-
206*/-
207/*!-
208 \qmlproperty url QtQuick::AnimatedSprite::source-
209-
210 The image source for the animation.-
211-
212 If frameHeight and frameWidth are not specified, it is assumed to be a single long row of square frames.-
213 Otherwise, it can be multiple contiguous rows or rectangluar frames, when one row runs out the next will be used.-
214-
215 If frameX and frameY are specified, the row of frames will be taken with that x/y coordinate as the upper left corner.-
216*/-
217-
218/*!-
219 \qmlproperty bool QtQuick::AnimatedSprite::reverse-
220-
221 If \c true, the animation will be played in reverse.-
222-
223 Default is \c false.-
224*/-
225-
226/*!-
227 \qmlproperty bool QtQuick::AnimatedSprite::frameSync-
228-
229 If \c true, the animation will have no duration. Instead, the animation will advance-
230 one frame each time a frame is rendered to the screen. This synchronizes it with the painting-
231 rate as opposed to elapsed time.-
232-
233 If frameSync is set to true, it overrides both frameRate and frameDuration.-
234-
235 Default is \c false.-
236-
237 Changing this parameter will restart the animation.-
238*/-
239-
240/*!-
241 \qmlproperty int QtQuick::AnimatedSprite::loops-
242-
243 After playing the animation this many times, the animation will automatically stop. Negative values are invalid.-
244-
245 If this is set to \c AnimatedSprite.Infinite the animation will not stop playing on its own.-
246-
247 Default is \c AnimatedSprite.Infinite-
248*/-
249-
250/*!-
251 \qmlproperty bool QtQuick::AnimatedSprite::paused-
252-
253 When paused, the current frame can be advanced manually.-
254-
255 Default is \c false.-
256*/-
257-
258/*!-
259 \qmlproperty int QtQuick::AnimatedSprite::currentFrame-
260-
261 When paused, the current frame can be advanced manually by setting this property or calling \l advance().-
262-
263*/-
264-
265/*!-
266 \qmlmethod int QtQuick::AnimatedSprite::restart()-
267-
268 Stops, then starts the sprite animation.-
269*/-
270-
271/*!-
272 \qmlsignal QtQuick::AnimatedSprite::finished()-
273 \since 5.12-
274-
275 This signal is emitted when the sprite has finished animating.-
276-
277 It is not emitted when running is set to \c false, nor for sprites whose-
278 \l loops property is set to \c AnimatedSprite.Infinite.-
279*/-
280-
281QQuickAnimatedSprite::QQuickAnimatedSprite(QQuickItem *parent) :-
282 QQuickItem(*(new QQuickAnimatedSpritePrivate), parent)-
283{-
284 Q_D(QQuickAnimatedSprite);-
285 d->m_sprite = new QQuickSprite(this);-
286-
287 setFlag(ItemHasContents);-
288 connect(this, SIGNAL(widthChanged()),-
289 this, SLOT(reset()));-
290 connect(this, SIGNAL(heightChanged()),-
291 this, SLOT(reset()));-
292}
executed 18 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
18
293-
294bool QQuickAnimatedSprite::running() const-
295{-
296 Q_D(const QQuickAnimatedSprite);-
297 return d->m_running;
executed 288 times by 1 test: return d->m_running;
Executed by:
  • tst_qquickanimatedsprite
288
298}-
299-
300bool QQuickAnimatedSprite::interpolate() const-
301{-
302 Q_D(const QQuickAnimatedSprite);-
303 return d->m_interpolate;
executed 4 times by 1 test: return d->m_interpolate;
Executed by:
  • tst_qquickanimatedsprite
4
304}-
305-
306QUrl QQuickAnimatedSprite::source() const-
307{-
308 Q_D(const QQuickAnimatedSprite);-
309 return d->m_sprite->source();
never executed: return d->m_sprite->source();
0
310}-
311-
312bool QQuickAnimatedSprite::reverse() const-
313{-
314 Q_D(const QQuickAnimatedSprite);-
315 return d->m_sprite->reverse();
never executed: return d->m_sprite->reverse();
0
316}-
317-
318bool QQuickAnimatedSprite::frameSync() const-
319{-
320 Q_D(const QQuickAnimatedSprite);-
321 return d->m_sprite->frameSync();
never executed: return d->m_sprite->frameSync();
0
322}-
323-
324int QQuickAnimatedSprite::frameCount() const-
325{-
326 Q_D(const QQuickAnimatedSprite);-
327 return d->m_sprite->frames();
executed 6 times by 1 test: return d->m_sprite->frames();
Executed by:
  • tst_qquickanimatedsprite
6
328}-
329-
330int QQuickAnimatedSprite::frameHeight() const-
331{-
332 Q_D(const QQuickAnimatedSprite);-
333 return d->m_sprite->frameHeight();
executed 651 times by 1 test: return d->m_sprite->frameHeight();
Executed by:
  • tst_qquickanimatedsprite
651
334}-
335-
336int QQuickAnimatedSprite::frameWidth() const-
337{-
338 Q_D(const QQuickAnimatedSprite);-
339 return d->m_sprite->frameWidth();
executed 28 times by 1 test: return d->m_sprite->frameWidth();
Executed by:
  • tst_qquickanimatedsprite
28
340}-
341-
342int QQuickAnimatedSprite::frameX() const-
343{-
344 Q_D(const QQuickAnimatedSprite);-
345 return d->m_sprite->frameX();
never executed: return d->m_sprite->frameX();
0
346}-
347-
348int QQuickAnimatedSprite::frameY() const-
349{-
350 Q_D(const QQuickAnimatedSprite);-
351 return d->m_sprite->frameY();
never executed: return d->m_sprite->frameY();
0
352}-
353-
354qreal QQuickAnimatedSprite::frameRate() const-
355{-
356 Q_D(const QQuickAnimatedSprite);-
357 return d->m_sprite->frameRate();
never executed: return d->m_sprite->frameRate();
0
358}-
359-
360int QQuickAnimatedSprite::frameDuration() const-
361{-
362 Q_D(const QQuickAnimatedSprite);-
363 return d->m_sprite->frameDuration();
never executed: return d->m_sprite->frameDuration();
0
364}-
365-
366int QQuickAnimatedSprite::loops() const-
367{-
368 Q_D(const QQuickAnimatedSprite);-
369 return d->m_loops;
executed 12 times by 1 test: return d->m_loops;
Executed by:
  • tst_qquickanimatedsprite
12
370}-
371-
372bool QQuickAnimatedSprite::paused() const-
373{-
374 Q_D(const QQuickAnimatedSprite);-
375 return d->m_paused;
executed 8 times by 1 test: return d->m_paused;
Executed by:
  • tst_qquickanimatedsprite
8
376}-
377-
378int QQuickAnimatedSprite::currentFrame() const-
379{-
380 Q_D(const QQuickAnimatedSprite);-
381 return d->m_curFrame;
executed 16 times by 1 test: return d->m_curFrame;
Executed by:
  • tst_qquickanimatedsprite
16
382}-
383-
384bool QQuickAnimatedSprite::isCurrentFrameChangedConnected()-
385{-
386 IS_SIGNAL_CONNECTED(this, QQuickAnimatedSprite, currentFrameChanged, (int));
executed 556 times by 1 test: return QObjectPrivate::get(sender)->isSignalConnected(signalIdx);
Executed by:
  • tst_qquickanimatedsprite
556
387}
never executed: end of block
0
388-
389void QQuickAnimatedSprite::reloadImage()-
390{-
391 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
392 return;
executed 46 times by 1 test: return;
Executed by:
  • tst_qquickanimatedsprite
46
393 createEngine();//### It's not as inefficient as it sounds, but it still sucks having to recreate the engine-
394}
executed 6 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
6
395-
396void QQuickAnimatedSprite::componentComplete()-
397{-
398 Q_D(const QQuickAnimatedSprite);-
399 createEngine();-
400 QQuickItem::componentComplete();-
401 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
402 start();
executed 10 times by 1 test: start();
Executed by:
  • tst_qquickanimatedsprite
10
403}
executed 18 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
18
404-
405void QQuickAnimatedSprite::start()-
406{-
407 Q_D(QQuickAnimatedSprite);-
408 d->m_running = true;-
409 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
410 return;
executed 8 times by 1 test: return;
Executed by:
  • tst_qquickanimatedsprite
8
411 d->m_curLoop = 0;-
412 d->m_timestamp.start();-
413 if (d->m_spriteEngine) {
d->m_spriteEngineDescription
TRUEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEnever evaluated
0-18
414 d->m_spriteEngine->stop(0);-
415 d->m_spriteEngine->updateSprites(0);-
416 d->m_spriteEngine->start(0);-
417 }
executed 18 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
18
418 emit currentFrameChanged(0);-
419 emit runningChanged(true);-
420 maybeUpdate();-
421}
executed 18 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
18
422-
423void QQuickAnimatedSprite::stop()-
424{-
425 Q_D(QQuickAnimatedSprite);-
426 d->m_running = false;-
427 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
428 return;
executed 16 times by 1 test: return;
Executed by:
  • tst_qquickanimatedsprite
16
429 d->m_pauseOffset = 0;-
430 emit runningChanged(false);-
431 maybeUpdate();-
432}
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
2
433-
434/*!-
435 \qmlmethod int QtQuick::AnimatedSprite::advance()-
436-
437 Advances the sprite animation by one frame.-
438*/-
439void QQuickAnimatedSprite::advance(int frames)-
440{-
441 Q_D(QQuickAnimatedSprite);-
442 if (!frames)
!framesDescription
TRUEnever evaluated
FALSEnever evaluated
0
443 return;
never executed: return;
0
444 //TODO-C: May not work when running - only when paused-
445 d->m_curFrame += frames;-
446 while (d->m_curFrame < 0)
d->m_curFrame < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
447 d->m_curFrame += d->m_spriteEngine->maxFrames();
never executed: d->m_curFrame += d->m_spriteEngine->maxFrames();
0
448 d->m_curFrame = d->m_curFrame % d->m_spriteEngine->maxFrames();-
449 emit currentFrameChanged(d->m_curFrame);-
450 maybeUpdate();-
451}
never executed: end of block
0
452-
453void QQuickAnimatedSprite::maybeUpdate()-
454{-
455 QQuickItemPrivate *priv = QQuickItemPrivate::get(this);-
456 const QLazilyAllocated<QQuickItemPrivate::ExtraData> &extraData = priv->extra;-
457 if ((extraData.isAllocated() && extraData->effectRefCount > 0) || priv->effectiveVisible)
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 > 0Description
TRUEnever evaluated
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
priv->effectiveVisibleDescription
TRUEevaluated 1585 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEnever evaluated
0-1585
458 update();
executed 1585 times by 1 test: update();
Executed by:
  • tst_qquickanimatedsprite
1585
459}
executed 1585 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
1585
460-
461/*!-
462 \qmlmethod int QtQuick::AnimatedSprite::pause()-
463-
464 Pauses the sprite animation. This does nothing if-
465 \l paused is \c true.-
466-
467 \sa resume()-
468*/-
469void QQuickAnimatedSprite::pause()-
470{-
471 Q_D(QQuickAnimatedSprite);-
472-
473 if (d->m_paused)
d->m_pausedDescription
TRUEnever evaluated
FALSEnever evaluated
0
474 return;
never executed: return;
0
475 d->m_pauseOffset = d->m_timestamp.elapsed();-
476 d->m_paused = true;-
477 emit pausedChanged(true);-
478 maybeUpdate();-
479}
never executed: end of block
0
480-
481/*!-
482 \qmlmethod int QtQuick::AnimatedSprite::resume()-
483-
484 Resumes the sprite animation if \l paused is \c true;-
485 otherwise, this does nothing.-
486-
487 \sa pause()-
488*/-
489void QQuickAnimatedSprite::resume()-
490{-
491 Q_D(QQuickAnimatedSprite);-
492-
493 if (!d->m_paused)
!d->m_pausedDescription
TRUEnever evaluated
FALSEnever evaluated
0
494 return;
never executed: return;
0
495 d->m_pauseOffset = d->m_pauseOffset - d->m_timestamp.elapsed();-
496 d->m_paused = false;-
497 emit pausedChanged(false);-
498 maybeUpdate();-
499}
never executed: end of block
0
500-
501void QQuickAnimatedSprite::setRunning(bool arg)-
502{-
503 Q_D(QQuickAnimatedSprite);-
504-
505 if (d->m_running != arg) {
d->m_running != argDescription
TRUEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEnever evaluated
0-18
506 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
507 stop();
executed 10 times by 1 test: stop();
Executed by:
  • tst_qquickanimatedsprite
10
508 else-
509 start();
executed 8 times by 1 test: start();
Executed by:
  • tst_qquickanimatedsprite
8
510 }-
511}
executed 18 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
18
512-
513void QQuickAnimatedSprite::setPaused(bool arg)-
514{-
515 Q_D(const QQuickAnimatedSprite);-
516-
517 if (d->m_paused != arg) {
d->m_paused != argDescription
TRUEnever evaluated
FALSEnever evaluated
0
518 if (d->m_paused)
d->m_pausedDescription
TRUEnever evaluated
FALSEnever evaluated
0
519 resume();
never executed: resume();
0
520 else-
521 pause();
never executed: pause();
0
522 }-
523}
never executed: end of block
0
524-
525void QQuickAnimatedSprite::setInterpolate(bool arg)-
526{-
527 Q_D(QQuickAnimatedSprite);-
528-
529 if (d->m_interpolate != arg) {
d->m_interpolate != argDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEnever evaluated
0-2
530 d->m_interpolate = arg;-
531 Q_EMIT interpolateChanged(arg);-
532 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
2
533}
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
2
534-
535void QQuickAnimatedSprite::setSource(QUrl arg)-
536{-
537 Q_D(QQuickAnimatedSprite);-
538-
539 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
540 const qreal targetDevicePixelRatio = (window() ? window()->effectiveDevicePixelRatio() : qApp->devicePixelRatio());
window()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
2-18
541 d->m_sprite->setDevicePixelRatio(targetDevicePixelRatio);-
542 d->m_sprite->setSource(arg);-
543 Q_EMIT sourceChanged(arg);-
544 reloadImage();-
545 }
executed 20 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
20
546}
executed 20 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
20
547-
548void QQuickAnimatedSprite::setReverse(bool arg)-
549{-
550 Q_D(QQuickAnimatedSprite);-
551-
552 if (d->m_sprite->m_reverse != arg) {
d->m_sprite->m_reverse != argDescription
TRUEnever evaluated
FALSEnever evaluated
0
553 d->m_sprite->setReverse(arg);-
554 Q_EMIT reverseChanged(arg);-
555 }
never executed: end of block
0
556}
never executed: end of block
0
557-
558void QQuickAnimatedSprite::setFrameSync(bool arg)-
559{-
560 Q_D(QQuickAnimatedSprite);-
561-
562 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
563 d->m_sprite->setFrameSync(arg);-
564 Q_EMIT frameSyncChanged(arg);-
565 if (d->m_running)
d->m_runningDescription
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
0-10
566 restart();
never executed: restart();
0
567 }
executed 10 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
10
568}
executed 12 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
12
569-
570void QQuickAnimatedSprite::setFrameCount(int arg)-
571{-
572 Q_D(QQuickAnimatedSprite);-
573-
574 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
575 d->m_sprite->setFrameCount(arg);-
576 Q_EMIT frameCountChanged(arg);-
577 reloadImage();-
578 }
executed 16 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
16
579}
executed 16 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
16
580-
581void QQuickAnimatedSprite::setFrameHeight(int arg)-
582{-
583 Q_D(QQuickAnimatedSprite);-
584-
585 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
586 d->m_sprite->setFrameHeight(arg);-
587 Q_EMIT frameHeightChanged(arg);-
588 setImplicitHeight(frameHeight());-
589 reloadImage();-
590 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
8
591}
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
8
592-
593void QQuickAnimatedSprite::setFrameWidth(int arg)-
594{-
595 Q_D(QQuickAnimatedSprite);-
596-
597 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
598 d->m_sprite->setFrameWidth(arg);-
599 Q_EMIT frameWidthChanged(arg);-
600 setImplicitWidth(frameWidth());-
601 reloadImage();-
602 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
8
603}
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
8
604-
605void QQuickAnimatedSprite::setFrameX(int arg)-
606{-
607 Q_D(QQuickAnimatedSprite);-
608-
609 if (d->m_sprite->m_frameX != arg) {
d->m_sprite->m_frameX != argDescription
TRUEnever evaluated
FALSEnever evaluated
0
610 d->m_sprite->setFrameX(arg);-
611 Q_EMIT frameXChanged(arg);-
612 reloadImage();-
613 }
never executed: end of block
0
614}
never executed: end of block
0
615-
616void QQuickAnimatedSprite::setFrameY(int arg)-
617{-
618 Q_D(QQuickAnimatedSprite);-
619-
620 if (d->m_sprite->m_frameY != arg) {
d->m_sprite->m_frameY != argDescription
TRUEnever evaluated
FALSEnever evaluated
0
621 d->m_sprite->setFrameY(arg);-
622 Q_EMIT frameYChanged(arg);-
623 reloadImage();-
624 }
never executed: end of block
0
625}
never executed: end of block
0
626-
627void QQuickAnimatedSprite::setFrameRate(qreal arg)-
628{-
629 Q_D(QQuickAnimatedSprite);-
630-
631 if (d->m_sprite->m_frameRate != arg) {
d->m_sprite->m...ameRate != argDescription
TRUEnever evaluated
FALSEnever evaluated
0
632 d->m_sprite->setFrameRate(arg);-
633 Q_EMIT frameRateChanged(arg);-
634 if (d->m_running)
d->m_runningDescription
TRUEnever evaluated
FALSEnever evaluated
0
635 restart();
never executed: restart();
0
636 }
never executed: end of block
0
637}
never executed: end of block
0
638-
639void QQuickAnimatedSprite::setFrameDuration(int arg)-
640{-
641 Q_D(QQuickAnimatedSprite);-
642-
643 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
644 d->m_sprite->setFrameDuration(arg);-
645 Q_EMIT frameDurationChanged(arg);-
646 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
647 restart();
executed 8 times by 1 test: restart();
Executed by:
  • tst_qquickanimatedsprite
8
648 }
executed 10 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
10
649}
executed 10 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
10
650-
651void QQuickAnimatedSprite::resetFrameRate()-
652{-
653 setFrameRate(-1.0);-
654}
never executed: end of block
0
655-
656void QQuickAnimatedSprite::resetFrameDuration()-
657{-
658 setFrameDuration(-1);-
659}
never executed: end of block
0
660-
661void QQuickAnimatedSprite::setLoops(int arg)-
662{-
663 Q_D(QQuickAnimatedSprite);-
664-
665 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
666 d->m_loops = arg;-
667 Q_EMIT loopsChanged(arg);-
668 }
executed 14 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
14
669}
executed 16 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
16
670-
671void QQuickAnimatedSprite::setCurrentFrame(int arg) //TODO-C: Probably only works when paused-
672{-
673 Q_D(QQuickAnimatedSprite);-
674-
675 if (d->m_curFrame != arg) {
d->m_curFrame != argDescription
TRUEnever evaluated
FALSEnever evaluated
0
676 d->m_curFrame = arg;-
677 Q_EMIT currentFrameChanged(arg); //TODO-C Only emitted on manual advance!-
678 update();-
679 }
never executed: end of block
0
680}
never executed: end of block
0
681-
682void QQuickAnimatedSprite::createEngine()-
683{-
684 Q_D(QQuickAnimatedSprite);-
685-
686 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
687 delete d->m_spriteEngine;
executed 6 times by 1 test: delete d->m_spriteEngine;
Executed by:
  • tst_qquickanimatedsprite
6
688 QList<QQuickSprite*> spriteList;-
689 spriteList << d->m_sprite;-
690 d->m_spriteEngine = new QQuickSpriteEngine(QList<QQuickSprite*>(spriteList), this);-
691 d->m_spriteEngine->startAssemblingImage();-
692 reset();-
693}
executed 24 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
24
694-
695QSGSpriteNode* QQuickAnimatedSprite::initNode()-
696{-
697 Q_D(QQuickAnimatedSprite);-
698-
699 if (!d->m_spriteEngine) {
!d->m_spriteEngineDescription
TRUEnever evaluated
FALSEevaluated 30 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
0-30
700 qmlWarning(this) << "No sprite engine...";-
701 return nullptr;
never executed: return nullptr;
0
702 } 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
703 d->m_spriteEngine->startAssemblingImage();-
704 maybeUpdate();//Schedule another update, where we will check again-
705 return nullptr;
executed 2 times by 1 test: return nullptr;
Executed by:
  • tst_qquickanimatedsprite
2
706 } 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
707 maybeUpdate();//Schedule another update, where we will check again-
708 return nullptr;
never executed: return nullptr;
0
709 }-
710-
711 QImage image = d->m_spriteEngine->assembledImage(d->sceneGraphRenderContext()->maxTextureSize()); //Engine prints errors if there are any-
712 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
713 return nullptr;
executed 10 times by 1 test: return nullptr;
Executed by:
  • tst_qquickanimatedsprite
10
714-
715 // If frameWidth or frameHeight are not explicitly set, frameWidth-
716 // will be set to the width of the image divided by the number of frames,-
717 // and frameHeight will be set to the height of the image.-
718 // In this case, QQuickAnimatedSprite currently won't emit frameWidth/HeightChanged-
719 // at all, so we have to do this here, as it's the only place where assembledImage()-
720 // is called (which calculates the "implicit" frameWidth/Height.-
721 // In addition, currently the "implicit" frameWidth/Height are only calculated once,-
722 // even after changing to a different source.-
723 setImplicitWidth(frameWidth());-
724 setImplicitHeight(frameHeight());-
725-
726 QSGSpriteNode *node = d->sceneGraphContext()->createSpriteNode();-
727-
728 d->m_sheetSize = QSize(image.size() / image.devicePixelRatioF());-
729 node->setTexture(window()->createTextureFromImage(image));-
730 d->m_spriteEngine->start(0);-
731 node->setTime(0.0f);-
732 node->setSourceA(QPoint(d->m_spriteEngine->spriteX(), d->m_spriteEngine->spriteY()));-
733 node->setSourceB(QPoint(d->m_spriteEngine->spriteX(), d->m_spriteEngine->spriteY()));-
734 node->setSpriteSize(QSize(d->m_spriteEngine->spriteWidth(), d->m_spriteEngine->spriteHeight()));-
735 node->setSheetSize(d->m_sheetSize);-
736 node->setSize(QSizeF(width(), height()));-
737 return node;
executed 18 times by 1 test: return node;
Executed by:
  • tst_qquickanimatedsprite
18
738}-
739-
740void QQuickAnimatedSprite::reset()-
741{-
742 Q_D(QQuickAnimatedSprite);-
743 d->m_pleaseReset = true;-
744 maybeUpdate();-
745}
executed 60 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
60
746-
747QSGNode *QQuickAnimatedSprite::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)-
748{-
749 Q_D(QQuickAnimatedSprite);-
750-
751 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
752 delete oldNode;-
753-
754 oldNode = nullptr;-
755 d->m_pleaseReset = false;-
756 }
executed 20 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
20
757-
758 QSGSpriteNode *node = static_cast<QSGSpriteNode *>(oldNode);-
759 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
760 node = initNode();
executed 30 times by 1 test: node = initNode();
Executed by:
  • tst_qquickanimatedsprite
30
761-
762 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
763 prepareNextFrame(node);
executed 949 times by 1 test: prepareNextFrame(node);
Executed by:
  • tst_qquickanimatedsprite
949
764-
765 if (d->m_running && !d->m_paused)
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_pausedDescription
TRUEevaluated 939 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEnever evaluated
0-939
766 maybeUpdate();
executed 939 times by 1 test: maybeUpdate();
Executed by:
  • tst_qquickanimatedsprite
939
767-
768 return node;
executed 961 times by 1 test: return node;
Executed by:
  • tst_qquickanimatedsprite
961
769}-
770-
771void QQuickAnimatedSprite::prepareNextFrame(QSGSpriteNode *node)-
772{-
773 Q_D(QQuickAnimatedSprite);-
774-
775 int timeInt = d->m_timestamp.elapsed() + d->m_pauseOffset;-
776 qreal time = timeInt / 1000.;-
777-
778 int frameAt;-
779 qreal progress = 0.0;-
780 int lastFrame = d->m_curFrame;-
781 if (d->m_running && !d->m_paused) {
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_pausedDescription
TRUEevaluated 935 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEnever evaluated
0-935
782 const int nColumns = d->m_sheetSize.width() / d->m_spriteEngine->spriteWidth();-
783 //Advance State (keeps time for psuedostates)-
784 d->m_spriteEngine->updateSprites(timeInt);-
785-
786 //Advance AnimatedSprite-
787 qreal animT = d->m_spriteEngine->spriteStart()/1000.0;-
788 const int frameCountInRow = d->m_spriteEngine->spriteFrames();-
789 const qreal frameDuration = d->m_spriteEngine->spriteDuration() / frameCountInRow;-
790 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
791 qreal frame = (time - animT)/(frameDuration / 1000.0);-
792 bool lastLoop = d->m_loops > 0 && d->m_curLoop == d->m_loops-1;
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-1Description
TRUEevaluated 187 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 399 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
37-586
793 //don't visually interpolate for the last frame of the last loop-
794 const int max = lastLoop ? frameCountInRow - 1 : frameCountInRow;
lastLoopDescription
TRUEevaluated 187 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 436 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
187-436
795 frame = qBound(qreal(0.0), frame, qreal(max));-
796 double intpart;-
797 progress = std::modf(frame,&intpart);-
798 frameAt = (int)intpart;-
799 const int rowIndex = d->m_spriteEngine->spriteY()/frameHeight();-
800 const int newFrame = rowIndex * nColumns + frameAt;-
801 if (d->m_curFrame > newFrame) //went around
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
802 d->m_curLoop++;
executed 6 times by 1 test: d->m_curLoop++;
Executed by:
  • tst_qquickanimatedsprite
6
803 d->m_curFrame = newFrame;-
804 } else {
executed 623 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
623
805 d->m_curFrame++;-
806 if (d->m_curFrame >= d->m_spriteEngine->maxFrames()) { // maxFrames: total number of frames including all rows
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
807 d->m_curFrame = 0;-
808 d->m_curLoop++;-
809 }
executed 18 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
18
810 frameAt = d->m_curFrame % nColumns;-
811 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
812 d->m_spriteEngine->advance();
executed 30 times by 1 test: d->m_spriteEngine->advance();
Executed by:
  • tst_qquickanimatedsprite
30
813 progress = 0;-
814 }
executed 312 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
312
815 if (d->m_loops > 0 && d->m_curLoop >= d->m_loops) {
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_loopsDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEevaluated 890 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
8-898
816 frameAt = 0;-
817 d->m_running = false;-
818 emit runningChanged(false);-
819 emit finished();-
820 maybeUpdate();-
821 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
8
822 } else {
executed 935 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
935
823 frameAt = d->m_curFrame;-
824 }
executed 14 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
14
825 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
826 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
827 emit currentFrameChanged(d->m_curFrame);
executed 516 times by 1 test: currentFrameChanged(d->m_curFrame);
Executed by:
  • tst_qquickanimatedsprite
516
828 maybeUpdate();-
829 }
executed 556 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
556
830-
831 qreal frameCount = d->m_spriteEngine->spriteFrames();-
832 bool reverse = d->m_spriteEngine->sprite()->reverse();-
833 if (reverse)
reverseDescription
TRUEnever evaluated
FALSEevaluated 949 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
0-949
834 frameAt = (frameCount - 1) - frameAt;
never executed: frameAt = (frameCount - 1) - frameAt;
0
835-
836 int w = d->m_spriteEngine->spriteWidth();-
837 int h = d->m_spriteEngine->spriteHeight();-
838 int x1;-
839 int y1;-
840 if (d->m_paused) {
d->m_pausedDescription
TRUEnever evaluated
FALSEevaluated 949 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
0-949
841 int spriteY = d->m_spriteEngine->spriteY();-
842 if (reverse) {
reverseDescription
TRUEnever evaluated
FALSEnever evaluated
0
843 int rows = d->m_spriteEngine->maxFrames() * d->m_spriteEngine->spriteWidth() / d->m_sheetSize.width();-
844 spriteY -= rows * d->m_spriteEngine->spriteHeight();-
845 frameAt = (frameCount - 1) - frameAt;-
846 }
never executed: end of block
0
847-
848 int position = frameAt * d->m_spriteEngine->spriteWidth() + d->m_spriteEngine->spriteX();-
849 int row = position / d->m_sheetSize.width();-
850-
851 x1 = (position - (row * d->m_sheetSize.width()));-
852 y1 = (row * d->m_spriteEngine->spriteHeight() + spriteY);-
853 } else {
never executed: end of block
0
854 x1 = d->m_spriteEngine->spriteX() + frameAt * w;-
855 y1 = d->m_spriteEngine->spriteY();-
856 }
executed 949 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
949
857-
858 //### hard-coded 0/1 work because we are the only-
859 // images in the sprite sheet (without this we cannot assume-
860 // where in the sheet we begin/end).-
861 int x2;-
862 int y2;-
863 if (reverse) {
reverseDescription
TRUEnever evaluated
FALSEevaluated 949 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
0-949
864 if (frameAt > 0) {
frameAt > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
865 x2 = x1 - w;-
866 y2 = y1;-
867 } else {
never executed: end of block
0
868 x2 = 1.0 - w;-
869 y2 = y1 - h;-
870 if (y2 < 0.0) {
y2 < 0.0Description
TRUEnever evaluated
FALSEnever evaluated
0
871 //the last row may not fill the entire width-
872 int maxRowFrames = d->m_sheetSize.width() / d->m_spriteEngine->spriteWidth();-
873 if (d->m_spriteEngine->maxFrames() % maxRowFrames)
d->m_spriteEng...% maxRowFramesDescription
TRUEnever evaluated
FALSEnever evaluated
0
874 x2 = ((d->m_spriteEngine->maxFrames() % maxRowFrames) - 1) * w;
never executed: x2 = ((d->m_spriteEngine->maxFrames() % maxRowFrames) - 1) * w;
0
875-
876 y2 = 1.0 - h;-
877 }
never executed: end of block
0
878 }
never executed: end of block
0
879 } else {-
880 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
881 x2 = x1 + w;-
882 y2 = y1;-
883 } else {
executed 863 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
863
884 x2 = 0.0;-
885 y2 = y1 + h;-
886 if (y2 >= 1.0)
y2 >= 1.0Description
TRUEevaluated 86 times by 1 test
Evaluated by:
  • tst_qquickanimatedsprite
FALSEnever evaluated
0-86
887 y2 = 0.0;
executed 86 times by 1 test: y2 = 0.0;
Executed by:
  • tst_qquickanimatedsprite
86
888 }
executed 86 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
86
889 }-
890-
891 node->setSourceA(QPoint(x1, y1));-
892 node->setSourceB(QPoint(x2, y2));-
893 node->setSpriteSize(QSize(w, h));-
894 node->setTime(d->m_interpolate ? progress : 0.0);-
895 node->setSize(QSizeF(width(), height()));-
896 node->setFiltering(smooth() ? QSGTexture::Linear : QSGTexture::Nearest);-
897 node->update();-
898}
executed 949 times by 1 test: end of block
Executed by:
  • tst_qquickanimatedsprite
949
899-
900QT_END_NAMESPACE-
901-
902#include "moc_qquickanimatedsprite_p.cpp"-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0