Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquicksprite_p.h |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
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 | #ifndef QQUICKSPRITE_P_H | - | ||||||
41 | #define QQUICKSPRITE_P_H | - | ||||||
42 | - | |||||||
43 | // | - | ||||||
44 | // W A R N I N G | - | ||||||
45 | // ------------- | - | ||||||
46 | // | - | ||||||
47 | // This file is not part of the Qt API. It exists purely as an | - | ||||||
48 | // implementation detail. This header file may change from version to | - | ||||||
49 | // version without notice, or even be removed. | - | ||||||
50 | // | - | ||||||
51 | // We mean it. | - | ||||||
52 | // | - | ||||||
53 | - | |||||||
54 | #include <private/qtquickglobal_p.h> | - | ||||||
55 | - | |||||||
56 | QT_REQUIRE_CONFIG(quick_sprite); | - | ||||||
57 | - | |||||||
58 | #include <QObject> | - | ||||||
59 | #include <QUrl> | - | ||||||
60 | #include <QVariantMap> | - | ||||||
61 | #include <QQmlListProperty> | - | ||||||
62 | #include <QtQuick/private/qquickpixmapcache_p.h> | - | ||||||
63 | #include "qquickspriteengine_p.h" | - | ||||||
64 | #include <QDebug> | - | ||||||
65 | - | |||||||
66 | QT_BEGIN_NAMESPACE | - | ||||||
67 | - | |||||||
68 | // exported, since it's used in QtQuickParticles | - | ||||||
69 | class Q_QUICK_EXPORT QQuickSprite : public QQuickStochasticState | - | ||||||
70 | { | - | ||||||
71 | Q_OBJECT | - | ||||||
72 | Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) | - | ||||||
73 | //Renderers have to query this hint when advancing frames | - | ||||||
74 | Q_PROPERTY(bool reverse READ reverse WRITE setReverse NOTIFY reverseChanged) | - | ||||||
75 | Q_PROPERTY(bool frameSync READ frameSync WRITE setFrameSync NOTIFY frameSyncChanged) | - | ||||||
76 | Q_PROPERTY(int frames READ frames WRITE setFrames NOTIFY frameCountChanged) | - | ||||||
77 | Q_PROPERTY(int frameCount READ frameCount WRITE setFrameCount NOTIFY frameCountChanged) | - | ||||||
78 | //If frame height or width is not specified, it is assumed to be a single long row of square frames. | - | ||||||
79 | //Otherwise, it can be multiple contiguous rows, when one row runs out the next will be used. | - | ||||||
80 | Q_PROPERTY(int frameHeight READ frameHeight WRITE setFrameHeight NOTIFY frameHeightChanged) | - | ||||||
81 | Q_PROPERTY(int frameWidth READ frameWidth WRITE setFrameWidth NOTIFY frameWidthChanged) | - | ||||||
82 | Q_PROPERTY(int frameX READ frameX WRITE setFrameX NOTIFY frameXChanged) | - | ||||||
83 | Q_PROPERTY(int frameY READ frameY WRITE setFrameY NOTIFY frameYChanged) | - | ||||||
84 | //Precedence order: frameRate, frameDuration, duration | - | ||||||
85 | Q_PROPERTY(qreal frameRate READ frameRate WRITE setFrameRate NOTIFY frameRateChanged RESET resetFrameRate) | - | ||||||
86 | Q_PROPERTY(qreal frameRateVariation READ frameRateVariation WRITE setFrameRateVariation NOTIFY frameRateVariationChanged) | - | ||||||
87 | Q_PROPERTY(int frameDuration READ frameDuration WRITE setFrameDuration NOTIFY frameDurationChanged RESET resetFrameDuration) | - | ||||||
88 | Q_PROPERTY(int frameDurationVariation READ frameDurationVariation WRITE setFrameDurationVariation NOTIFY frameDurationVariationChanged) | - | ||||||
89 | - | |||||||
90 | public: | - | ||||||
91 | explicit QQuickSprite(QObject *parent = nullptr); | - | ||||||
92 | ~QQuickSprite() override; | - | ||||||
93 | - | |||||||
94 | QUrl source() const | - | ||||||
95 | { | - | ||||||
96 | return m_source; never executed: return m_source; | 0 | ||||||
97 | } | - | ||||||
98 | - | |||||||
99 | int frameHeight() const | - | ||||||
100 | { | - | ||||||
101 | return m_frameHeight; executed 697 times by 4 tests: return m_frameHeight; Executed by:
| 697 | ||||||
102 | } | - | ||||||
103 | - | |||||||
104 | int frameWidth() const | - | ||||||
105 | { | - | ||||||
106 | return m_frameWidth; executed 120 times by 4 tests: return m_frameWidth; Executed by:
| 120 | ||||||
107 | } | - | ||||||
108 | - | |||||||
109 | bool reverse() const | - | ||||||
110 | { | - | ||||||
111 | return m_reverse; executed 146551 times by 4 tests: return m_reverse; Executed by:
| 146551 | ||||||
112 | } | - | ||||||
113 | - | |||||||
114 | int frames() const | - | ||||||
115 | { | - | ||||||
116 | return m_frames; executed 5526 times by 4 tests: return m_frames; Executed by:
| 5526 | ||||||
117 | } | - | ||||||
118 | - | |||||||
119 | int frameCount() const | - | ||||||
120 | { | - | ||||||
121 | return m_frames; never executed: return m_frames; | 0 | ||||||
122 | } | - | ||||||
123 | - | |||||||
124 | int frameX() const | - | ||||||
125 | { | - | ||||||
126 | return m_frameX; never executed: return m_frameX; | 0 | ||||||
127 | } | - | ||||||
128 | - | |||||||
129 | int frameY() const | - | ||||||
130 | { | - | ||||||
131 | return m_frameY; never executed: return m_frameY; | 0 | ||||||
132 | } | - | ||||||
133 | - | |||||||
134 | void resetFrameRate() | - | ||||||
135 | { | - | ||||||
136 | setFrameRate(-1); | - | ||||||
137 | } never executed: end of block | 0 | ||||||
138 | - | |||||||
139 | qreal frameRate() const | - | ||||||
140 | { | - | ||||||
141 | return m_frameRate; never executed: return m_frameRate; | 0 | ||||||
142 | } | - | ||||||
143 | - | |||||||
144 | qreal frameRateVariation() const | - | ||||||
145 | { | - | ||||||
146 | return m_frameRateVariation; never executed: return m_frameRateVariation; | 0 | ||||||
147 | } | - | ||||||
148 | - | |||||||
149 | void resetFrameDuration() | - | ||||||
150 | { | - | ||||||
151 | setFrameDuration(-1); | - | ||||||
152 | } never executed: end of block | 0 | ||||||
153 | - | |||||||
154 | int frameDuration() const | - | ||||||
155 | { | - | ||||||
156 | return m_frameDuration; never executed: return m_frameDuration; | 0 | ||||||
157 | } | - | ||||||
158 | - | |||||||
159 | int frameDurationVariation() const | - | ||||||
160 | { | - | ||||||
161 | return m_frameDurationVariation; never executed: return m_frameDurationVariation; | 0 | ||||||
162 | } | - | ||||||
163 | - | |||||||
164 | int variedDuration() const override; | - | ||||||
165 | - | |||||||
166 | bool frameSync() const | - | ||||||
167 | { | - | ||||||
168 | return m_frameSync; executed 7608 times by 4 tests: return m_frameSync; Executed by:
| 7608 | ||||||
169 | } | - | ||||||
170 | - | |||||||
171 | void setDevicePixelRatio(qreal dpr) | - | ||||||
172 | { | - | ||||||
173 | m_devicePixelRatio = dpr; | - | ||||||
174 | } executed 20 times by 1 test: end of block Executed by:
| 20 | ||||||
175 | - | |||||||
176 | qreal devicePixelRatio() const | - | ||||||
177 | { | - | ||||||
178 | return m_devicePixelRatio; executed 40 times by 4 tests: return m_devicePixelRatio; Executed by:
| 40 | ||||||
179 | } | - | ||||||
180 | - | |||||||
181 | Q_SIGNALS: | - | ||||||
182 | - | |||||||
183 | void sourceChanged(QUrl arg); | - | ||||||
184 | - | |||||||
185 | void frameHeightChanged(int arg); | - | ||||||
186 | - | |||||||
187 | void frameWidthChanged(int arg); | - | ||||||
188 | - | |||||||
189 | void reverseChanged(bool arg); | - | ||||||
190 | - | |||||||
191 | void frameCountChanged(int arg); | - | ||||||
192 | - | |||||||
193 | void frameXChanged(int arg); | - | ||||||
194 | - | |||||||
195 | void frameYChanged(int arg); | - | ||||||
196 | - | |||||||
197 | void frameRateChanged(qreal arg); | - | ||||||
198 | - | |||||||
199 | void frameRateVariationChanged(qreal arg); | - | ||||||
200 | - | |||||||
201 | void frameDurationChanged(int arg); | - | ||||||
202 | - | |||||||
203 | void frameDurationVariationChanged(int arg); | - | ||||||
204 | - | |||||||
205 | void frameSyncChanged(bool arg); | - | ||||||
206 | - | |||||||
207 | public Q_SLOTS: | - | ||||||
208 | - | |||||||
209 | void setSource(QUrl arg) | - | ||||||
210 | { | - | ||||||
211 | if (m_source != arg) {
| 0-92 | ||||||
212 | m_source = arg; | - | ||||||
213 | Q_EMIT sourceChanged(arg); | - | ||||||
214 | startImageLoading(); | - | ||||||
215 | } executed 92 times by 5 tests: end of block Executed by:
| 92 | ||||||
216 | } executed 92 times by 5 tests: end of block Executed by:
| 92 | ||||||
217 | - | |||||||
218 | void setFrameHeight(int arg) | - | ||||||
219 | { | - | ||||||
220 | if (m_frameHeight != arg) {
| 0-14 | ||||||
221 | m_frameHeight = arg; | - | ||||||
222 | Q_EMIT frameHeightChanged(arg); | - | ||||||
223 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||
224 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||
225 | - | |||||||
226 | void setFrameWidth(int arg) | - | ||||||
227 | { | - | ||||||
228 | if (m_frameWidth != arg) {
| 0-14 | ||||||
229 | m_frameWidth = arg; | - | ||||||
230 | Q_EMIT frameWidthChanged(arg); | - | ||||||
231 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||
232 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||
233 | - | |||||||
234 | void setReverse(bool arg) | - | ||||||
235 | { | - | ||||||
236 | if (m_reverse != arg) {
| 0 | ||||||
237 | m_reverse = arg; | - | ||||||
238 | Q_EMIT reverseChanged(arg); | - | ||||||
239 | } never executed: end of block | 0 | ||||||
240 | } never executed: end of block | 0 | ||||||
241 | - | |||||||
242 | void setFrames(int arg) | - | ||||||
243 | { | - | ||||||
244 | qWarning() << "Sprite::frames has been renamed Sprite::frameCount"; | - | ||||||
245 | setFrameCount(arg); | - | ||||||
246 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||
247 | - | |||||||
248 | void setFrameCount(int arg) | - | ||||||
249 | { | - | ||||||
250 | if (m_frames != arg) {
| 30-54 | ||||||
251 | m_frames = arg; | - | ||||||
252 | Q_EMIT frameCountChanged(arg); | - | ||||||
253 | } executed 54 times by 5 tests: end of block Executed by:
| 54 | ||||||
254 | } executed 84 times by 5 tests: end of block Executed by:
| 84 | ||||||
255 | - | |||||||
256 | void setFrameX(int arg) | - | ||||||
257 | { | - | ||||||
258 | if (m_frameX != arg) {
| 0 | ||||||
259 | m_frameX = arg; | - | ||||||
260 | Q_EMIT frameXChanged(arg); | - | ||||||
261 | } never executed: end of block | 0 | ||||||
262 | } never executed: end of block | 0 | ||||||
263 | - | |||||||
264 | void setFrameY(int arg) | - | ||||||
265 | { | - | ||||||
266 | if (m_frameY != arg) {
| 0 | ||||||
267 | m_frameY = arg; | - | ||||||
268 | Q_EMIT frameYChanged(arg); | - | ||||||
269 | } never executed: end of block | 0 | ||||||
270 | } never executed: end of block | 0 | ||||||
271 | - | |||||||
272 | void setFrameRate(qreal arg) | - | ||||||
273 | { | - | ||||||
274 | if (m_frameRate != arg) {
| 0 | ||||||
275 | m_frameRate = arg; | - | ||||||
276 | Q_EMIT frameRateChanged(arg); | - | ||||||
277 | } never executed: end of block | 0 | ||||||
278 | } never executed: end of block | 0 | ||||||
279 | - | |||||||
280 | void setFrameRateVariation(qreal arg) | - | ||||||
281 | { | - | ||||||
282 | if (m_frameRateVariation != arg) {
| 0 | ||||||
283 | m_frameRateVariation = arg; | - | ||||||
284 | Q_EMIT frameRateVariationChanged(arg); | - | ||||||
285 | } never executed: end of block | 0 | ||||||
286 | } never executed: end of block | 0 | ||||||
287 | - | |||||||
288 | void setFrameDuration(int arg) | - | ||||||
289 | { | - | ||||||
290 | if (m_frameDuration != arg) {
| 0-72 | ||||||
291 | m_frameDuration = arg; | - | ||||||
292 | Q_EMIT frameDurationChanged(arg); | - | ||||||
293 | } executed 72 times by 5 tests: end of block Executed by:
| 72 | ||||||
294 | } executed 72 times by 5 tests: end of block Executed by:
| 72 | ||||||
295 | - | |||||||
296 | void setFrameDurationVariation(int arg) | - | ||||||
297 | { | - | ||||||
298 | if (m_frameDurationVariation != arg) {
| 0-4 | ||||||
299 | m_frameDurationVariation = arg; | - | ||||||
300 | Q_EMIT frameDurationVariationChanged(arg); | - | ||||||
301 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||
302 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||
303 | - | |||||||
304 | void setFrameSync(bool arg) | - | ||||||
305 | { | - | ||||||
306 | if (m_frameSync != arg) {
| 0-16 | ||||||
307 | m_frameSync = arg; | - | ||||||
308 | Q_EMIT frameSyncChanged(arg); | - | ||||||
309 | } executed 16 times by 2 tests: end of block Executed by:
| 16 | ||||||
310 | } executed 16 times by 2 tests: end of block Executed by:
| 16 | ||||||
311 | - | |||||||
312 | private Q_SLOTS: | - | ||||||
313 | void startImageLoading(); | - | ||||||
314 | - | |||||||
315 | private: | - | ||||||
316 | friend class QQuickImageParticle; | - | ||||||
317 | //friend class QQuickSpriteSequence; | - | ||||||
318 | friend class QQuickAnimatedSprite; | - | ||||||
319 | friend class QQuickSpriteEngine; | - | ||||||
320 | friend class QQuickStochasticEngine; | - | ||||||
321 | - | |||||||
322 | int m_generatedCount; | - | ||||||
323 | int m_framesPerRow; | - | ||||||
324 | int m_rowY; | - | ||||||
325 | int m_rowStartX; | - | ||||||
326 | - | |||||||
327 | QUrl m_source; | - | ||||||
328 | bool m_reverse; | - | ||||||
329 | int m_frameHeight; | - | ||||||
330 | int m_frameWidth; | - | ||||||
331 | int m_frames; | - | ||||||
332 | int m_frameX; | - | ||||||
333 | int m_frameY; | - | ||||||
334 | qreal m_frameRate; | - | ||||||
335 | qreal m_frameRateVariation; | - | ||||||
336 | int m_frameDuration; | - | ||||||
337 | int m_frameDurationVariation; | - | ||||||
338 | bool m_frameSync; | - | ||||||
339 | qreal m_devicePixelRatio; | - | ||||||
340 | QQuickPixmap m_pix; | - | ||||||
341 | }; | - | ||||||
342 | - | |||||||
343 | QT_END_NAMESPACE | - | ||||||
344 | - | |||||||
345 | #endif // QQUICKSPRITE_P_H | - | ||||||
Source code | Switch to Preprocessed file |