Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickanimatedsprite.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||
2 | - | |||||||||||||||||||
3 | - | |||||||||||||||||||
4 | QQuickAnimatedSprite::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:
| 18 | ||||||||||||||||||
16 | - | |||||||||||||||||||
17 | bool QQuickAnimatedSprite::running() const | - | ||||||||||||||||||
18 | { | - | ||||||||||||||||||
19 | const QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
20 | return executed 288 times by 1 test: d->m_running;return d->m_running; Executed by:
executed 288 times by 1 test: return d->m_running; Executed by:
| 288 | ||||||||||||||||||
21 | } | - | ||||||||||||||||||
22 | - | |||||||||||||||||||
23 | bool QQuickAnimatedSprite::interpolate() const | - | ||||||||||||||||||
24 | { | - | ||||||||||||||||||
25 | const QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
26 | return executed 4 times by 1 test: d->m_interpolate;return d->m_interpolate; Executed by:
executed 4 times by 1 test: return d->m_interpolate; Executed by:
| 4 | ||||||||||||||||||
27 | } | - | ||||||||||||||||||
28 | - | |||||||||||||||||||
29 | QUrl QQuickAnimatedSprite::source() const | - | ||||||||||||||||||
30 | { | - | ||||||||||||||||||
31 | const QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
32 | return never executed: d->m_sprite->source();return d->m_sprite->source(); never executed: return d->m_sprite->source(); | 0 | ||||||||||||||||||
33 | } | - | ||||||||||||||||||
34 | - | |||||||||||||||||||
35 | bool QQuickAnimatedSprite::reverse() const | - | ||||||||||||||||||
36 | { | - | ||||||||||||||||||
37 | const QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
38 | return never executed: d->m_sprite->reverse();return d->m_sprite->reverse(); never executed: return d->m_sprite->reverse(); | 0 | ||||||||||||||||||
39 | } | - | ||||||||||||||||||
40 | - | |||||||||||||||||||
41 | bool QQuickAnimatedSprite::frameSync() const | - | ||||||||||||||||||
42 | { | - | ||||||||||||||||||
43 | const QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
44 | return never executed: d->m_sprite->frameSync();return d->m_sprite->frameSync(); never executed: return d->m_sprite->frameSync(); | 0 | ||||||||||||||||||
45 | } | - | ||||||||||||||||||
46 | - | |||||||||||||||||||
47 | int QQuickAnimatedSprite::frameCount() const | - | ||||||||||||||||||
48 | { | - | ||||||||||||||||||
49 | const QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
50 | return executed 6 times by 1 test: d->m_sprite->frames();return d->m_sprite->frames(); Executed by:
executed 6 times by 1 test: return d->m_sprite->frames(); Executed by:
| 6 | ||||||||||||||||||
51 | } | - | ||||||||||||||||||
52 | - | |||||||||||||||||||
53 | int QQuickAnimatedSprite::frameHeight() const | - | ||||||||||||||||||
54 | { | - | ||||||||||||||||||
55 | const QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
56 | return executed 651 times by 1 test: d->m_sprite->frameHeight();return d->m_sprite->frameHeight(); Executed by:
executed 651 times by 1 test: return d->m_sprite->frameHeight(); Executed by:
| 651 | ||||||||||||||||||
57 | } | - | ||||||||||||||||||
58 | - | |||||||||||||||||||
59 | int QQuickAnimatedSprite::frameWidth() const | - | ||||||||||||||||||
60 | { | - | ||||||||||||||||||
61 | const QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
62 | return executed 28 times by 1 test: d->m_sprite->frameWidth();return d->m_sprite->frameWidth(); Executed by:
executed 28 times by 1 test: return d->m_sprite->frameWidth(); Executed by:
| 28 | ||||||||||||||||||
63 | } | - | ||||||||||||||||||
64 | - | |||||||||||||||||||
65 | int QQuickAnimatedSprite::frameX() const | - | ||||||||||||||||||
66 | { | - | ||||||||||||||||||
67 | const QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
68 | return never executed: d->m_sprite->frameX();return d->m_sprite->frameX(); never executed: return d->m_sprite->frameX(); | 0 | ||||||||||||||||||
69 | } | - | ||||||||||||||||||
70 | - | |||||||||||||||||||
71 | int QQuickAnimatedSprite::frameY() const | - | ||||||||||||||||||
72 | { | - | ||||||||||||||||||
73 | const QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
74 | return never executed: d->m_sprite->frameY();return d->m_sprite->frameY(); never executed: return d->m_sprite->frameY(); | 0 | ||||||||||||||||||
75 | } | - | ||||||||||||||||||
76 | - | |||||||||||||||||||
77 | qreal QQuickAnimatedSprite::frameRate() const | - | ||||||||||||||||||
78 | { | - | ||||||||||||||||||
79 | const QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
80 | return never executed: d->m_sprite->frameRate();return d->m_sprite->frameRate(); never executed: return d->m_sprite->frameRate(); | 0 | ||||||||||||||||||
81 | } | - | ||||||||||||||||||
82 | - | |||||||||||||||||||
83 | int QQuickAnimatedSprite::frameDuration() const | - | ||||||||||||||||||
84 | { | - | ||||||||||||||||||
85 | const QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
86 | return never executed: d->m_sprite->frameDuration();return d->m_sprite->frameDuration(); never executed: return d->m_sprite->frameDuration(); | 0 | ||||||||||||||||||
87 | } | - | ||||||||||||||||||
88 | - | |||||||||||||||||||
89 | int QQuickAnimatedSprite::loops() const | - | ||||||||||||||||||
90 | { | - | ||||||||||||||||||
91 | const QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
92 | return executed 12 times by 1 test: d->m_loops;return d->m_loops; Executed by:
executed 12 times by 1 test: return d->m_loops; Executed by:
| 12 | ||||||||||||||||||
93 | } | - | ||||||||||||||||||
94 | - | |||||||||||||||||||
95 | bool QQuickAnimatedSprite::paused() const | - | ||||||||||||||||||
96 | { | - | ||||||||||||||||||
97 | const QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
98 | return executed 8 times by 1 test: d->m_paused;return d->m_paused; Executed by:
executed 8 times by 1 test: return d->m_paused; Executed by:
| 8 | ||||||||||||||||||
99 | } | - | ||||||||||||||||||
100 | - | |||||||||||||||||||
101 | int QQuickAnimatedSprite::currentFrame() const | - | ||||||||||||||||||
102 | { | - | ||||||||||||||||||
103 | const QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
104 | return executed 16 times by 1 test: d->m_curFrame;return d->m_curFrame; Executed by:
executed 16 times by 1 test: return d->m_curFrame; Executed by:
| 16 | ||||||||||||||||||
105 | } | - | ||||||||||||||||||
106 | - | |||||||||||||||||||
107 | bool 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: QObjectPrivate::get(sender)->isSignalConnected(signalIdx);return QObjectPrivate::get(sender)->isSignalConnected(signalIdx); Executed by:
executed 556 times by 1 test: } while (0);return QObjectPrivate::get(sender)->isSignalConnected(signalIdx); Executed by:
| 556 | ||||||||||||||||||
110 | } never executed: end of block | 0 | ||||||||||||||||||
111 | - | |||||||||||||||||||
112 | void QQuickAnimatedSprite::reloadImage() | - | ||||||||||||||||||
113 | { | - | ||||||||||||||||||
114 | if (!isComponentComplete()
| 6-46 | ||||||||||||||||||
115 | return; executed 46 times by 1 test: return; Executed by:
| 46 | ||||||||||||||||||
116 | createEngine(); | - | ||||||||||||||||||
117 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||
118 | - | |||||||||||||||||||
119 | void QQuickAnimatedSprite::componentComplete() | - | ||||||||||||||||||
120 | { | - | ||||||||||||||||||
121 | const QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
122 | createEngine(); | - | ||||||||||||||||||
123 | QQuickItem::componentComplete(); | - | ||||||||||||||||||
124 | if (d->m_running
| 8-10 | ||||||||||||||||||
125 | start(); executed 10 times by 1 test: start(); Executed by:
| 10 | ||||||||||||||||||
126 | } executed 18 times by 1 test: end of block Executed by:
| 18 | ||||||||||||||||||
127 | - | |||||||||||||||||||
128 | void QQuickAnimatedSprite::start() | - | ||||||||||||||||||
129 | { | - | ||||||||||||||||||
130 | QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
131 | d->m_running = true; | - | ||||||||||||||||||
132 | if (!isComponentComplete()
| 8-18 | ||||||||||||||||||
133 | return; executed 8 times by 1 test: return; Executed by:
| 8 | ||||||||||||||||||
134 | d->m_curLoop = 0; | - | ||||||||||||||||||
135 | d->m_timestamp.start(); | - | ||||||||||||||||||
136 | if (d->m_spriteEngine
| 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:
| 18 | ||||||||||||||||||
141 | currentFrameChanged(0); | - | ||||||||||||||||||
142 | runningChanged(true); | - | ||||||||||||||||||
143 | maybeUpdate(); | - | ||||||||||||||||||
144 | } executed 18 times by 1 test: end of block Executed by:
| 18 | ||||||||||||||||||
145 | - | |||||||||||||||||||
146 | void QQuickAnimatedSprite::stop() | - | ||||||||||||||||||
147 | { | - | ||||||||||||||||||
148 | QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
149 | d->m_running = false; | - | ||||||||||||||||||
150 | if (!isComponentComplete()
| 2-16 | ||||||||||||||||||
151 | return; executed 16 times by 1 test: return; Executed by:
| 16 | ||||||||||||||||||
152 | d->m_pauseOffset = 0; | - | ||||||||||||||||||
153 | runningChanged(false); | - | ||||||||||||||||||
154 | maybeUpdate(); | - | ||||||||||||||||||
155 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
156 | - | |||||||||||||||||||
157 | - | |||||||||||||||||||
158 | - | |||||||||||||||||||
159 | - | |||||||||||||||||||
160 | - | |||||||||||||||||||
161 | - | |||||||||||||||||||
162 | void QQuickAnimatedSprite::advance(int frames) | - | ||||||||||||||||||
163 | { | - | ||||||||||||||||||
164 | QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
165 | if (!frames
| 0 | ||||||||||||||||||
166 | return; never executed: return; | 0 | ||||||||||||||||||
167 | - | |||||||||||||||||||
168 | d->m_curFrame += frames; | - | ||||||||||||||||||
169 | while (d->m_curFrame < 0
| 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 | - | |||||||||||||||||||
176 | void QQuickAnimatedSprite::maybeUpdate() | - | ||||||||||||||||||
177 | { | - | ||||||||||||||||||
178 | QQuickItemPrivate *priv = QQuickItemPrivate::get(this); | - | ||||||||||||||||||
179 | const QLazilyAllocated<QQuickItemPrivate::ExtraData> &extraData = priv->extra; | - | ||||||||||||||||||
180 | if ((extraData.isAllocated()
| 0-1585 | ||||||||||||||||||
181 | update(); executed 1585 times by 1 test: update(); Executed by:
| 1585 | ||||||||||||||||||
182 | } executed 1585 times by 1 test: end of block Executed by:
| 1585 | ||||||||||||||||||
183 | void QQuickAnimatedSprite::pause() | - | ||||||||||||||||||
184 | { | - | ||||||||||||||||||
185 | QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
186 | - | |||||||||||||||||||
187 | if (d->m_paused
| 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 | ||||||||||||||||||
194 | void QQuickAnimatedSprite::resume() | - | ||||||||||||||||||
195 | { | - | ||||||||||||||||||
196 | QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
197 | - | |||||||||||||||||||
198 | if (!d->m_paused
| 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 | - | |||||||||||||||||||
206 | void QQuickAnimatedSprite::setRunning(bool arg) | - | ||||||||||||||||||
207 | { | - | ||||||||||||||||||
208 | QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
209 | - | |||||||||||||||||||
210 | if (d->m_running != arg
| 0-18 | ||||||||||||||||||
211 | if (d->m_running
| 8-10 | ||||||||||||||||||
212 | stop(); executed 10 times by 1 test: stop(); Executed by:
| 10 | ||||||||||||||||||
213 | else | - | ||||||||||||||||||
214 | start(); executed 8 times by 1 test: start(); Executed by:
| 8 | ||||||||||||||||||
215 | } | - | ||||||||||||||||||
216 | } executed 18 times by 1 test: end of block Executed by:
| 18 | ||||||||||||||||||
217 | - | |||||||||||||||||||
218 | void QQuickAnimatedSprite::setPaused(bool arg) | - | ||||||||||||||||||
219 | { | - | ||||||||||||||||||
220 | const QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
221 | - | |||||||||||||||||||
222 | if (d->m_paused != arg
| 0 | ||||||||||||||||||
223 | if (d->m_paused
| 0 | ||||||||||||||||||
224 | resume(); never executed: resume(); | 0 | ||||||||||||||||||
225 | else | - | ||||||||||||||||||
226 | pause(); never executed: pause(); | 0 | ||||||||||||||||||
227 | } | - | ||||||||||||||||||
228 | } never executed: end of block | 0 | ||||||||||||||||||
229 | - | |||||||||||||||||||
230 | void QQuickAnimatedSprite::setInterpolate(bool arg) | - | ||||||||||||||||||
231 | { | - | ||||||||||||||||||
232 | QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
233 | - | |||||||||||||||||||
234 | if (d->m_interpolate != arg
| 0-2 | ||||||||||||||||||
235 | d->m_interpolate = arg; | - | ||||||||||||||||||
236 | interpolateChanged(arg); | - | ||||||||||||||||||
237 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
238 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
239 | - | |||||||||||||||||||
240 | void QQuickAnimatedSprite::setSource(QUrl arg) | - | ||||||||||||||||||
241 | { | - | ||||||||||||||||||
242 | QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
243 | - | |||||||||||||||||||
244 | if (d->m_sprite->m_source != arg
| 0-20 | ||||||||||||||||||
245 | const qreal targetDevicePixelRatio = (window()
| 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:
| 20 | ||||||||||||||||||
251 | } executed 20 times by 1 test: end of block Executed by:
| 20 | ||||||||||||||||||
252 | - | |||||||||||||||||||
253 | void QQuickAnimatedSprite::setReverse(bool arg) | - | ||||||||||||||||||
254 | { | - | ||||||||||||||||||
255 | QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
256 | - | |||||||||||||||||||
257 | if (d->m_sprite->m_reverse != arg
| 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 | - | |||||||||||||||||||
263 | void QQuickAnimatedSprite::setFrameSync(bool arg) | - | ||||||||||||||||||
264 | { | - | ||||||||||||||||||
265 | QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
266 | - | |||||||||||||||||||
267 | if (d->m_sprite->m_frameSync != arg
| 2-10 | ||||||||||||||||||
268 | d->m_sprite->setFrameSync(arg); | - | ||||||||||||||||||
269 | frameSyncChanged(arg); | - | ||||||||||||||||||
270 | if (d->m_running
| 0-10 | ||||||||||||||||||
271 | restart(); never executed: restart(); | 0 | ||||||||||||||||||
272 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||
273 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||
274 | - | |||||||||||||||||||
275 | void QQuickAnimatedSprite::setFrameCount(int arg) | - | ||||||||||||||||||
276 | { | - | ||||||||||||||||||
277 | QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
278 | - | |||||||||||||||||||
279 | if (d->m_sprite->m_frames != arg
| 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:
| 16 | ||||||||||||||||||
284 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||||||||
285 | - | |||||||||||||||||||
286 | void QQuickAnimatedSprite::setFrameHeight(int arg) | - | ||||||||||||||||||
287 | { | - | ||||||||||||||||||
288 | QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
289 | - | |||||||||||||||||||
290 | if (d->m_sprite->m_frameHeight != arg
| 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:
| 8 | ||||||||||||||||||
296 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||
297 | - | |||||||||||||||||||
298 | void QQuickAnimatedSprite::setFrameWidth(int arg) | - | ||||||||||||||||||
299 | { | - | ||||||||||||||||||
300 | QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
301 | - | |||||||||||||||||||
302 | if (d->m_sprite->m_frameWidth != arg
| 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:
| 8 | ||||||||||||||||||
308 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||
309 | - | |||||||||||||||||||
310 | void QQuickAnimatedSprite::setFrameX(int arg) | - | ||||||||||||||||||
311 | { | - | ||||||||||||||||||
312 | QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
313 | - | |||||||||||||||||||
314 | if (d->m_sprite->m_frameX != arg
| 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 | - | |||||||||||||||||||
321 | void QQuickAnimatedSprite::setFrameY(int arg) | - | ||||||||||||||||||
322 | { | - | ||||||||||||||||||
323 | QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
324 | - | |||||||||||||||||||
325 | if (d->m_sprite->m_frameY != arg
| 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 | - | |||||||||||||||||||
332 | void QQuickAnimatedSprite::setFrameRate(qreal arg) | - | ||||||||||||||||||
333 | { | - | ||||||||||||||||||
334 | QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
335 | - | |||||||||||||||||||
336 | if (d->m_sprite->m_frameRate != arg
| 0 | ||||||||||||||||||
337 | d->m_sprite->setFrameRate(arg); | - | ||||||||||||||||||
338 | frameRateChanged(arg); | - | ||||||||||||||||||
339 | if (d->m_running
| 0 | ||||||||||||||||||
340 | restart(); never executed: restart(); | 0 | ||||||||||||||||||
341 | } never executed: end of block | 0 | ||||||||||||||||||
342 | } never executed: end of block | 0 | ||||||||||||||||||
343 | - | |||||||||||||||||||
344 | void QQuickAnimatedSprite::setFrameDuration(int arg) | - | ||||||||||||||||||
345 | { | - | ||||||||||||||||||
346 | QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
347 | - | |||||||||||||||||||
348 | if (d->m_sprite->m_frameDuration != arg
| 0-10 | ||||||||||||||||||
349 | d->m_sprite->setFrameDuration(arg); | - | ||||||||||||||||||
350 | frameDurationChanged(arg); | - | ||||||||||||||||||
351 | if (d->m_running
| 2-8 | ||||||||||||||||||
352 | restart(); executed 8 times by 1 test: restart(); Executed by:
| 8 | ||||||||||||||||||
353 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||
354 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||
355 | - | |||||||||||||||||||
356 | void QQuickAnimatedSprite::resetFrameRate() | - | ||||||||||||||||||
357 | { | - | ||||||||||||||||||
358 | setFrameRate(-1.0); | - | ||||||||||||||||||
359 | } never executed: end of block | 0 | ||||||||||||||||||
360 | - | |||||||||||||||||||
361 | void QQuickAnimatedSprite::resetFrameDuration() | - | ||||||||||||||||||
362 | { | - | ||||||||||||||||||
363 | setFrameDuration(-1); | - | ||||||||||||||||||
364 | } never executed: end of block | 0 | ||||||||||||||||||
365 | - | |||||||||||||||||||
366 | void QQuickAnimatedSprite::setLoops(int arg) | - | ||||||||||||||||||
367 | { | - | ||||||||||||||||||
368 | QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
369 | - | |||||||||||||||||||
370 | if (d->m_loops != arg
| 2-14 | ||||||||||||||||||
371 | d->m_loops = arg; | - | ||||||||||||||||||
372 | loopsChanged(arg); | - | ||||||||||||||||||
373 | } executed 14 times by 1 test: end of block Executed by:
| 14 | ||||||||||||||||||
374 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||||||||
375 | - | |||||||||||||||||||
376 | void QQuickAnimatedSprite::setCurrentFrame(int arg) | - | ||||||||||||||||||
377 | { | - | ||||||||||||||||||
378 | QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
379 | - | |||||||||||||||||||
380 | if (d->m_curFrame != arg
| 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 | - | |||||||||||||||||||
387 | void QQuickAnimatedSprite::createEngine() | - | ||||||||||||||||||
388 | { | - | ||||||||||||||||||
389 | QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
390 | - | |||||||||||||||||||
391 | if (d->m_spriteEngine
| 6-18 | ||||||||||||||||||
392 | delete d->m_spriteEngine; executed 6 times by 1 test: delete d->m_spriteEngine; Executed by:
| 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:
| 24 | ||||||||||||||||||
399 | - | |||||||||||||||||||
400 | QSGSpriteNode* QQuickAnimatedSprite::initNode() | - | ||||||||||||||||||
401 | { | - | ||||||||||||||||||
402 | QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
403 | - | |||||||||||||||||||
404 | if (!d->m_spriteEngine
| 0-30 | ||||||||||||||||||
405 | qmlWarning(this) << "No sprite engine..."; | - | ||||||||||||||||||
406 | return never executed: nullptr;return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||
407 | } else if (d->m_spriteEngine->status() == QQuickPixmap::Null
| 2-28 | ||||||||||||||||||
408 | d->m_spriteEngine->startAssemblingImage(); | - | ||||||||||||||||||
409 | maybeUpdate(); | - | ||||||||||||||||||
410 | return executed 2 times by 1 test: nullptr;return nullptr; Executed by:
executed 2 times by 1 test: return nullptr; Executed by:
| 2 | ||||||||||||||||||
411 | } else if (d->m_spriteEngine->status() == QQuickPixmap::Loading
| 0-28 | ||||||||||||||||||
412 | maybeUpdate(); | - | ||||||||||||||||||
413 | return never executed: nullptr;return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||
414 | } | - | ||||||||||||||||||
415 | - | |||||||||||||||||||
416 | QImage image = d->m_spriteEngine->assembledImage(d->sceneGraphRenderContext()->maxTextureSize()); | - | ||||||||||||||||||
417 | if (image.isNull()
| 10-18 | ||||||||||||||||||
418 | return executed 10 times by 1 test: nullptr;return nullptr; Executed by:
executed 10 times by 1 test: return nullptr; Executed by:
| 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: node;return node; Executed by:
executed 18 times by 1 test: return node; Executed by:
| 18 | ||||||||||||||||||
434 | } | - | ||||||||||||||||||
435 | - | |||||||||||||||||||
436 | void 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:
| 60 | ||||||||||||||||||
442 | - | |||||||||||||||||||
443 | QSGNode *QQuickAnimatedSprite::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) | - | ||||||||||||||||||
444 | { | - | ||||||||||||||||||
445 | QQuickAnimatedSpritePrivate * const d = d_func(); | - | ||||||||||||||||||
446 | - | |||||||||||||||||||
447 | if (d->m_pleaseReset
| 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:
| 20 | ||||||||||||||||||
453 | - | |||||||||||||||||||
454 | QSGSpriteNode *node = static_cast<QSGSpriteNode *>(oldNode); | - | ||||||||||||||||||
455 | if (!node
| 30-931 | ||||||||||||||||||
456 | node = initNode(); executed 30 times by 1 test: node = initNode(); Executed by:
| 30 | ||||||||||||||||||
457 | - | |||||||||||||||||||
458 | if (node
| 12-949 | ||||||||||||||||||
459 | prepareNextFrame(node); executed 949 times by 1 test: prepareNextFrame(node); Executed by:
| 949 | ||||||||||||||||||
460 | - | |||||||||||||||||||
461 | if (d->m_running
| 0-939 | ||||||||||||||||||
462 | maybeUpdate(); executed 939 times by 1 test: maybeUpdate(); Executed by:
| 939 | ||||||||||||||||||
463 | - | |||||||||||||||||||
464 | return executed 961 times by 1 test: node;return node; Executed by:
executed 961 times by 1 test: return node; Executed by:
| 961 | ||||||||||||||||||
465 | } | - | ||||||||||||||||||
466 | - | |||||||||||||||||||
467 | void 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
| 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
| 312-623 | ||||||||||||||||||
487 | qreal frame = (time - animT)/(frameDuration / 1000.0); | - | ||||||||||||||||||
488 | bool lastLoop = d->m_loops > 0
| 37-586 | ||||||||||||||||||
489 | - | |||||||||||||||||||
490 | const int max = lastLoop
| 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
| 6-617 | ||||||||||||||||||
498 | d->m_curLoop++; executed 6 times by 1 test: d->m_curLoop++; Executed by:
| 6 | ||||||||||||||||||
499 | d->m_curFrame = newFrame; | - | ||||||||||||||||||
500 | } executed 623 times by 1 test: else {end of block Executed by:
| 623 | ||||||||||||||||||
501 | d->m_curFrame++; | - | ||||||||||||||||||
502 | if (d->m_curFrame >= d->m_spriteEngine->maxFrames()
| 18-294 | ||||||||||||||||||
503 | d->m_curFrame = 0; | - | ||||||||||||||||||
504 | d->m_curLoop++; | - | ||||||||||||||||||
505 | } executed 18 times by 1 test: end of block Executed by:
| 18 | ||||||||||||||||||
506 | frameAt = d->m_curFrame % nColumns; | - | ||||||||||||||||||
507 | if (frameAt == 0
| 30-282 | ||||||||||||||||||
508 | d->m_spriteEngine->advance(); executed 30 times by 1 test: d->m_spriteEngine->advance(); Executed by:
| 30 | ||||||||||||||||||
509 | progress = 0; | - | ||||||||||||||||||
510 | } executed 312 times by 1 test: end of block Executed by:
| 312 | ||||||||||||||||||
511 | if (d->m_loops > 0
| 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:
| 8 | ||||||||||||||||||
518 | } executed 935 times by 1 test: else {end of block Executed by:
| 935 | ||||||||||||||||||
519 | frameAt = d->m_curFrame; | - | ||||||||||||||||||
520 | } executed 14 times by 1 test: end of block Executed by:
| 14 | ||||||||||||||||||
521 | if (d->m_curFrame != lastFrame
| 393-556 | ||||||||||||||||||
522 | if (isCurrentFrameChangedConnected()
| 40-516 | ||||||||||||||||||
523 | currentFrameChanged(d->m_curFrame); executed 516 times by 1 test: currentFrameChanged(d->m_curFrame); Executed by:
| 516 | ||||||||||||||||||
524 | maybeUpdate(); | - | ||||||||||||||||||
525 | } executed 556 times by 1 test: end of block Executed by:
| 556 | ||||||||||||||||||
526 | - | |||||||||||||||||||
527 | qreal frameCount = d->m_spriteEngine->spriteFrames(); | - | ||||||||||||||||||
528 | bool reverse = d->m_spriteEngine->sprite()->reverse(); | - | ||||||||||||||||||
529 | if (reverse
| 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
| 0-949 | ||||||||||||||||||
537 | int spriteY = d->m_spriteEngine->spriteY(); | - | ||||||||||||||||||
538 | if (reverse
| 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: else {end of block | 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:
| 949 | ||||||||||||||||||
553 | - | |||||||||||||||||||
554 | - | |||||||||||||||||||
555 | - | |||||||||||||||||||
556 | - | |||||||||||||||||||
557 | int x2; | - | ||||||||||||||||||
558 | int y2; | - | ||||||||||||||||||
559 | if (reverse
| 0-949 | ||||||||||||||||||
560 | if (frameAt > 0
| 0 | ||||||||||||||||||
561 | x2 = x1 - w; | - | ||||||||||||||||||
562 | y2 = y1; | - | ||||||||||||||||||
563 | } never executed: else {end of block | 0 | ||||||||||||||||||
564 | x2 = 1.0 - w; | - | ||||||||||||||||||
565 | y2 = y1 - h; | - | ||||||||||||||||||
566 | if (y2 < 0.0
| 0 | ||||||||||||||||||
567 | - | |||||||||||||||||||
568 | int maxRowFrames = d->m_sheetSize.width() / d->m_spriteEngine->spriteWidth(); | - | ||||||||||||||||||
569 | if (d->m_spriteEngine->maxFrames() % maxRowFrames
| 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)
| 86-863 | ||||||||||||||||||
577 | x2 = x1 + w; | - | ||||||||||||||||||
578 | y2 = y1; | - | ||||||||||||||||||
579 | } executed 863 times by 1 test: else {end of block Executed by:
| 863 | ||||||||||||||||||
580 | x2 = 0.0; | - | ||||||||||||||||||
581 | y2 = y1 + h; | - | ||||||||||||||||||
582 | if (y2 >= 1.0
| 0-86 | ||||||||||||||||||
583 | y2 = 0.0; executed 86 times by 1 test: y2 = 0.0; Executed by:
| 86 | ||||||||||||||||||
584 | } executed 86 times by 1 test: end of block Executed by:
| 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:
| 949 | ||||||||||||||||||
595 | - | |||||||||||||||||||
596 | - | |||||||||||||||||||
597 | - | |||||||||||||||||||
Switch to Source code | Preprocessed file |