Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/particles/qquickimageparticle.cpp |
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 | #include <QtQuick/private/qsgcontext_p.h> | - | ||||||||||||||||||
41 | #include <private/qsgadaptationlayer_p.h> | - | ||||||||||||||||||
42 | #include <private/qquickitem_p.h> | - | ||||||||||||||||||
43 | #include <QtQuick/qsgnode.h> | - | ||||||||||||||||||
44 | #include <QtQuick/qsgtexturematerial.h> | - | ||||||||||||||||||
45 | #include <QtQuick/qsgtexture.h> | - | ||||||||||||||||||
46 | #include <QFile> | - | ||||||||||||||||||
47 | #include <QRandomGenerator> | - | ||||||||||||||||||
48 | #include "qquickimageparticle_p.h" | - | ||||||||||||||||||
49 | #include "qquickparticleemitter_p.h" | - | ||||||||||||||||||
50 | #include <private/qquicksprite_p.h> | - | ||||||||||||||||||
51 | #include <private/qquickspriteengine_p.h> | - | ||||||||||||||||||
52 | #include <QOpenGLFunctions> | - | ||||||||||||||||||
53 | #include <QSGRendererInterface> | - | ||||||||||||||||||
54 | #include <QtQuick/private/qsgshadersourcebuilder_p.h> | - | ||||||||||||||||||
55 | #include <QtQuick/private/qsgtexture_p.h> | - | ||||||||||||||||||
56 | #include <private/qqmlglobal_p.h> | - | ||||||||||||||||||
57 | #include <QtQml/qqmlinfo.h> | - | ||||||||||||||||||
58 | #include <cmath> | - | ||||||||||||||||||
59 | - | |||||||||||||||||||
60 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
61 | - | |||||||||||||||||||
62 | //TODO: Make it larger on desktop? Requires fixing up shader code with the same define | - | ||||||||||||||||||
63 | #define UNIFORM_ARRAY_SIZE 64 | - | ||||||||||||||||||
64 | - | |||||||||||||||||||
65 | const qreal CONV = 0.017453292519943295; | - | ||||||||||||||||||
66 | class ImageMaterialData | - | ||||||||||||||||||
67 | { | - | ||||||||||||||||||
68 | public: | - | ||||||||||||||||||
69 | ImageMaterialData() | - | ||||||||||||||||||
70 | : texture(nullptr), colorTable(nullptr) | - | ||||||||||||||||||
71 | {} executed 99 times by 21 tests: end of block Executed by:
| 99 | ||||||||||||||||||
72 | - | |||||||||||||||||||
73 | ~ImageMaterialData(){ | - | ||||||||||||||||||
74 | delete texture; | - | ||||||||||||||||||
75 | delete colorTable; | - | ||||||||||||||||||
76 | } executed 99 times by 21 tests: end of block Executed by:
| 99 | ||||||||||||||||||
77 | - | |||||||||||||||||||
78 | QSGTexture *texture; | - | ||||||||||||||||||
79 | QSGTexture *colorTable; | - | ||||||||||||||||||
80 | float sizeTable[UNIFORM_ARRAY_SIZE]; | - | ||||||||||||||||||
81 | float opacityTable[UNIFORM_ARRAY_SIZE]; | - | ||||||||||||||||||
82 | - | |||||||||||||||||||
83 | qreal timestamp; | - | ||||||||||||||||||
84 | qreal entry; | - | ||||||||||||||||||
85 | QSizeF animSheetSize; | - | ||||||||||||||||||
86 | }; | - | ||||||||||||||||||
87 | - | |||||||||||||||||||
88 | class TabledMaterialData : public ImageMaterialData {}; | - | ||||||||||||||||||
89 | class TabledMaterial : public QSGSimpleMaterialShader<TabledMaterialData> | - | ||||||||||||||||||
90 | { | - | ||||||||||||||||||
91 | QSG_DECLARE_SIMPLE_SHADER(TabledMaterial, TabledMaterialData) executed 2 times by 1 test: return new TabledMaterial; Executed by:
executed 2 times by 1 test: return new QSGSimpleMaterial<TabledMaterialData>(createShader); Executed by:
| 2 | ||||||||||||||||||
92 | - | |||||||||||||||||||
93 | public: | - | ||||||||||||||||||
94 | TabledMaterial() | - | ||||||||||||||||||
95 | { | - | ||||||||||||||||||
96 | QSGShaderSourceBuilder builder; | - | ||||||||||||||||||
97 | const bool isES = QOpenGLContext::currentContext()->isOpenGLES(); | - | ||||||||||||||||||
98 | - | |||||||||||||||||||
99 | builder.appendSourceFile(QStringLiteral(":/particles/shaders/imageparticle.vert")); executed 2 times by 1 test: return qstring_literal_temp; Executed by:
| 2 | ||||||||||||||||||
100 | builder.addDefinition(QByteArrayLiteral("TABLE")); executed 2 times by 1 test: return ba; Executed by:
| 2 | ||||||||||||||||||
101 | builder.addDefinition(QByteArrayLiteral("DEFORM")); executed 2 times by 1 test: return ba; Executed by:
| 2 | ||||||||||||||||||
102 | builder.addDefinition(QByteArrayLiteral("COLOR")); executed 2 times by 1 test: return ba; Executed by:
| 2 | ||||||||||||||||||
103 | if (isES)
| 0-2 | ||||||||||||||||||
104 | builder.removeVersion(); never executed: builder.removeVersion(); | 0 | ||||||||||||||||||
105 | - | |||||||||||||||||||
106 | m_vertex_code = builder.source(); | - | ||||||||||||||||||
107 | builder.clear(); | - | ||||||||||||||||||
108 | - | |||||||||||||||||||
109 | builder.appendSourceFile(QStringLiteral(":/particles/shaders/imageparticle.frag")); executed 2 times by 1 test: return qstring_literal_temp; Executed by:
| 2 | ||||||||||||||||||
110 | builder.addDefinition(QByteArrayLiteral("TABLE")); executed 2 times by 1 test: return ba; Executed by:
| 2 | ||||||||||||||||||
111 | builder.addDefinition(QByteArrayLiteral("DEFORM")); executed 2 times by 1 test: return ba; Executed by:
| 2 | ||||||||||||||||||
112 | builder.addDefinition(QByteArrayLiteral("COLOR")); executed 2 times by 1 test: return ba; Executed by:
| 2 | ||||||||||||||||||
113 | if (isES)
| 0-2 | ||||||||||||||||||
114 | builder.removeVersion(); never executed: builder.removeVersion(); | 0 | ||||||||||||||||||
115 | - | |||||||||||||||||||
116 | m_fragment_code = builder.source(); | - | ||||||||||||||||||
117 | - | |||||||||||||||||||
118 | Q_ASSERT(!m_vertex_code.isNull()); | - | ||||||||||||||||||
119 | Q_ASSERT(!m_fragment_code.isNull()); | - | ||||||||||||||||||
120 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
121 | - | |||||||||||||||||||
122 | const char *vertexShader() const override { return m_vertex_code.constData(); } executed 2 times by 1 test: return m_vertex_code.constData(); Executed by:
| 2 | ||||||||||||||||||
123 | const char *fragmentShader() const override { return m_fragment_code.constData(); } executed 2 times by 1 test: return m_fragment_code.constData(); Executed by:
| 2 | ||||||||||||||||||
124 | - | |||||||||||||||||||
125 | QList<QByteArray> attributes() const override { | - | ||||||||||||||||||
126 | return QList<QByteArray>() << "vPosTex" << "vData" << "vVec" executed 2 times by 1 test: return QList<QByteArray>() << "vPosTex" << "vData" << "vVec" << "vColor" << "vDeformVec" << "vRotation"; Executed by:
| 2 | ||||||||||||||||||
127 | << "vColor" << "vDeformVec" << "vRotation"; executed 2 times by 1 test: return QList<QByteArray>() << "vPosTex" << "vData" << "vVec" << "vColor" << "vDeformVec" << "vRotation"; Executed by:
| 2 | ||||||||||||||||||
128 | }; | - | ||||||||||||||||||
129 | - | |||||||||||||||||||
130 | void initialize() override { | - | ||||||||||||||||||
131 | QSGSimpleMaterialShader<TabledMaterialData>::initialize(); | - | ||||||||||||||||||
132 | program()->bind(); | - | ||||||||||||||||||
133 | program()->setUniformValue("_qt_texture", 0); | - | ||||||||||||||||||
134 | program()->setUniformValue("colortable", 1); | - | ||||||||||||||||||
135 | glFuncs = QOpenGLContext::currentContext()->functions(); | - | ||||||||||||||||||
136 | m_timestamp_id = program()->uniformLocation("timestamp"); | - | ||||||||||||||||||
137 | m_entry_id = program()->uniformLocation("entry"); | - | ||||||||||||||||||
138 | m_sizetable_id = program()->uniformLocation("sizetable"); | - | ||||||||||||||||||
139 | m_opacitytable_id = program()->uniformLocation("opacitytable"); | - | ||||||||||||||||||
140 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
141 | - | |||||||||||||||||||
142 | void updateState(const TabledMaterialData* d, const TabledMaterialData*) override { | - | ||||||||||||||||||
143 | glFuncs->glActiveTexture(GL_TEXTURE1); | - | ||||||||||||||||||
144 | d->colorTable->bind(); | - | ||||||||||||||||||
145 | - | |||||||||||||||||||
146 | glFuncs->glActiveTexture(GL_TEXTURE0); | - | ||||||||||||||||||
147 | d->texture->bind(); | - | ||||||||||||||||||
148 | - | |||||||||||||||||||
149 | program()->setUniformValue(m_timestamp_id, (float) d->timestamp); | - | ||||||||||||||||||
150 | program()->setUniformValue(m_entry_id, (float) d->entry); | - | ||||||||||||||||||
151 | program()->setUniformValueArray(m_sizetable_id, (const float*) d->sizeTable, UNIFORM_ARRAY_SIZE, 1); | - | ||||||||||||||||||
152 | program()->setUniformValueArray(m_opacitytable_id, (const float*) d->opacityTable, UNIFORM_ARRAY_SIZE, 1); | - | ||||||||||||||||||
153 | } executed 125 times by 1 test: end of block Executed by:
| 125 | ||||||||||||||||||
154 | - | |||||||||||||||||||
155 | int m_entry_id; | - | ||||||||||||||||||
156 | int m_timestamp_id; | - | ||||||||||||||||||
157 | int m_sizetable_id; | - | ||||||||||||||||||
158 | int m_opacitytable_id; | - | ||||||||||||||||||
159 | QByteArray m_vertex_code; | - | ||||||||||||||||||
160 | QByteArray m_fragment_code; | - | ||||||||||||||||||
161 | QOpenGLFunctions* glFuncs; | - | ||||||||||||||||||
162 | }; | - | ||||||||||||||||||
163 | - | |||||||||||||||||||
164 | class DeformableMaterialData : public ImageMaterialData {}; | - | ||||||||||||||||||
165 | class DeformableMaterial : public QSGSimpleMaterialShader<DeformableMaterialData> | - | ||||||||||||||||||
166 | { | - | ||||||||||||||||||
167 | QSG_DECLARE_SIMPLE_SHADER(DeformableMaterial, DeformableMaterialData) executed 6 times by 2 tests: return new DeformableMaterial; Executed by:
executed 6 times by 2 tests: return new QSGSimpleMaterial<DeformableMaterialData>(createShader); Executed by:
| 6 | ||||||||||||||||||
168 | - | |||||||||||||||||||
169 | public: | - | ||||||||||||||||||
170 | DeformableMaterial() | - | ||||||||||||||||||
171 | { | - | ||||||||||||||||||
172 | QSGShaderSourceBuilder builder; | - | ||||||||||||||||||
173 | const bool isES = QOpenGLContext::currentContext()->isOpenGLES(); | - | ||||||||||||||||||
174 | - | |||||||||||||||||||
175 | builder.appendSourceFile(QStringLiteral(":/particles/shaders/imageparticle.vert")); executed 6 times by 2 tests: return qstring_literal_temp; Executed by:
| 6 | ||||||||||||||||||
176 | builder.addDefinition(QByteArrayLiteral("DEFORM")); executed 6 times by 2 tests: return ba; Executed by:
| 6 | ||||||||||||||||||
177 | builder.addDefinition(QByteArrayLiteral("COLOR")); executed 6 times by 2 tests: return ba; Executed by:
| 6 | ||||||||||||||||||
178 | if (isES)
| 0-6 | ||||||||||||||||||
179 | builder.removeVersion(); never executed: builder.removeVersion(); | 0 | ||||||||||||||||||
180 | - | |||||||||||||||||||
181 | m_vertex_code = builder.source(); | - | ||||||||||||||||||
182 | builder.clear(); | - | ||||||||||||||||||
183 | - | |||||||||||||||||||
184 | builder.appendSourceFile(QStringLiteral(":/particles/shaders/imageparticle.frag")); executed 6 times by 2 tests: return qstring_literal_temp; Executed by:
| 6 | ||||||||||||||||||
185 | builder.addDefinition(QByteArrayLiteral("DEFORM")); executed 6 times by 2 tests: return ba; Executed by:
| 6 | ||||||||||||||||||
186 | builder.addDefinition(QByteArrayLiteral("COLOR")); executed 6 times by 2 tests: return ba; Executed by:
| 6 | ||||||||||||||||||
187 | if (isES)
| 0-6 | ||||||||||||||||||
188 | builder.removeVersion(); never executed: builder.removeVersion(); | 0 | ||||||||||||||||||
189 | - | |||||||||||||||||||
190 | m_fragment_code = builder.source(); | - | ||||||||||||||||||
191 | - | |||||||||||||||||||
192 | Q_ASSERT(!m_vertex_code.isNull()); | - | ||||||||||||||||||
193 | Q_ASSERT(!m_fragment_code.isNull()); | - | ||||||||||||||||||
194 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||||||||
195 | - | |||||||||||||||||||
196 | const char *vertexShader() const override { return m_vertex_code.constData(); } executed 6 times by 2 tests: return m_vertex_code.constData(); Executed by:
| 6 | ||||||||||||||||||
197 | const char *fragmentShader() const override { return m_fragment_code.constData(); } executed 6 times by 2 tests: return m_fragment_code.constData(); Executed by:
| 6 | ||||||||||||||||||
198 | - | |||||||||||||||||||
199 | QList<QByteArray> attributes() const override { | - | ||||||||||||||||||
200 | return QList<QByteArray>() << "vPosTex" << "vData" << "vVec" executed 6 times by 2 tests: return QList<QByteArray>() << "vPosTex" << "vData" << "vVec" << "vColor" << "vDeformVec" << "vRotation"; Executed by:
| 6 | ||||||||||||||||||
201 | << "vColor" << "vDeformVec" << "vRotation"; executed 6 times by 2 tests: return QList<QByteArray>() << "vPosTex" << "vData" << "vVec" << "vColor" << "vDeformVec" << "vRotation"; Executed by:
| 6 | ||||||||||||||||||
202 | }; | - | ||||||||||||||||||
203 | - | |||||||||||||||||||
204 | void initialize() override { | - | ||||||||||||||||||
205 | QSGSimpleMaterialShader<DeformableMaterialData>::initialize(); | - | ||||||||||||||||||
206 | program()->bind(); | - | ||||||||||||||||||
207 | program()->setUniformValue("_qt_texture", 0); | - | ||||||||||||||||||
208 | glFuncs = QOpenGLContext::currentContext()->functions(); | - | ||||||||||||||||||
209 | m_timestamp_id = program()->uniformLocation("timestamp"); | - | ||||||||||||||||||
210 | m_entry_id = program()->uniformLocation("entry"); | - | ||||||||||||||||||
211 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||||||||
212 | - | |||||||||||||||||||
213 | void updateState(const DeformableMaterialData* d, const DeformableMaterialData*) override { | - | ||||||||||||||||||
214 | d->texture->bind(); | - | ||||||||||||||||||
215 | - | |||||||||||||||||||
216 | program()->setUniformValue(m_timestamp_id, (float) d->timestamp); | - | ||||||||||||||||||
217 | program()->setUniformValue(m_entry_id, (float) d->entry); | - | ||||||||||||||||||
218 | } executed 308 times by 2 tests: end of block Executed by:
| 308 | ||||||||||||||||||
219 | - | |||||||||||||||||||
220 | int m_entry_id; | - | ||||||||||||||||||
221 | int m_timestamp_id; | - | ||||||||||||||||||
222 | QByteArray m_vertex_code; | - | ||||||||||||||||||
223 | QByteArray m_fragment_code; | - | ||||||||||||||||||
224 | QOpenGLFunctions* glFuncs; | - | ||||||||||||||||||
225 | }; | - | ||||||||||||||||||
226 | - | |||||||||||||||||||
227 | class SpriteMaterialData : public ImageMaterialData {}; | - | ||||||||||||||||||
228 | class SpriteMaterial : public QSGSimpleMaterialShader<SpriteMaterialData> | - | ||||||||||||||||||
229 | { | - | ||||||||||||||||||
230 | QSG_DECLARE_SIMPLE_SHADER(SpriteMaterial, SpriteMaterialData) executed 4 times by 2 tests: return new SpriteMaterial; Executed by:
executed 4 times by 2 tests: return new QSGSimpleMaterial<SpriteMaterialData>(createShader); Executed by:
| 4 | ||||||||||||||||||
231 | - | |||||||||||||||||||
232 | public: | - | ||||||||||||||||||
233 | SpriteMaterial() | - | ||||||||||||||||||
234 | { | - | ||||||||||||||||||
235 | QSGShaderSourceBuilder builder; | - | ||||||||||||||||||
236 | const bool isES = QOpenGLContext::currentContext()->isOpenGLES(); | - | ||||||||||||||||||
237 | - | |||||||||||||||||||
238 | builder.appendSourceFile(QStringLiteral(":/particles/shaders/imageparticle.vert")); executed 4 times by 2 tests: return qstring_literal_temp; Executed by:
| 4 | ||||||||||||||||||
239 | builder.addDefinition(QByteArrayLiteral("SPRITE")); executed 4 times by 2 tests: return ba; Executed by:
| 4 | ||||||||||||||||||
240 | builder.addDefinition(QByteArrayLiteral("TABLE")); executed 4 times by 2 tests: return ba; Executed by:
| 4 | ||||||||||||||||||
241 | builder.addDefinition(QByteArrayLiteral("DEFORM")); executed 4 times by 2 tests: return ba; Executed by:
| 4 | ||||||||||||||||||
242 | builder.addDefinition(QByteArrayLiteral("COLOR")); executed 4 times by 2 tests: return ba; Executed by:
| 4 | ||||||||||||||||||
243 | if (isES)
| 0-4 | ||||||||||||||||||
244 | builder.removeVersion(); never executed: builder.removeVersion(); | 0 | ||||||||||||||||||
245 | - | |||||||||||||||||||
246 | m_vertex_code = builder.source(); | - | ||||||||||||||||||
247 | builder.clear(); | - | ||||||||||||||||||
248 | - | |||||||||||||||||||
249 | builder.appendSourceFile(QStringLiteral(":/particles/shaders/imageparticle.frag")); executed 4 times by 2 tests: return qstring_literal_temp; Executed by:
| 4 | ||||||||||||||||||
250 | builder.addDefinition(QByteArrayLiteral("SPRITE")); executed 4 times by 2 tests: return ba; Executed by:
| 4 | ||||||||||||||||||
251 | builder.addDefinition(QByteArrayLiteral("TABLE")); executed 4 times by 2 tests: return ba; Executed by:
| 4 | ||||||||||||||||||
252 | builder.addDefinition(QByteArrayLiteral("DEFORM")); executed 4 times by 2 tests: return ba; Executed by:
| 4 | ||||||||||||||||||
253 | builder.addDefinition(QByteArrayLiteral("COLOR")); executed 4 times by 2 tests: return ba; Executed by:
| 4 | ||||||||||||||||||
254 | if (isES)
| 0-4 | ||||||||||||||||||
255 | builder.removeVersion(); never executed: builder.removeVersion(); | 0 | ||||||||||||||||||
256 | - | |||||||||||||||||||
257 | m_fragment_code = builder.source(); | - | ||||||||||||||||||
258 | - | |||||||||||||||||||
259 | Q_ASSERT(!m_vertex_code.isNull()); | - | ||||||||||||||||||
260 | Q_ASSERT(!m_fragment_code.isNull()); | - | ||||||||||||||||||
261 | } executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||||||||||||||
262 | - | |||||||||||||||||||
263 | const char *vertexShader() const override { return m_vertex_code.constData(); } executed 4 times by 2 tests: return m_vertex_code.constData(); Executed by:
| 4 | ||||||||||||||||||
264 | const char *fragmentShader() const override { return m_fragment_code.constData(); } executed 4 times by 2 tests: return m_fragment_code.constData(); Executed by:
| 4 | ||||||||||||||||||
265 | - | |||||||||||||||||||
266 | QList<QByteArray> attributes() const override { | - | ||||||||||||||||||
267 | return QList<QByteArray>() << "vPosTex" << "vData" << "vVec" executed 4 times by 2 tests: return QList<QByteArray>() << "vPosTex" << "vData" << "vVec" << "vColor" << "vDeformVec" << "vRotation" << "vAnimData" << "vAnimPos"; Executed by:
| 4 | ||||||||||||||||||
268 | << "vColor" << "vDeformVec" << "vRotation" << "vAnimData" << "vAnimPos"; executed 4 times by 2 tests: return QList<QByteArray>() << "vPosTex" << "vData" << "vVec" << "vColor" << "vDeformVec" << "vRotation" << "vAnimData" << "vAnimPos"; Executed by:
| 4 | ||||||||||||||||||
269 | } | - | ||||||||||||||||||
270 | - | |||||||||||||||||||
271 | void initialize() override { | - | ||||||||||||||||||
272 | QSGSimpleMaterialShader<SpriteMaterialData>::initialize(); | - | ||||||||||||||||||
273 | program()->bind(); | - | ||||||||||||||||||
274 | program()->setUniformValue("_qt_texture", 0); | - | ||||||||||||||||||
275 | program()->setUniformValue("colortable", 1); | - | ||||||||||||||||||
276 | glFuncs = QOpenGLContext::currentContext()->functions(); | - | ||||||||||||||||||
277 | //Don't actually expose the animSheetSize in the shader, it's currently only used for CPU calculations. | - | ||||||||||||||||||
278 | m_timestamp_id = program()->uniformLocation("timestamp"); | - | ||||||||||||||||||
279 | m_entry_id = program()->uniformLocation("entry"); | - | ||||||||||||||||||
280 | m_sizetable_id = program()->uniformLocation("sizetable"); | - | ||||||||||||||||||
281 | m_opacitytable_id = program()->uniformLocation("opacitytable"); | - | ||||||||||||||||||
282 | } executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||||||||||||||
283 | - | |||||||||||||||||||
284 | void updateState(const SpriteMaterialData* d, const SpriteMaterialData*) override { | - | ||||||||||||||||||
285 | glFuncs->glActiveTexture(GL_TEXTURE1); | - | ||||||||||||||||||
286 | d->colorTable->bind(); | - | ||||||||||||||||||
287 | - | |||||||||||||||||||
288 | // make sure we end by setting GL_TEXTURE0 as active texture | - | ||||||||||||||||||
289 | glFuncs->glActiveTexture(GL_TEXTURE0); | - | ||||||||||||||||||
290 | d->texture->bind(); | - | ||||||||||||||||||
291 | - | |||||||||||||||||||
292 | program()->setUniformValue(m_timestamp_id, (float) d->timestamp); | - | ||||||||||||||||||
293 | program()->setUniformValue(m_entry_id, (float) d->entry); | - | ||||||||||||||||||
294 | program()->setUniformValueArray(m_sizetable_id, (const float*) d->sizeTable, 64, 1); | - | ||||||||||||||||||
295 | program()->setUniformValueArray(m_opacitytable_id, (const float*) d->opacityTable, UNIFORM_ARRAY_SIZE, 1); | - | ||||||||||||||||||
296 | } executed 267 times by 2 tests: end of block Executed by:
| 267 | ||||||||||||||||||
297 | - | |||||||||||||||||||
298 | int m_timestamp_id; | - | ||||||||||||||||||
299 | int m_entry_id; | - | ||||||||||||||||||
300 | int m_sizetable_id; | - | ||||||||||||||||||
301 | int m_opacitytable_id; | - | ||||||||||||||||||
302 | QByteArray m_vertex_code; | - | ||||||||||||||||||
303 | QByteArray m_fragment_code; | - | ||||||||||||||||||
304 | QOpenGLFunctions* glFuncs; | - | ||||||||||||||||||
305 | }; | - | ||||||||||||||||||
306 | - | |||||||||||||||||||
307 | class ColoredMaterialData : public ImageMaterialData {}; | - | ||||||||||||||||||
308 | class ColoredMaterial : public QSGSimpleMaterialShader<ColoredMaterialData> | - | ||||||||||||||||||
309 | { | - | ||||||||||||||||||
310 | QSG_DECLARE_SIMPLE_SHADER(ColoredMaterial, ColoredMaterialData) executed 4 times by 1 test: return new ColoredMaterial; Executed by:
executed 4 times by 1 test: return new QSGSimpleMaterial<ColoredMaterialData>(createShader); Executed by:
| 4 | ||||||||||||||||||
311 | - | |||||||||||||||||||
312 | public: | - | ||||||||||||||||||
313 | ColoredMaterial() | - | ||||||||||||||||||
314 | { | - | ||||||||||||||||||
315 | QSGShaderSourceBuilder builder; | - | ||||||||||||||||||
316 | const bool isES = QOpenGLContext::currentContext()->isOpenGLES(); | - | ||||||||||||||||||
317 | - | |||||||||||||||||||
318 | builder.appendSourceFile(QStringLiteral(":/particles/shaders/imageparticle.vert")); executed 4 times by 1 test: return qstring_literal_temp; Executed by:
| 4 | ||||||||||||||||||
319 | builder.addDefinition(QByteArrayLiteral("COLOR")); executed 4 times by 1 test: return ba; Executed by:
| 4 | ||||||||||||||||||
320 | if (isES)
| 0-4 | ||||||||||||||||||
321 | builder.removeVersion(); never executed: builder.removeVersion(); | 0 | ||||||||||||||||||
322 | - | |||||||||||||||||||
323 | m_vertex_code = builder.source(); | - | ||||||||||||||||||
324 | builder.clear(); | - | ||||||||||||||||||
325 | - | |||||||||||||||||||
326 | builder.appendSourceFile(QStringLiteral(":/particles/shaders/imageparticle.frag")); executed 4 times by 1 test: return qstring_literal_temp; Executed by:
| 4 | ||||||||||||||||||
327 | builder.addDefinition(QByteArrayLiteral("COLOR")); executed 4 times by 1 test: return ba; Executed by:
| 4 | ||||||||||||||||||
328 | if (isES)
| 0-4 | ||||||||||||||||||
329 | builder.removeVersion(); never executed: builder.removeVersion(); | 0 | ||||||||||||||||||
330 | - | |||||||||||||||||||
331 | m_fragment_code = builder.source(); | - | ||||||||||||||||||
332 | - | |||||||||||||||||||
333 | Q_ASSERT(!m_vertex_code.isNull()); | - | ||||||||||||||||||
334 | Q_ASSERT(!m_fragment_code.isNull()); | - | ||||||||||||||||||
335 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||
336 | - | |||||||||||||||||||
337 | const char *vertexShader() const override { return m_vertex_code.constData(); } executed 4 times by 1 test: return m_vertex_code.constData(); Executed by:
| 4 | ||||||||||||||||||
338 | const char *fragmentShader() const override { return m_fragment_code.constData(); } executed 4 times by 1 test: return m_fragment_code.constData(); Executed by:
| 4 | ||||||||||||||||||
339 | - | |||||||||||||||||||
340 | void activate() override { | - | ||||||||||||||||||
341 | QSGSimpleMaterialShader<ColoredMaterialData>::activate(); | - | ||||||||||||||||||
342 | #if !defined(QT_OPENGL_ES_2) && !defined(Q_OS_WIN) | - | ||||||||||||||||||
343 | glEnable(GL_POINT_SPRITE); | - | ||||||||||||||||||
344 | glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); | - | ||||||||||||||||||
345 | #endif | - | ||||||||||||||||||
346 | } executed 258 times by 1 test: end of block Executed by:
| 258 | ||||||||||||||||||
347 | - | |||||||||||||||||||
348 | void deactivate() override { | - | ||||||||||||||||||
349 | QSGSimpleMaterialShader<ColoredMaterialData>::deactivate(); | - | ||||||||||||||||||
350 | #if !defined(QT_OPENGL_ES_2) && !defined(Q_OS_WIN) | - | ||||||||||||||||||
351 | glDisable(GL_POINT_SPRITE); | - | ||||||||||||||||||
352 | glDisable(GL_VERTEX_PROGRAM_POINT_SIZE); | - | ||||||||||||||||||
353 | #endif | - | ||||||||||||||||||
354 | } executed 258 times by 1 test: end of block Executed by:
| 258 | ||||||||||||||||||
355 | - | |||||||||||||||||||
356 | QList<QByteArray> attributes() const override { | - | ||||||||||||||||||
357 | return QList<QByteArray>() << "vPos" << "vData" << "vVec" << "vColor"; executed 4 times by 1 test: return QList<QByteArray>() << "vPos" << "vData" << "vVec" << "vColor"; Executed by:
| 4 | ||||||||||||||||||
358 | } | - | ||||||||||||||||||
359 | - | |||||||||||||||||||
360 | void initialize() override { | - | ||||||||||||||||||
361 | QSGSimpleMaterialShader<ColoredMaterialData>::initialize(); | - | ||||||||||||||||||
362 | program()->bind(); | - | ||||||||||||||||||
363 | program()->setUniformValue("_qt_texture", 0); | - | ||||||||||||||||||
364 | glFuncs = QOpenGLContext::currentContext()->functions(); | - | ||||||||||||||||||
365 | m_timestamp_id = program()->uniformLocation("timestamp"); | - | ||||||||||||||||||
366 | m_entry_id = program()->uniformLocation("entry"); | - | ||||||||||||||||||
367 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||
368 | - | |||||||||||||||||||
369 | void updateState(const ColoredMaterialData* d, const ColoredMaterialData*) override { | - | ||||||||||||||||||
370 | d->texture->bind(); | - | ||||||||||||||||||
371 | - | |||||||||||||||||||
372 | program()->setUniformValue(m_timestamp_id, (float) d->timestamp); | - | ||||||||||||||||||
373 | program()->setUniformValue(m_entry_id, (float) d->entry); | - | ||||||||||||||||||
374 | } executed 258 times by 1 test: end of block Executed by:
| 258 | ||||||||||||||||||
375 | - | |||||||||||||||||||
376 | int m_timestamp_id; | - | ||||||||||||||||||
377 | int m_entry_id; | - | ||||||||||||||||||
378 | QByteArray m_vertex_code; | - | ||||||||||||||||||
379 | QByteArray m_fragment_code; | - | ||||||||||||||||||
380 | QOpenGLFunctions* glFuncs; | - | ||||||||||||||||||
381 | }; | - | ||||||||||||||||||
382 | - | |||||||||||||||||||
383 | class SimpleMaterialData : public ImageMaterialData {}; | - | ||||||||||||||||||
384 | class SimpleMaterial : public QSGSimpleMaterialShader<SimpleMaterialData> | - | ||||||||||||||||||
385 | { | - | ||||||||||||||||||
386 | QSG_DECLARE_SIMPLE_SHADER(SimpleMaterial, SimpleMaterialData) executed 48 times by 20 tests: return new SimpleMaterial; Executed by:
executed 83 times by 20 tests: return new QSGSimpleMaterial<SimpleMaterialData>(createShader); Executed by:
| 48-83 | ||||||||||||||||||
387 | - | |||||||||||||||||||
388 | public: | - | ||||||||||||||||||
389 | SimpleMaterial() | - | ||||||||||||||||||
390 | { | - | ||||||||||||||||||
391 | QSGShaderSourceBuilder builder; | - | ||||||||||||||||||
392 | const bool isES = QOpenGLContext::currentContext()->isOpenGLES(); | - | ||||||||||||||||||
393 | - | |||||||||||||||||||
394 | builder.appendSourceFile(QStringLiteral(":/particles/shaders/imageparticle.vert")); executed 48 times by 20 tests: return qstring_literal_temp; Executed by:
| 48 | ||||||||||||||||||
395 | if (isES)
| 0-48 | ||||||||||||||||||
396 | builder.removeVersion(); never executed: builder.removeVersion(); | 0 | ||||||||||||||||||
397 | - | |||||||||||||||||||
398 | m_vertex_code = builder.source(); | - | ||||||||||||||||||
399 | builder.clear(); | - | ||||||||||||||||||
400 | - | |||||||||||||||||||
401 | builder.appendSourceFile(QStringLiteral(":/particles/shaders/imageparticle.frag")); executed 48 times by 20 tests: return qstring_literal_temp; Executed by:
| 48 | ||||||||||||||||||
402 | if (isES)
| 0-48 | ||||||||||||||||||
403 | builder.removeVersion(); never executed: builder.removeVersion(); | 0 | ||||||||||||||||||
404 | - | |||||||||||||||||||
405 | m_fragment_code = builder.source(); | - | ||||||||||||||||||
406 | - | |||||||||||||||||||
407 | Q_ASSERT(!m_vertex_code.isNull()); | - | ||||||||||||||||||
408 | Q_ASSERT(!m_fragment_code.isNull()); | - | ||||||||||||||||||
409 | } executed 48 times by 20 tests: end of block Executed by:
| 48 | ||||||||||||||||||
410 | - | |||||||||||||||||||
411 | const char *vertexShader() const override { return m_vertex_code.constData(); } executed 48 times by 20 tests: return m_vertex_code.constData(); Executed by:
| 48 | ||||||||||||||||||
412 | const char *fragmentShader() const override { return m_fragment_code.constData(); } executed 48 times by 20 tests: return m_fragment_code.constData(); Executed by:
| 48 | ||||||||||||||||||
413 | - | |||||||||||||||||||
414 | void activate() override { | - | ||||||||||||||||||
415 | QSGSimpleMaterialShader<SimpleMaterialData>::activate(); | - | ||||||||||||||||||
416 | #if !defined(QT_OPENGL_ES_2) && !defined(Q_OS_WIN) | - | ||||||||||||||||||
417 | glEnable(GL_POINT_SPRITE); | - | ||||||||||||||||||
418 | glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); | - | ||||||||||||||||||
419 | #endif | - | ||||||||||||||||||
420 | } executed 2952 times by 20 tests: end of block Executed by:
| 2952 | ||||||||||||||||||
421 | - | |||||||||||||||||||
422 | void deactivate() override { | - | ||||||||||||||||||
423 | QSGSimpleMaterialShader<SimpleMaterialData>::deactivate(); | - | ||||||||||||||||||
424 | #if !defined(QT_OPENGL_ES_2) && !defined(Q_OS_WIN) | - | ||||||||||||||||||
425 | glDisable(GL_POINT_SPRITE); | - | ||||||||||||||||||
426 | glDisable(GL_VERTEX_PROGRAM_POINT_SIZE); | - | ||||||||||||||||||
427 | #endif | - | ||||||||||||||||||
428 | } executed 2952 times by 20 tests: end of block Executed by:
| 2952 | ||||||||||||||||||
429 | - | |||||||||||||||||||
430 | QList<QByteArray> attributes() const override { | - | ||||||||||||||||||
431 | return QList<QByteArray>() << "vPos" << "vData" << "vVec"; executed 48 times by 20 tests: return QList<QByteArray>() << "vPos" << "vData" << "vVec"; Executed by:
| 48 | ||||||||||||||||||
432 | } | - | ||||||||||||||||||
433 | - | |||||||||||||||||||
434 | void initialize() override { | - | ||||||||||||||||||
435 | QSGSimpleMaterialShader<SimpleMaterialData>::initialize(); | - | ||||||||||||||||||
436 | program()->bind(); | - | ||||||||||||||||||
437 | program()->setUniformValue("_qt_texture", 0); | - | ||||||||||||||||||
438 | glFuncs = QOpenGLContext::currentContext()->functions(); | - | ||||||||||||||||||
439 | m_timestamp_id = program()->uniformLocation("timestamp"); | - | ||||||||||||||||||
440 | m_entry_id = program()->uniformLocation("entry"); | - | ||||||||||||||||||
441 | } executed 48 times by 20 tests: end of block Executed by:
| 48 | ||||||||||||||||||
442 | - | |||||||||||||||||||
443 | void updateState(const SimpleMaterialData* d, const SimpleMaterialData*) override { | - | ||||||||||||||||||
444 | d->texture->bind(); | - | ||||||||||||||||||
445 | - | |||||||||||||||||||
446 | program()->setUniformValue(m_timestamp_id, (float) d->timestamp); | - | ||||||||||||||||||
447 | program()->setUniformValue(m_entry_id, (float) d->entry); | - | ||||||||||||||||||
448 | } executed 3635 times by 20 tests: end of block Executed by:
| 3635 | ||||||||||||||||||
449 | - | |||||||||||||||||||
450 | int m_timestamp_id; | - | ||||||||||||||||||
451 | int m_entry_id; | - | ||||||||||||||||||
452 | QByteArray m_vertex_code; | - | ||||||||||||||||||
453 | QByteArray m_fragment_code; | - | ||||||||||||||||||
454 | QOpenGLFunctions* glFuncs; | - | ||||||||||||||||||
455 | }; | - | ||||||||||||||||||
456 | - | |||||||||||||||||||
457 | void fillUniformArrayFromImage(float* array, const QImage& img, int size) | - | ||||||||||||||||||
458 | { | - | ||||||||||||||||||
459 | if (img.isNull()){
| 4-8 | ||||||||||||||||||
460 | for (int i=0; i<size; i++)
| 8-512 | ||||||||||||||||||
461 | array[i] = 1.0; executed 512 times by 2 tests: array[i] = 1.0; Executed by:
| 512 | ||||||||||||||||||
462 | return; executed 8 times by 2 tests: return; Executed by:
| 8 | ||||||||||||||||||
463 | } | - | ||||||||||||||||||
464 | QImage scaled = img.scaled(size,1); | - | ||||||||||||||||||
465 | for (int i=0; i<size; i++)
| 4-256 | ||||||||||||||||||
466 | array[i] = qAlpha(scaled.pixel(i,0))/255.0; executed 256 times by 1 test: array[i] = qAlpha(scaled.pixel(i,0))/255.0; Executed by:
| 256 | ||||||||||||||||||
467 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||
468 | - | |||||||||||||||||||
469 | /*! | - | ||||||||||||||||||
470 | \qmltype ImageParticle | - | ||||||||||||||||||
471 | \instantiates QQuickImageParticle | - | ||||||||||||||||||
472 | \inqmlmodule QtQuick.Particles | - | ||||||||||||||||||
473 | \inherits ParticlePainter | - | ||||||||||||||||||
474 | \brief For visualizing logical particles using an image. | - | ||||||||||||||||||
475 | \ingroup qtquick-particles | - | ||||||||||||||||||
476 | - | |||||||||||||||||||
477 | This element renders a logical particle as an image. The image can be | - | ||||||||||||||||||
478 | \list | - | ||||||||||||||||||
479 | \li colorized | - | ||||||||||||||||||
480 | \li rotated | - | ||||||||||||||||||
481 | \li deformed | - | ||||||||||||||||||
482 | \li a sprite-based animation | - | ||||||||||||||||||
483 | \endlist | - | ||||||||||||||||||
484 | - | |||||||||||||||||||
485 | ImageParticles implictly share data on particles if multiple ImageParticles are painting | - | ||||||||||||||||||
486 | the same logical particle group. This is broken down along the four capabilities listed | - | ||||||||||||||||||
487 | above. So if one ImageParticle defines data for rendering the particles in one of those | - | ||||||||||||||||||
488 | capabilities, and the other does not, then both will draw the particles the same in that | - | ||||||||||||||||||
489 | aspect automatically. This is primarily useful when there is some random variation on | - | ||||||||||||||||||
490 | the particle which is supposed to stay with it when switching painters. If both ImageParticles | - | ||||||||||||||||||
491 | define how they should appear for that aspect, they diverge and each appears as it is defined. | - | ||||||||||||||||||
492 | - | |||||||||||||||||||
493 | This sharing of data happens behind the scenes based off of whether properties were implicitly or explicitly | - | ||||||||||||||||||
494 | set. One drawback of the current implementation is that it is only possible to reset the capabilities as a whole. | - | ||||||||||||||||||
495 | So if you explicitly set an attribute affecting color, such as redVariation, and then reset it (by setting redVariation | - | ||||||||||||||||||
496 | to undefined), all color data will be reset and it will begin to have an implicit value of any shared color from | - | ||||||||||||||||||
497 | other ImageParticles. | - | ||||||||||||||||||
498 | - | |||||||||||||||||||
499 | \note The maximum number of image particles is limited to 16383. | - | ||||||||||||||||||
500 | */ | - | ||||||||||||||||||
501 | /*! | - | ||||||||||||||||||
502 | \qmlproperty url QtQuick.Particles::ImageParticle::source | - | ||||||||||||||||||
503 | - | |||||||||||||||||||
504 | The source image to be used. | - | ||||||||||||||||||
505 | - | |||||||||||||||||||
506 | If the image is a sprite animation, use the sprite property instead. | - | ||||||||||||||||||
507 | - | |||||||||||||||||||
508 | Since Qt 5.2, some default images are provided as resources to aid prototyping: | - | ||||||||||||||||||
509 | \table | - | ||||||||||||||||||
510 | \row | - | ||||||||||||||||||
511 | \li qrc:///particleresources/star.png | - | ||||||||||||||||||
512 | \li \inlineimage particles/star.png | - | ||||||||||||||||||
513 | \row | - | ||||||||||||||||||
514 | \li qrc:///particleresources/glowdot.png | - | ||||||||||||||||||
515 | \li \inlineimage particles/glowdot.png | - | ||||||||||||||||||
516 | \row | - | ||||||||||||||||||
517 | \li qrc:///particleresources/fuzzydot.png | - | ||||||||||||||||||
518 | \li \inlineimage particles/fuzzydot.png | - | ||||||||||||||||||
519 | \endtable | - | ||||||||||||||||||
520 | - | |||||||||||||||||||
521 | Note that the images are white and semi-transparent, to allow colorization | - | ||||||||||||||||||
522 | and alpha levels to have maximum effect. | - | ||||||||||||||||||
523 | */ | - | ||||||||||||||||||
524 | /*! | - | ||||||||||||||||||
525 | \qmlproperty list<Sprite> QtQuick.Particles::ImageParticle::sprites | - | ||||||||||||||||||
526 | - | |||||||||||||||||||
527 | The sprite or sprites used to draw this particle. | - | ||||||||||||||||||
528 | - | |||||||||||||||||||
529 | Note that the sprite image will be scaled to a square based on the size of | - | ||||||||||||||||||
530 | the particle being rendered. | - | ||||||||||||||||||
531 | - | |||||||||||||||||||
532 | For full details, see the \l{Sprite Animations} overview. | - | ||||||||||||||||||
533 | */ | - | ||||||||||||||||||
534 | /*! | - | ||||||||||||||||||
535 | \qmlproperty url QtQuick.Particles::ImageParticle::colorTable | - | ||||||||||||||||||
536 | - | |||||||||||||||||||
537 | An image whose color will be used as a 1D texture to determine color over life. E.g. when | - | ||||||||||||||||||
538 | the particle is halfway through its lifetime, it will have the color specified halfway | - | ||||||||||||||||||
539 | across the image. | - | ||||||||||||||||||
540 | - | |||||||||||||||||||
541 | This color is blended with the color property and the color of the source image. | - | ||||||||||||||||||
542 | */ | - | ||||||||||||||||||
543 | /*! | - | ||||||||||||||||||
544 | \qmlproperty url QtQuick.Particles::ImageParticle::sizeTable | - | ||||||||||||||||||
545 | - | |||||||||||||||||||
546 | An image whose opacity will be used as a 1D texture to determine size over life. | - | ||||||||||||||||||
547 | - | |||||||||||||||||||
548 | This property is expected to be removed shortly, in favor of custom easing curves to determine size over life. | - | ||||||||||||||||||
549 | */ | - | ||||||||||||||||||
550 | /*! | - | ||||||||||||||||||
551 | \qmlproperty url QtQuick.Particles::ImageParticle::opacityTable | - | ||||||||||||||||||
552 | - | |||||||||||||||||||
553 | An image whose opacity will be used as a 1D texture to determine size over life. | - | ||||||||||||||||||
554 | - | |||||||||||||||||||
555 | This property is expected to be removed shortly, in favor of custom easing curves to determine opacity over life. | - | ||||||||||||||||||
556 | */ | - | ||||||||||||||||||
557 | /*! | - | ||||||||||||||||||
558 | \qmlproperty color QtQuick.Particles::ImageParticle::color | - | ||||||||||||||||||
559 | - | |||||||||||||||||||
560 | If a color is specified, the provided image will be colorized with it. | - | ||||||||||||||||||
561 | - | |||||||||||||||||||
562 | Default is white (no change). | - | ||||||||||||||||||
563 | */ | - | ||||||||||||||||||
564 | /*! | - | ||||||||||||||||||
565 | \qmlproperty real QtQuick.Particles::ImageParticle::colorVariation | - | ||||||||||||||||||
566 | - | |||||||||||||||||||
567 | This number represents the color variation applied to individual particles. | - | ||||||||||||||||||
568 | Setting colorVariation is the same as setting redVariation, greenVariation, | - | ||||||||||||||||||
569 | and blueVariation to the same number. | - | ||||||||||||||||||
570 | - | |||||||||||||||||||
571 | Each channel can vary between particle by up to colorVariation from its usual color. | - | ||||||||||||||||||
572 | - | |||||||||||||||||||
573 | Color is measured, per channel, from 0.0 to 1.0. | - | ||||||||||||||||||
574 | - | |||||||||||||||||||
575 | Default is 0.0 | - | ||||||||||||||||||
576 | */ | - | ||||||||||||||||||
577 | /*! | - | ||||||||||||||||||
578 | \qmlproperty real QtQuick.Particles::ImageParticle::redVariation | - | ||||||||||||||||||
579 | The variation in the red color channel between particles. | - | ||||||||||||||||||
580 | - | |||||||||||||||||||
581 | Color is measured, per channel, from 0.0 to 1.0. | - | ||||||||||||||||||
582 | - | |||||||||||||||||||
583 | Default is 0.0 | - | ||||||||||||||||||
584 | */ | - | ||||||||||||||||||
585 | /*! | - | ||||||||||||||||||
586 | \qmlproperty real QtQuick.Particles::ImageParticle::greenVariation | - | ||||||||||||||||||
587 | The variation in the green color channel between particles. | - | ||||||||||||||||||
588 | - | |||||||||||||||||||
589 | Color is measured, per channel, from 0.0 to 1.0. | - | ||||||||||||||||||
590 | - | |||||||||||||||||||
591 | Default is 0.0 | - | ||||||||||||||||||
592 | */ | - | ||||||||||||||||||
593 | /*! | - | ||||||||||||||||||
594 | \qmlproperty real QtQuick.Particles::ImageParticle::blueVariation | - | ||||||||||||||||||
595 | The variation in the blue color channel between particles. | - | ||||||||||||||||||
596 | - | |||||||||||||||||||
597 | Color is measured, per channel, from 0.0 to 1.0. | - | ||||||||||||||||||
598 | - | |||||||||||||||||||
599 | Default is 0.0 | - | ||||||||||||||||||
600 | */ | - | ||||||||||||||||||
601 | /*! | - | ||||||||||||||||||
602 | \qmlproperty real QtQuick.Particles::ImageParticle::alpha | - | ||||||||||||||||||
603 | An alpha to be applied to the image. This value is multiplied by the value in | - | ||||||||||||||||||
604 | the image, and the value in the color property. | - | ||||||||||||||||||
605 | - | |||||||||||||||||||
606 | Particles have additive blending, so lower alpha on single particles leads | - | ||||||||||||||||||
607 | to stronger effects when multiple particles overlap. | - | ||||||||||||||||||
608 | - | |||||||||||||||||||
609 | Alpha is measured from 0.0 to 1.0. | - | ||||||||||||||||||
610 | - | |||||||||||||||||||
611 | Default is 1.0 | - | ||||||||||||||||||
612 | */ | - | ||||||||||||||||||
613 | /*! | - | ||||||||||||||||||
614 | \qmlproperty real QtQuick.Particles::ImageParticle::alphaVariation | - | ||||||||||||||||||
615 | The variation in the alpha channel between particles. | - | ||||||||||||||||||
616 | - | |||||||||||||||||||
617 | Alpha is measured from 0.0 to 1.0. | - | ||||||||||||||||||
618 | - | |||||||||||||||||||
619 | Default is 0.0 | - | ||||||||||||||||||
620 | */ | - | ||||||||||||||||||
621 | /*! | - | ||||||||||||||||||
622 | \qmlproperty real QtQuick.Particles::ImageParticle::rotation | - | ||||||||||||||||||
623 | - | |||||||||||||||||||
624 | If set the image will be rotated by this many degrees before it is drawn. | - | ||||||||||||||||||
625 | - | |||||||||||||||||||
626 | The particle coordinates are not transformed. | - | ||||||||||||||||||
627 | */ | - | ||||||||||||||||||
628 | /*! | - | ||||||||||||||||||
629 | \qmlproperty real QtQuick.Particles::ImageParticle::rotationVariation | - | ||||||||||||||||||
630 | - | |||||||||||||||||||
631 | If set the rotation of individual particles will vary by up to this much | - | ||||||||||||||||||
632 | between particles. | - | ||||||||||||||||||
633 | - | |||||||||||||||||||
634 | */ | - | ||||||||||||||||||
635 | /*! | - | ||||||||||||||||||
636 | \qmlproperty real QtQuick.Particles::ImageParticle::rotationVelocity | - | ||||||||||||||||||
637 | - | |||||||||||||||||||
638 | If set particles will rotate at this velocity in degrees/second. | - | ||||||||||||||||||
639 | */ | - | ||||||||||||||||||
640 | /*! | - | ||||||||||||||||||
641 | \qmlproperty real QtQuick.Particles::ImageParticle::rotationVelocityVariation | - | ||||||||||||||||||
642 | - | |||||||||||||||||||
643 | If set the rotationVelocity of individual particles will vary by up to this much | - | ||||||||||||||||||
644 | between particles. | - | ||||||||||||||||||
645 | - | |||||||||||||||||||
646 | */ | - | ||||||||||||||||||
647 | /*! | - | ||||||||||||||||||
648 | \qmlproperty bool QtQuick.Particles::ImageParticle::autoRotation | - | ||||||||||||||||||
649 | - | |||||||||||||||||||
650 | If set to true then a rotation will be applied on top of the particles rotation, so | - | ||||||||||||||||||
651 | that it faces the direction of travel. So to face away from the direction of travel, | - | ||||||||||||||||||
652 | set autoRotation to true and rotation to 180. | - | ||||||||||||||||||
653 | - | |||||||||||||||||||
654 | Default is false | - | ||||||||||||||||||
655 | */ | - | ||||||||||||||||||
656 | /*! | - | ||||||||||||||||||
657 | \qmlproperty StochasticDirection QtQuick.Particles::ImageParticle::xVector | - | ||||||||||||||||||
658 | - | |||||||||||||||||||
659 | Allows you to deform the particle image when drawn. The rectangular image will | - | ||||||||||||||||||
660 | be deformed so that the horizontal sides are in the shape of this vector instead | - | ||||||||||||||||||
661 | of (1,0). | - | ||||||||||||||||||
662 | */ | - | ||||||||||||||||||
663 | /*! | - | ||||||||||||||||||
664 | \qmlproperty StochasticDirection QtQuick.Particles::ImageParticle::yVector | - | ||||||||||||||||||
665 | - | |||||||||||||||||||
666 | Allows you to deform the particle image when drawn. The rectangular image will | - | ||||||||||||||||||
667 | be deformed so that the vertical sides are in the shape of this vector instead | - | ||||||||||||||||||
668 | of (0,1). | - | ||||||||||||||||||
669 | */ | - | ||||||||||||||||||
670 | /*! | - | ||||||||||||||||||
671 | \qmlproperty EntryEffect QtQuick.Particles::ImageParticle::entryEffect | - | ||||||||||||||||||
672 | - | |||||||||||||||||||
673 | This property provides basic and cheap entrance and exit effects for the particles. | - | ||||||||||||||||||
674 | For fine-grained control, see sizeTable and opacityTable. | - | ||||||||||||||||||
675 | - | |||||||||||||||||||
676 | Acceptable values are | - | ||||||||||||||||||
677 | \list | - | ||||||||||||||||||
678 | \li ImageParticle.None: Particles just appear and disappear. | - | ||||||||||||||||||
679 | \li ImageParticle.Fade: Particles fade in from 0 opacity at the start of their life, and fade out to 0 at the end. | - | ||||||||||||||||||
680 | \li ImageParticle.Scale: Particles scale in from 0 size at the start of their life, and scale back to 0 at the end. | - | ||||||||||||||||||
681 | \endlist | - | ||||||||||||||||||
682 | - | |||||||||||||||||||
683 | Default value is Fade. | - | ||||||||||||||||||
684 | */ | - | ||||||||||||||||||
685 | /*! | - | ||||||||||||||||||
686 | \qmlproperty bool QtQuick.Particles::ImageParticle::spritesInterpolate | - | ||||||||||||||||||
687 | - | |||||||||||||||||||
688 | If set to true, sprite particles will interpolate between sprite frames each rendered frame, making | - | ||||||||||||||||||
689 | the sprites look smoother. | - | ||||||||||||||||||
690 | - | |||||||||||||||||||
691 | Default is true. | - | ||||||||||||||||||
692 | */ | - | ||||||||||||||||||
693 | - | |||||||||||||||||||
694 | /*! | - | ||||||||||||||||||
695 | \qmlproperty Status QtQuick.Particles::ImageParticle::status | - | ||||||||||||||||||
696 | - | |||||||||||||||||||
697 | The status of loading the image. | - | ||||||||||||||||||
698 | */ | - | ||||||||||||||||||
699 | - | |||||||||||||||||||
700 | - | |||||||||||||||||||
701 | QQuickImageParticle::QQuickImageParticle(QQuickItem* parent) | - | ||||||||||||||||||
702 | : QQuickParticlePainter(parent) | - | ||||||||||||||||||
703 | , m_color_variation(0.0) | - | ||||||||||||||||||
704 | , m_material(nullptr) | - | ||||||||||||||||||
705 | , m_alphaVariation(0.0) | - | ||||||||||||||||||
706 | , m_alpha(1.0) | - | ||||||||||||||||||
707 | , m_redVariation(0.0) | - | ||||||||||||||||||
708 | , m_greenVariation(0.0) | - | ||||||||||||||||||
709 | , m_blueVariation(0.0) | - | ||||||||||||||||||
710 | , m_rotation(0) | - | ||||||||||||||||||
711 | , m_rotationVariation(0) | - | ||||||||||||||||||
712 | , m_rotationVelocity(0) | - | ||||||||||||||||||
713 | , m_rotationVelocityVariation(0) | - | ||||||||||||||||||
714 | , m_autoRotation(false) | - | ||||||||||||||||||
715 | , m_xVector(nullptr) | - | ||||||||||||||||||
716 | , m_yVector(nullptr) | - | ||||||||||||||||||
717 | , m_spriteEngine(nullptr) | - | ||||||||||||||||||
718 | , m_spritesInterpolate(true) | - | ||||||||||||||||||
719 | , m_explicitColor(false) | - | ||||||||||||||||||
720 | , m_explicitRotation(false) | - | ||||||||||||||||||
721 | , m_explicitDeformation(false) | - | ||||||||||||||||||
722 | , m_explicitAnimation(false) | - | ||||||||||||||||||
723 | , m_bypassOptimizations(false) | - | ||||||||||||||||||
724 | , perfLevel(Unknown) | - | ||||||||||||||||||
725 | , m_lastLevel(Unknown) | - | ||||||||||||||||||
726 | , m_debugMode(false) | - | ||||||||||||||||||
727 | , m_entryEffect(Fade) | - | ||||||||||||||||||
728 | , m_startedImageLoading(0) | - | ||||||||||||||||||
729 | { | - | ||||||||||||||||||
730 | setFlag(ItemHasContents); | - | ||||||||||||||||||
731 | } executed 202 times by 22 tests: end of block Executed by:
| 202 | ||||||||||||||||||
732 | - | |||||||||||||||||||
733 | QQuickImageParticle::~QQuickImageParticle() | - | ||||||||||||||||||
734 | { | - | ||||||||||||||||||
735 | clearShadows(); | - | ||||||||||||||||||
736 | } executed 202 times by 22 tests: end of block Executed by:
| 202 | ||||||||||||||||||
737 | - | |||||||||||||||||||
738 | QQmlListProperty<QQuickSprite> QQuickImageParticle::sprites() | - | ||||||||||||||||||
739 | { | - | ||||||||||||||||||
740 | return QQmlListProperty<QQuickSprite>(this, &m_sprites, spriteAppend, spriteCount, spriteAt, spriteClear); executed 22 times by 3 tests: return QQmlListProperty<QQuickSprite>(this, &m_sprites, spriteAppend, spriteCount, spriteAt, spriteClear); Executed by:
| 22 | ||||||||||||||||||
741 | } | - | ||||||||||||||||||
742 | - | |||||||||||||||||||
743 | void QQuickImageParticle::sceneGraphInvalidated() | - | ||||||||||||||||||
744 | { | - | ||||||||||||||||||
745 | m_nodes.clear(); | - | ||||||||||||||||||
746 | m_material = nullptr; | - | ||||||||||||||||||
747 | } never executed: end of block | 0 | ||||||||||||||||||
748 | - | |||||||||||||||||||
749 | void QQuickImageParticle::setImage(const QUrl &image) | - | ||||||||||||||||||
750 | { | - | ||||||||||||||||||
751 | if (image.isEmpty()){
| 0-180 | ||||||||||||||||||
752 | if (m_image) {
| 0 | ||||||||||||||||||
753 | m_image.reset(); | - | ||||||||||||||||||
754 | emit imageChanged(); | - | ||||||||||||||||||
755 | } never executed: end of block | 0 | ||||||||||||||||||
756 | return; never executed: return; | 0 | ||||||||||||||||||
757 | } | - | ||||||||||||||||||
758 | - | |||||||||||||||||||
759 | if (!m_image)
| 0-180 | ||||||||||||||||||
760 | m_image.reset(new ImageData); executed 180 times by 21 tests: m_image.reset(new ImageData); Executed by:
| 180 | ||||||||||||||||||
761 | if (image == m_image->source)
| 0-180 | ||||||||||||||||||
762 | return; never executed: return; | 0 | ||||||||||||||||||
763 | m_image->source = image; | - | ||||||||||||||||||
764 | emit imageChanged(); | - | ||||||||||||||||||
765 | reset(); | - | ||||||||||||||||||
766 | } executed 180 times by 21 tests: end of block Executed by:
| 180 | ||||||||||||||||||
767 | - | |||||||||||||||||||
768 | - | |||||||||||||||||||
769 | void QQuickImageParticle::setColortable(const QUrl &table) | - | ||||||||||||||||||
770 | { | - | ||||||||||||||||||
771 | if (table.isEmpty()){
| 0-6 | ||||||||||||||||||
772 | if (m_colorTable) {
| 0 | ||||||||||||||||||
773 | m_colorTable.reset(); | - | ||||||||||||||||||
774 | emit colortableChanged(); | - | ||||||||||||||||||
775 | } never executed: end of block | 0 | ||||||||||||||||||
776 | return; never executed: return; | 0 | ||||||||||||||||||
777 | } | - | ||||||||||||||||||
778 | - | |||||||||||||||||||
779 | if (!m_colorTable)
| 0-6 | ||||||||||||||||||
780 | m_colorTable.reset(new ImageData); executed 6 times by 2 tests: m_colorTable.reset(new ImageData); Executed by:
| 6 | ||||||||||||||||||
781 | if (table == m_colorTable->source)
| 0-6 | ||||||||||||||||||
782 | return; never executed: return; | 0 | ||||||||||||||||||
783 | m_colorTable->source = table; | - | ||||||||||||||||||
784 | emit colortableChanged(); | - | ||||||||||||||||||
785 | reset(); | - | ||||||||||||||||||
786 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||||||||
787 | - | |||||||||||||||||||
788 | void QQuickImageParticle::setSizetable(const QUrl &table) | - | ||||||||||||||||||
789 | { | - | ||||||||||||||||||
790 | if (table.isEmpty()){
| 0-6 | ||||||||||||||||||
791 | if (m_sizeTable) {
| 0 | ||||||||||||||||||
792 | m_sizeTable.reset(); | - | ||||||||||||||||||
793 | emit sizetableChanged(); | - | ||||||||||||||||||
794 | } never executed: end of block | 0 | ||||||||||||||||||
795 | return; never executed: return; | 0 | ||||||||||||||||||
796 | } | - | ||||||||||||||||||
797 | - | |||||||||||||||||||
798 | if (!m_sizeTable)
| 0-6 | ||||||||||||||||||
799 | m_sizeTable.reset(new ImageData); executed 6 times by 2 tests: m_sizeTable.reset(new ImageData); Executed by:
| 6 | ||||||||||||||||||
800 | if (table == m_sizeTable->source)
| 0-6 | ||||||||||||||||||
801 | return; never executed: return; | 0 | ||||||||||||||||||
802 | m_sizeTable->source = table; | - | ||||||||||||||||||
803 | emit sizetableChanged(); | - | ||||||||||||||||||
804 | reset(); | - | ||||||||||||||||||
805 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||||||||
806 | - | |||||||||||||||||||
807 | void QQuickImageParticle::setOpacitytable(const QUrl &table) | - | ||||||||||||||||||
808 | { | - | ||||||||||||||||||
809 | if (table.isEmpty()){
| 0-2 | ||||||||||||||||||
810 | if (m_opacityTable) {
| 0 | ||||||||||||||||||
811 | m_opacityTable.reset(); | - | ||||||||||||||||||
812 | emit opacitytableChanged(); | - | ||||||||||||||||||
813 | } never executed: end of block | 0 | ||||||||||||||||||
814 | return; never executed: return; | 0 | ||||||||||||||||||
815 | } | - | ||||||||||||||||||
816 | - | |||||||||||||||||||
817 | if (!m_opacityTable)
| 0-2 | ||||||||||||||||||
818 | m_opacityTable.reset(new ImageData); executed 2 times by 1 test: m_opacityTable.reset(new ImageData); Executed by:
| 2 | ||||||||||||||||||
819 | if (table == m_opacityTable->source)
| 0-2 | ||||||||||||||||||
820 | return; never executed: return; | 0 | ||||||||||||||||||
821 | m_opacityTable->source = table; | - | ||||||||||||||||||
822 | emit opacitytableChanged(); | - | ||||||||||||||||||
823 | reset(); | - | ||||||||||||||||||
824 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
825 | - | |||||||||||||||||||
826 | void QQuickImageParticle::setColor(const QColor &color) | - | ||||||||||||||||||
827 | { | - | ||||||||||||||||||
828 | if (color == m_color)
| 4-112 | ||||||||||||||||||
829 | return; executed 4 times by 1 test: return; Executed by:
| 4 | ||||||||||||||||||
830 | m_color = color; | - | ||||||||||||||||||
831 | emit colorChanged(); | - | ||||||||||||||||||
832 | m_explicitColor = true; | - | ||||||||||||||||||
833 | if (perfLevel < Colored)
| 0-112 | ||||||||||||||||||
834 | reset(); executed 112 times by 2 tests: reset(); Executed by:
| 112 | ||||||||||||||||||
835 | } executed 112 times by 2 tests: end of block Executed by:
| 112 | ||||||||||||||||||
836 | - | |||||||||||||||||||
837 | void QQuickImageParticle::setColorVariation(qreal var) | - | ||||||||||||||||||
838 | { | - | ||||||||||||||||||
839 | if (var == m_color_variation)
| 8-72 | ||||||||||||||||||
840 | return; executed 8 times by 1 test: return; Executed by:
| 8 | ||||||||||||||||||
841 | m_color_variation = var; | - | ||||||||||||||||||
842 | emit colorVariationChanged(); | - | ||||||||||||||||||
843 | m_explicitColor = true; | - | ||||||||||||||||||
844 | if (perfLevel < Colored)
| 0-72 | ||||||||||||||||||
845 | reset(); executed 72 times by 1 test: reset(); Executed by:
| 72 | ||||||||||||||||||
846 | } executed 72 times by 1 test: end of block Executed by:
| 72 | ||||||||||||||||||
847 | - | |||||||||||||||||||
848 | void QQuickImageParticle::setAlphaVariation(qreal arg) | - | ||||||||||||||||||
849 | { | - | ||||||||||||||||||
850 | if (m_alphaVariation != arg) {
| 0-6 | ||||||||||||||||||
851 | m_alphaVariation = arg; | - | ||||||||||||||||||
852 | emit alphaVariationChanged(arg); | - | ||||||||||||||||||
853 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||||||||
854 | m_explicitColor = true; | - | ||||||||||||||||||
855 | if (perfLevel < Colored)
| 0-6 | ||||||||||||||||||
856 | reset(); executed 6 times by 2 tests: reset(); Executed by:
| 6 | ||||||||||||||||||
857 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||||||||
858 | - | |||||||||||||||||||
859 | void QQuickImageParticle::setAlpha(qreal arg) | - | ||||||||||||||||||
860 | { | - | ||||||||||||||||||
861 | if (m_alpha != arg) {
| 2-64 | ||||||||||||||||||
862 | m_alpha = arg; | - | ||||||||||||||||||
863 | emit alphaChanged(arg); | - | ||||||||||||||||||
864 | } executed 64 times by 2 tests: end of block Executed by:
| 64 | ||||||||||||||||||
865 | m_explicitColor = true; | - | ||||||||||||||||||
866 | if (perfLevel < Colored)
| 0-66 | ||||||||||||||||||
867 | reset(); executed 66 times by 2 tests: reset(); Executed by:
| 66 | ||||||||||||||||||
868 | } executed 66 times by 2 tests: end of block Executed by:
| 66 | ||||||||||||||||||
869 | - | |||||||||||||||||||
870 | void QQuickImageParticle::setRedVariation(qreal arg) | - | ||||||||||||||||||
871 | { | - | ||||||||||||||||||
872 | if (m_redVariation != arg) {
| 0-6 | ||||||||||||||||||
873 | m_redVariation = arg; | - | ||||||||||||||||||
874 | emit redVariationChanged(arg); | - | ||||||||||||||||||
875 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||||||||
876 | m_explicitColor = true; | - | ||||||||||||||||||
877 | if (perfLevel < Colored)
| 0-6 | ||||||||||||||||||
878 | reset(); executed 6 times by 2 tests: reset(); Executed by:
| 6 | ||||||||||||||||||
879 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||||||||
880 | - | |||||||||||||||||||
881 | void QQuickImageParticle::setGreenVariation(qreal arg) | - | ||||||||||||||||||
882 | { | - | ||||||||||||||||||
883 | if (m_greenVariation != arg) {
| 0-4 | ||||||||||||||||||
884 | m_greenVariation = arg; | - | ||||||||||||||||||
885 | emit greenVariationChanged(arg); | - | ||||||||||||||||||
886 | } executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||||||||||||||
887 | m_explicitColor = true; | - | ||||||||||||||||||
888 | if (perfLevel < Colored)
| 0-4 | ||||||||||||||||||
889 | reset(); executed 4 times by 2 tests: reset(); Executed by:
| 4 | ||||||||||||||||||
890 | } executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||||||||||||||
891 | - | |||||||||||||||||||
892 | void QQuickImageParticle::setBlueVariation(qreal arg) | - | ||||||||||||||||||
893 | { | - | ||||||||||||||||||
894 | if (m_blueVariation != arg) {
| 0-6 | ||||||||||||||||||
895 | m_blueVariation = arg; | - | ||||||||||||||||||
896 | emit blueVariationChanged(arg); | - | ||||||||||||||||||
897 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||||||||
898 | m_explicitColor = true; | - | ||||||||||||||||||
899 | if (perfLevel < Colored)
| 0-6 | ||||||||||||||||||
900 | reset(); executed 6 times by 2 tests: reset(); Executed by:
| 6 | ||||||||||||||||||
901 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||||||||
902 | - | |||||||||||||||||||
903 | void QQuickImageParticle::setRotation(qreal arg) | - | ||||||||||||||||||
904 | { | - | ||||||||||||||||||
905 | if (m_rotation != arg) {
| 0-12 | ||||||||||||||||||
906 | m_rotation = arg; | - | ||||||||||||||||||
907 | emit rotationChanged(arg); | - | ||||||||||||||||||
908 | } executed 12 times by 3 tests: end of block Executed by:
| 12 | ||||||||||||||||||
909 | m_explicitRotation = true; | - | ||||||||||||||||||
910 | if (perfLevel < Deformable)
| 0-12 | ||||||||||||||||||
911 | reset(); executed 12 times by 3 tests: reset(); Executed by:
| 12 | ||||||||||||||||||
912 | } executed 12 times by 3 tests: end of block Executed by:
| 12 | ||||||||||||||||||
913 | - | |||||||||||||||||||
914 | void QQuickImageParticle::setRotationVariation(qreal arg) | - | ||||||||||||||||||
915 | { | - | ||||||||||||||||||
916 | if (m_rotationVariation != arg) {
| 0-2 | ||||||||||||||||||
917 | m_rotationVariation = arg; | - | ||||||||||||||||||
918 | emit rotationVariationChanged(arg); | - | ||||||||||||||||||
919 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
920 | m_explicitRotation = true; | - | ||||||||||||||||||
921 | if (perfLevel < Deformable)
| 0-2 | ||||||||||||||||||
922 | reset(); executed 2 times by 1 test: reset(); Executed by:
| 2 | ||||||||||||||||||
923 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
924 | - | |||||||||||||||||||
925 | void QQuickImageParticle::setRotationVelocity(qreal arg) | - | ||||||||||||||||||
926 | { | - | ||||||||||||||||||
927 | if (m_rotationVelocity != arg) {
| 0-4 | ||||||||||||||||||
928 | m_rotationVelocity = arg; | - | ||||||||||||||||||
929 | emit rotationVelocityChanged(arg); | - | ||||||||||||||||||
930 | } executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||||||||||||||
931 | m_explicitRotation = true; | - | ||||||||||||||||||
932 | if (perfLevel < Deformable)
| 0-4 | ||||||||||||||||||
933 | reset(); executed 4 times by 2 tests: reset(); Executed by:
| 4 | ||||||||||||||||||
934 | } executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||||||||||||||
935 | - | |||||||||||||||||||
936 | void QQuickImageParticle::setRotationVelocityVariation(qreal arg) | - | ||||||||||||||||||
937 | { | - | ||||||||||||||||||
938 | if (m_rotationVelocityVariation != arg) {
| 0-2 | ||||||||||||||||||
939 | m_rotationVelocityVariation = arg; | - | ||||||||||||||||||
940 | emit rotationVelocityVariationChanged(arg); | - | ||||||||||||||||||
941 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
942 | m_explicitRotation = true; | - | ||||||||||||||||||
943 | if (perfLevel < Deformable)
| 0-2 | ||||||||||||||||||
944 | reset(); executed 2 times by 1 test: reset(); Executed by:
| 2 | ||||||||||||||||||
945 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
946 | - | |||||||||||||||||||
947 | void QQuickImageParticle::setAutoRotation(bool arg) | - | ||||||||||||||||||
948 | { | - | ||||||||||||||||||
949 | if (m_autoRotation != arg) {
| 0-8 | ||||||||||||||||||
950 | m_autoRotation = arg; | - | ||||||||||||||||||
951 | emit autoRotationChanged(arg); | - | ||||||||||||||||||
952 | } executed 8 times by 2 tests: end of block Executed by:
| 8 | ||||||||||||||||||
953 | m_explicitRotation = true; | - | ||||||||||||||||||
954 | if (perfLevel < Deformable)
| 0-8 | ||||||||||||||||||
955 | reset(); executed 8 times by 2 tests: reset(); Executed by:
| 8 | ||||||||||||||||||
956 | } executed 8 times by 2 tests: end of block Executed by:
| 8 | ||||||||||||||||||
957 | - | |||||||||||||||||||
958 | void QQuickImageParticle::setXVector(QQuickDirection* arg) | - | ||||||||||||||||||
959 | { | - | ||||||||||||||||||
960 | if (m_xVector != arg) {
| 0-2 | ||||||||||||||||||
961 | m_xVector = arg; | - | ||||||||||||||||||
962 | emit xVectorChanged(arg); | - | ||||||||||||||||||
963 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
964 | m_explicitDeformation = true; | - | ||||||||||||||||||
965 | if (perfLevel < Deformable)
| 0-2 | ||||||||||||||||||
966 | reset(); executed 2 times by 1 test: reset(); Executed by:
| 2 | ||||||||||||||||||
967 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
968 | - | |||||||||||||||||||
969 | void QQuickImageParticle::setYVector(QQuickDirection* arg) | - | ||||||||||||||||||
970 | { | - | ||||||||||||||||||
971 | if (m_yVector != arg) {
| 0-4 | ||||||||||||||||||
972 | m_yVector = arg; | - | ||||||||||||||||||
973 | emit yVectorChanged(arg); | - | ||||||||||||||||||
974 | } executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||||||||||||||
975 | m_explicitDeformation = true; | - | ||||||||||||||||||
976 | if (perfLevel < Deformable)
| 0-4 | ||||||||||||||||||
977 | reset(); executed 4 times by 2 tests: reset(); Executed by:
| 4 | ||||||||||||||||||
978 | } executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||||||||||||||
979 | - | |||||||||||||||||||
980 | void QQuickImageParticle::setSpritesInterpolate(bool arg) | - | ||||||||||||||||||
981 | { | - | ||||||||||||||||||
982 | if (m_spritesInterpolate != arg) {
| 0-2 | ||||||||||||||||||
983 | m_spritesInterpolate = arg; | - | ||||||||||||||||||
984 | emit spritesInterpolateChanged(arg); | - | ||||||||||||||||||
985 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
986 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
987 | - | |||||||||||||||||||
988 | void QQuickImageParticle::setBypassOptimizations(bool arg) | - | ||||||||||||||||||
989 | { | - | ||||||||||||||||||
990 | if (m_bypassOptimizations != arg) {
| 0 | ||||||||||||||||||
991 | m_bypassOptimizations = arg; | - | ||||||||||||||||||
992 | emit bypassOptimizationsChanged(arg); | - | ||||||||||||||||||
993 | } never executed: end of block | 0 | ||||||||||||||||||
994 | // Applies regardless of perfLevel | - | ||||||||||||||||||
995 | reset(); | - | ||||||||||||||||||
996 | } never executed: end of block | 0 | ||||||||||||||||||
997 | - | |||||||||||||||||||
998 | void QQuickImageParticle::setEntryEffect(EntryEffect arg) | - | ||||||||||||||||||
999 | { | - | ||||||||||||||||||
1000 | if (m_entryEffect != arg) {
| 0-12 | ||||||||||||||||||
1001 | m_entryEffect = arg; | - | ||||||||||||||||||
1002 | if (m_material)
| 0-12 | ||||||||||||||||||
1003 | getState<ImageMaterialData>(m_material)->entry = (qreal) m_entryEffect; never executed: getState<ImageMaterialData>(m_material)->entry = (qreal) m_entryEffect; | 0 | ||||||||||||||||||
1004 | emit entryEffectChanged(arg); | - | ||||||||||||||||||
1005 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||
1006 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||
1007 | - | |||||||||||||||||||
1008 | void QQuickImageParticle::resetColor() | - | ||||||||||||||||||
1009 | { | - | ||||||||||||||||||
1010 | m_explicitColor = false; | - | ||||||||||||||||||
1011 | for (auto groupId : groupIds()) { | - | ||||||||||||||||||
1012 | for (QQuickParticleData* d : qAsConst(m_system->groupData[groupId]->data)) { | - | ||||||||||||||||||
1013 | if (d->colorOwner == this) {
| 0 | ||||||||||||||||||
1014 | d->colorOwner = nullptr; | - | ||||||||||||||||||
1015 | } never executed: end of block | 0 | ||||||||||||||||||
1016 | } never executed: end of block | 0 | ||||||||||||||||||
1017 | } never executed: end of block | 0 | ||||||||||||||||||
1018 | m_color = QColor(); | - | ||||||||||||||||||
1019 | m_color_variation = 0.0f; | - | ||||||||||||||||||
1020 | m_redVariation = 0.0f; | - | ||||||||||||||||||
1021 | m_blueVariation = 0.0f; | - | ||||||||||||||||||
1022 | m_greenVariation = 0.0f; | - | ||||||||||||||||||
1023 | m_alpha = 1.0f; | - | ||||||||||||||||||
1024 | m_alphaVariation = 0.0f; | - | ||||||||||||||||||
1025 | } never executed: end of block | 0 | ||||||||||||||||||
1026 | - | |||||||||||||||||||
1027 | void QQuickImageParticle::resetRotation() | - | ||||||||||||||||||
1028 | { | - | ||||||||||||||||||
1029 | m_explicitRotation = false; | - | ||||||||||||||||||
1030 | for (auto groupId : groupIds()) { | - | ||||||||||||||||||
1031 | for (QQuickParticleData* d : qAsConst(m_system->groupData[groupId]->data)) { | - | ||||||||||||||||||
1032 | if (d->rotationOwner == this) {
| 0 | ||||||||||||||||||
1033 | d->rotationOwner = nullptr; | - | ||||||||||||||||||
1034 | } never executed: end of block | 0 | ||||||||||||||||||
1035 | } never executed: end of block | 0 | ||||||||||||||||||
1036 | } never executed: end of block | 0 | ||||||||||||||||||
1037 | m_rotation = 0; | - | ||||||||||||||||||
1038 | m_rotationVariation = 0; | - | ||||||||||||||||||
1039 | m_rotationVelocity = 0; | - | ||||||||||||||||||
1040 | m_rotationVelocityVariation = 0; | - | ||||||||||||||||||
1041 | m_autoRotation = false; | - | ||||||||||||||||||
1042 | } never executed: end of block | 0 | ||||||||||||||||||
1043 | - | |||||||||||||||||||
1044 | void QQuickImageParticle::resetDeformation() | - | ||||||||||||||||||
1045 | { | - | ||||||||||||||||||
1046 | m_explicitDeformation = false; | - | ||||||||||||||||||
1047 | for (auto groupId : groupIds()) { | - | ||||||||||||||||||
1048 | for (QQuickParticleData* d : qAsConst(m_system->groupData[groupId]->data)) { | - | ||||||||||||||||||
1049 | if (d->deformationOwner == this) {
| 0 | ||||||||||||||||||
1050 | d->deformationOwner = nullptr; | - | ||||||||||||||||||
1051 | } never executed: end of block | 0 | ||||||||||||||||||
1052 | } never executed: end of block | 0 | ||||||||||||||||||
1053 | } never executed: end of block | 0 | ||||||||||||||||||
1054 | if (m_xVector)
| 0 | ||||||||||||||||||
1055 | delete m_xVector; never executed: delete m_xVector; | 0 | ||||||||||||||||||
1056 | if (m_yVector)
| 0 | ||||||||||||||||||
1057 | delete m_yVector; never executed: delete m_yVector; | 0 | ||||||||||||||||||
1058 | m_xVector = nullptr; | - | ||||||||||||||||||
1059 | m_yVector = nullptr; | - | ||||||||||||||||||
1060 | } never executed: end of block | 0 | ||||||||||||||||||
1061 | - | |||||||||||||||||||
1062 | void QQuickImageParticle::reset() | - | ||||||||||||||||||
1063 | { | - | ||||||||||||||||||
1064 | QQuickParticlePainter::reset(); | - | ||||||||||||||||||
1065 | m_pleaseReset = true; | - | ||||||||||||||||||
1066 | update(); | - | ||||||||||||||||||
1067 | } executed 1378 times by 22 tests: end of block Executed by:
| 1378 | ||||||||||||||||||
1068 | - | |||||||||||||||||||
1069 | void QQuickImageParticle::createEngine() | - | ||||||||||||||||||
1070 | { | - | ||||||||||||||||||
1071 | if (m_spriteEngine)
| 22-32 | ||||||||||||||||||
1072 | delete m_spriteEngine; executed 32 times by 2 tests: delete m_spriteEngine; Executed by:
| 32 | ||||||||||||||||||
1073 | if (m_sprites.count()) {
| 0-54 | ||||||||||||||||||
1074 | m_spriteEngine = new QQuickSpriteEngine(m_sprites, this); | - | ||||||||||||||||||
1075 | connect(m_spriteEngine, SIGNAL(stateChanged(int)), | - | ||||||||||||||||||
1076 | this, SLOT(spriteAdvance(int)), Qt::DirectConnection); | - | ||||||||||||||||||
1077 | m_explicitAnimation = true; | - | ||||||||||||||||||
1078 | } else { executed 54 times by 3 tests: end of block Executed by:
| 54 | ||||||||||||||||||
1079 | m_spriteEngine = nullptr; | - | ||||||||||||||||||
1080 | m_explicitAnimation = false; | - | ||||||||||||||||||
1081 | } never executed: end of block | 0 | ||||||||||||||||||
1082 | reset(); | - | ||||||||||||||||||
1083 | } executed 54 times by 3 tests: end of block Executed by:
| 54 | ||||||||||||||||||
1084 | - | |||||||||||||||||||
1085 | static QSGGeometry::Attribute SimpleParticle_Attributes[] = { | - | ||||||||||||||||||
1086 | QSGGeometry::Attribute::create(0, 2, GL_FLOAT, true), // Position | - | ||||||||||||||||||
1087 | QSGGeometry::Attribute::create(1, 4, GL_FLOAT), // Data | - | ||||||||||||||||||
1088 | QSGGeometry::Attribute::create(2, 4, GL_FLOAT) // Vectors | - | ||||||||||||||||||
1089 | }; | - | ||||||||||||||||||
1090 | - | |||||||||||||||||||
1091 | static QSGGeometry::AttributeSet SimpleParticle_AttributeSet = | - | ||||||||||||||||||
1092 | { | - | ||||||||||||||||||
1093 | 3, // Attribute Count | - | ||||||||||||||||||
1094 | ( 2 + 4 + 4 ) * sizeof(float), | - | ||||||||||||||||||
1095 | SimpleParticle_Attributes | - | ||||||||||||||||||
1096 | }; | - | ||||||||||||||||||
1097 | - | |||||||||||||||||||
1098 | static QSGGeometry::Attribute ColoredParticle_Attributes[] = { | - | ||||||||||||||||||
1099 | QSGGeometry::Attribute::create(0, 2, GL_FLOAT, true), // Position | - | ||||||||||||||||||
1100 | QSGGeometry::Attribute::create(1, 4, GL_FLOAT), // Data | - | ||||||||||||||||||
1101 | QSGGeometry::Attribute::create(2, 4, GL_FLOAT), // Vectors | - | ||||||||||||||||||
1102 | QSGGeometry::Attribute::create(3, 4, GL_UNSIGNED_BYTE), // Colors | - | ||||||||||||||||||
1103 | }; | - | ||||||||||||||||||
1104 | - | |||||||||||||||||||
1105 | static QSGGeometry::AttributeSet ColoredParticle_AttributeSet = | - | ||||||||||||||||||
1106 | { | - | ||||||||||||||||||
1107 | 4, // Attribute Count | - | ||||||||||||||||||
1108 | ( 2 + 4 + 4 ) * sizeof(float) + 4 * sizeof(uchar), | - | ||||||||||||||||||
1109 | ColoredParticle_Attributes | - | ||||||||||||||||||
1110 | }; | - | ||||||||||||||||||
1111 | - | |||||||||||||||||||
1112 | static QSGGeometry::Attribute DeformableParticle_Attributes[] = { | - | ||||||||||||||||||
1113 | QSGGeometry::Attribute::create(0, 4, GL_FLOAT), // Position & TexCoord | - | ||||||||||||||||||
1114 | QSGGeometry::Attribute::create(1, 4, GL_FLOAT), // Data | - | ||||||||||||||||||
1115 | QSGGeometry::Attribute::create(2, 4, GL_FLOAT), // Vectors | - | ||||||||||||||||||
1116 | QSGGeometry::Attribute::create(3, 4, GL_UNSIGNED_BYTE), // Colors | - | ||||||||||||||||||
1117 | QSGGeometry::Attribute::create(4, 4, GL_FLOAT), // DeformationVectors | - | ||||||||||||||||||
1118 | QSGGeometry::Attribute::create(5, 3, GL_FLOAT), // Rotation | - | ||||||||||||||||||
1119 | }; | - | ||||||||||||||||||
1120 | - | |||||||||||||||||||
1121 | static QSGGeometry::AttributeSet DeformableParticle_AttributeSet = | - | ||||||||||||||||||
1122 | { | - | ||||||||||||||||||
1123 | 6, // Attribute Count | - | ||||||||||||||||||
1124 | (4 + 4 + 4 + 4 + 3) * sizeof(float) + 4 * sizeof(uchar), | - | ||||||||||||||||||
1125 | DeformableParticle_Attributes | - | ||||||||||||||||||
1126 | }; | - | ||||||||||||||||||
1127 | - | |||||||||||||||||||
1128 | static QSGGeometry::Attribute SpriteParticle_Attributes[] = { | - | ||||||||||||||||||
1129 | QSGGeometry::Attribute::create(0, 4, GL_FLOAT), // Position & TexCoord | - | ||||||||||||||||||
1130 | QSGGeometry::Attribute::create(1, 4, GL_FLOAT), // Data | - | ||||||||||||||||||
1131 | QSGGeometry::Attribute::create(2, 4, GL_FLOAT), // Vectors | - | ||||||||||||||||||
1132 | QSGGeometry::Attribute::create(3, 4, GL_UNSIGNED_BYTE), // Colors | - | ||||||||||||||||||
1133 | QSGGeometry::Attribute::create(4, 4, GL_FLOAT), // DeformationVectors | - | ||||||||||||||||||
1134 | QSGGeometry::Attribute::create(5, 3, GL_FLOAT), // Rotation | - | ||||||||||||||||||
1135 | QSGGeometry::Attribute::create(6, 3, GL_FLOAT), // Anim Data | - | ||||||||||||||||||
1136 | QSGGeometry::Attribute::create(7, 4, GL_FLOAT) // Anim Pos | - | ||||||||||||||||||
1137 | }; | - | ||||||||||||||||||
1138 | - | |||||||||||||||||||
1139 | static QSGGeometry::AttributeSet SpriteParticle_AttributeSet = | - | ||||||||||||||||||
1140 | { | - | ||||||||||||||||||
1141 | 8, // Attribute Count | - | ||||||||||||||||||
1142 | (4 + 4 + 4 + 4 + 3 + 3 + 4) * sizeof(float) + 4 * sizeof(uchar), | - | ||||||||||||||||||
1143 | SpriteParticle_Attributes | - | ||||||||||||||||||
1144 | }; | - | ||||||||||||||||||
1145 | - | |||||||||||||||||||
1146 | void QQuickImageParticle::clearShadows() | - | ||||||||||||||||||
1147 | { | - | ||||||||||||||||||
1148 | foreach (const QVector<QQuickParticleData*> data, m_shadowData)
| 0-303 | ||||||||||||||||||
1149 | qDeleteAll(data); executed 2 times by 1 test: qDeleteAll(data); Executed by:
| 2 | ||||||||||||||||||
1150 | m_shadowData.clear(); | - | ||||||||||||||||||
1151 | } executed 301 times by 22 tests: end of block Executed by:
| 301 | ||||||||||||||||||
1152 | - | |||||||||||||||||||
1153 | //Only call if you need to, may initialize the whole array first time | - | ||||||||||||||||||
1154 | QQuickParticleData* QQuickImageParticle::getShadowDatum(QQuickParticleData* datum) | - | ||||||||||||||||||
1155 | { | - | ||||||||||||||||||
1156 | //Will return datum if the datum is a sentinel or uninitialized, to centralize that one check | - | ||||||||||||||||||
1157 | if (datum->systemIndex == -1)
| 886-75249 | ||||||||||||||||||
1158 | return datum; executed 75249 times by 3 tests: return datum; Executed by:
| 75249 | ||||||||||||||||||
1159 | QQuickParticleGroupData* gd = m_system->groupData[datum->groupId]; | - | ||||||||||||||||||
1160 | if (!m_shadowData.contains(datum->groupId)) {
| 2-884 | ||||||||||||||||||
1161 | QVector<QQuickParticleData*> data; | - | ||||||||||||||||||
1162 | const int gdSize = gd->size(); | - | ||||||||||||||||||
1163 | data.reserve(gdSize); | - | ||||||||||||||||||
1164 | for (int i = 0; i < gdSize; i++) {
| 2-1000 | ||||||||||||||||||
1165 | QQuickParticleData* datum = new QQuickParticleData; | - | ||||||||||||||||||
1166 | *datum = *(gd->data[i]); | - | ||||||||||||||||||
1167 | data << datum; | - | ||||||||||||||||||
1168 | } executed 1000 times by 1 test: end of block Executed by:
| 1000 | ||||||||||||||||||
1169 | m_shadowData.insert(datum->groupId, data); | - | ||||||||||||||||||
1170 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
1171 | //### If dynamic resize is added, remember to potentially resize the shadow data on out-of-bounds access request | - | ||||||||||||||||||
1172 | - | |||||||||||||||||||
1173 | return m_shadowData[datum->groupId][datum->index]; executed 886 times by 1 test: return m_shadowData[datum->groupId][datum->index]; Executed by:
| 886 | ||||||||||||||||||
1174 | } | - | ||||||||||||||||||
1175 | - | |||||||||||||||||||
1176 | bool QQuickImageParticle::loadingSomething() | - | ||||||||||||||||||
1177 | { | - | ||||||||||||||||||
1178 | return (m_image && m_image->pix.isLoading()) executed 488 times by 22 tests: return (m_image && m_image->pix.isLoading()) || (m_colorTable && m_colorTable->pix.isLoading()) || (m_sizeTable && m_sizeTable->pix.isLoading()) || (m_opacityTable && m_opacityTable->pix.isLoading()) || (m_spriteEngine && m_spriteEngine->isLoading()); Executed by:
| 488 | ||||||||||||||||||
1179 | || (m_colorTable && m_colorTable->pix.isLoading()) executed 488 times by 22 tests: return (m_image && m_image->pix.isLoading()) || (m_colorTable && m_colorTable->pix.isLoading()) || (m_sizeTable && m_sizeTable->pix.isLoading()) || (m_opacityTable && m_opacityTable->pix.isLoading()) || (m_spriteEngine && m_spriteEngine->isLoading()); Executed by:
| 488 | ||||||||||||||||||
1180 | || (m_sizeTable && m_sizeTable->pix.isLoading()) executed 488 times by 22 tests: return (m_image && m_image->pix.isLoading()) || (m_colorTable && m_colorTable->pix.isLoading()) || (m_sizeTable && m_sizeTable->pix.isLoading()) || (m_opacityTable && m_opacityTable->pix.isLoading()) || (m_spriteEngine && m_spriteEngine->isLoading()); Executed by:
| 488 | ||||||||||||||||||
1181 | || (m_opacityTable && m_opacityTable->pix.isLoading()) executed 488 times by 22 tests: return (m_image && m_image->pix.isLoading()) || (m_colorTable && m_colorTable->pix.isLoading()) || (m_sizeTable && m_sizeTable->pix.isLoading()) || (m_opacityTable && m_opacityTable->pix.isLoading()) || (m_spriteEngine && m_spriteEngine->isLoading()); Executed by:
| 488 | ||||||||||||||||||
1182 | || (m_spriteEngine && m_spriteEngine->isLoading()); executed 488 times by 22 tests: return (m_image && m_image->pix.isLoading()) || (m_colorTable && m_colorTable->pix.isLoading()) || (m_sizeTable && m_sizeTable->pix.isLoading()) || (m_opacityTable && m_opacityTable->pix.isLoading()) || (m_spriteEngine && m_spriteEngine->isLoading()); Executed by:
| 488 | ||||||||||||||||||
1183 | } | - | ||||||||||||||||||
1184 | - | |||||||||||||||||||
1185 | void QQuickImageParticle::mainThreadFetchImageData() | - | ||||||||||||||||||
1186 | { | - | ||||||||||||||||||
1187 | if (m_image) {//ImageData created on setSource
| 4-199 | ||||||||||||||||||
1188 | m_image->pix.clear(this); | - | ||||||||||||||||||
1189 | m_image->pix.load(qmlEngine(this), m_image->source); | - | ||||||||||||||||||
1190 | } executed 199 times by 20 tests: end of block Executed by:
| 199 | ||||||||||||||||||
1191 | - | |||||||||||||||||||
1192 | if (m_spriteEngine)
| 4-199 | ||||||||||||||||||
1193 | m_spriteEngine->startAssemblingImage(); executed 4 times by 2 tests: m_spriteEngine->startAssemblingImage(); Executed by:
| 4 | ||||||||||||||||||
1194 | - | |||||||||||||||||||
1195 | if (m_colorTable)
| 2-201 | ||||||||||||||||||
1196 | m_colorTable->pix.load(qmlEngine(this), m_colorTable->source); executed 2 times by 1 test: m_colorTable->pix.load(qmlEngine(this), m_colorTable->source); Executed by:
| 2 | ||||||||||||||||||
1197 | - | |||||||||||||||||||
1198 | if (m_sizeTable)
| 2-201 | ||||||||||||||||||
1199 | m_sizeTable->pix.load(qmlEngine(this), m_sizeTable->source); executed 2 times by 1 test: m_sizeTable->pix.load(qmlEngine(this), m_sizeTable->source); Executed by:
| 2 | ||||||||||||||||||
1200 | - | |||||||||||||||||||
1201 | if (m_opacityTable)
| 2-201 | ||||||||||||||||||
1202 | m_opacityTable->pix.load(qmlEngine(this), m_opacityTable->source); executed 2 times by 1 test: m_opacityTable->pix.load(qmlEngine(this), m_opacityTable->source); Executed by:
| 2 | ||||||||||||||||||
1203 | - | |||||||||||||||||||
1204 | m_startedImageLoading = 2; | - | ||||||||||||||||||
1205 | } executed 203 times by 21 tests: end of block Executed by:
| 203 | ||||||||||||||||||
1206 | - | |||||||||||||||||||
1207 | void QQuickImageParticle::buildParticleNodes(QSGNode** passThrough) | - | ||||||||||||||||||
1208 | { | - | ||||||||||||||||||
1209 | // Starts async parts, like loading images, on gui thread | - | ||||||||||||||||||
1210 | // Not on individual properties, because we delay until system is running | - | ||||||||||||||||||
1211 | if (*passThrough || loadingSomething())
| 0-488 | ||||||||||||||||||
1212 | return; never executed: return; | 0 | ||||||||||||||||||
1213 | - | |||||||||||||||||||
1214 | if (m_startedImageLoading == 0) {
| 167-321 | ||||||||||||||||||
1215 | m_startedImageLoading = 1; | - | ||||||||||||||||||
1216 | //stage 1 is in gui thread | - | ||||||||||||||||||
1217 | QQuickImageParticle::staticMetaObject.invokeMethod(this, "mainThreadFetchImageData", Qt::QueuedConnection); | - | ||||||||||||||||||
1218 | } else if (m_startedImageLoading == 2) { executed 321 times by 22 tests: end of block Executed by:
| 64-321 | ||||||||||||||||||
1219 | finishBuildParticleNodes(passThrough); //rest happens in render thread | - | ||||||||||||||||||
1220 | } executed 103 times by 21 tests: end of block Executed by:
| 103 | ||||||||||||||||||
1221 | - | |||||||||||||||||||
1222 | //No mutex, because it's slow and a compare that fails due to a race condition means just a dropped frame | - | ||||||||||||||||||
1223 | } executed 488 times by 22 tests: end of block Executed by:
| 488 | ||||||||||||||||||
1224 | - | |||||||||||||||||||
1225 | void QQuickImageParticle::finishBuildParticleNodes(QSGNode** node) | - | ||||||||||||||||||
1226 | { | - | ||||||||||||||||||
1227 | if (!QOpenGLContext::currentContext())
| 0-103 | ||||||||||||||||||
1228 | return; never executed: return; | 0 | ||||||||||||||||||
1229 | - | |||||||||||||||||||
1230 | if (m_count * 4 > 0xffff) {
| 0-103 | ||||||||||||||||||
1231 | // Index data is ushort. | - | ||||||||||||||||||
1232 | qmlInfo(this) << "ImageParticle: Too many particles - maximum 16383 per ImageParticle"; | - | ||||||||||||||||||
1233 | return; never executed: return; | 0 | ||||||||||||||||||
1234 | } | - | ||||||||||||||||||
1235 | - | |||||||||||||||||||
1236 | if (count() <= 0)
| 4-99 | ||||||||||||||||||
1237 | return; executed 4 times by 2 tests: return; Executed by:
| 4 | ||||||||||||||||||
1238 | - | |||||||||||||||||||
1239 | m_debugMode = m_system->m_debugMode; | - | ||||||||||||||||||
1240 | - | |||||||||||||||||||
1241 | if (m_sprites.count() || m_bypassOptimizations) {
| 0-95 | ||||||||||||||||||
1242 | perfLevel = Sprites; | - | ||||||||||||||||||
1243 | } else if (m_colorTable || m_sizeTable || m_opacityTable) { executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||||||||||||||
1244 | perfLevel = Tabled; | - | ||||||||||||||||||
1245 | } else if (m_autoRotation || m_rotation || m_rotationVariation executed 2 times by 1 test: end of block Executed by:
| 2-91 | ||||||||||||||||||
1246 | || m_rotationVelocity || m_rotationVelocityVariation | - | ||||||||||||||||||
1247 | || m_xVector || m_yVector) {
| 0-87 | ||||||||||||||||||
1248 | perfLevel = Deformable; | - | ||||||||||||||||||
1249 | } else if (m_alphaVariation || m_alpha != 1.0 || m_color.isValid() || m_color_variation executed 6 times by 2 tests: end of block Executed by:
| 0-83 | ||||||||||||||||||
1250 | || m_redVariation || m_blueVariation || m_greenVariation) { | - | ||||||||||||||||||
1251 | perfLevel = Colored; | - | ||||||||||||||||||
1252 | } else { executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||
1253 | perfLevel = Simple; | - | ||||||||||||||||||
1254 | } executed 83 times by 20 tests: end of block Executed by:
| 83 | ||||||||||||||||||
1255 | - | |||||||||||||||||||
1256 | for (auto groupId : groupIds()) { | - | ||||||||||||||||||
1257 | //For sharing higher levels, need to have highest used so it renders | - | ||||||||||||||||||
1258 | for (QQuickParticlePainter* p : qAsConst(m_system->groupData[groupId]->painters)) { | - | ||||||||||||||||||
1259 | QQuickImageParticle* other = qobject_cast<QQuickImageParticle*>(p); | - | ||||||||||||||||||
1260 | if (other){
| 0-111 | ||||||||||||||||||
1261 | if (other->perfLevel > perfLevel) {
| 0-111 | ||||||||||||||||||
1262 | if (other->perfLevel >= Tabled){//Deformable is the highest level needed for this, anything higher isn't shared (or requires your own sprite)
| 0 | ||||||||||||||||||
1263 | if (perfLevel < Deformable)
| 0 | ||||||||||||||||||
1264 | perfLevel = Deformable; never executed: perfLevel = Deformable; | 0 | ||||||||||||||||||
1265 | } else { never executed: end of block | 0 | ||||||||||||||||||
1266 | perfLevel = other->perfLevel; | - | ||||||||||||||||||
1267 | } never executed: end of block | 0 | ||||||||||||||||||
1268 | } else if (other->perfLevel < perfLevel) {
| 0-111 | ||||||||||||||||||
1269 | other->reset(); | - | ||||||||||||||||||
1270 | } never executed: end of block | 0 | ||||||||||||||||||
1271 | } executed 111 times by 21 tests: end of block Executed by:
| 111 | ||||||||||||||||||
1272 | } executed 111 times by 21 tests: end of block Executed by:
| 111 | ||||||||||||||||||
1273 | } executed 111 times by 21 tests: end of block Executed by:
| 111 | ||||||||||||||||||
1274 | #ifdef Q_OS_WIN | - | ||||||||||||||||||
1275 | if (perfLevel < Deformable) //QTBUG-24540 , point sprite 'extension' isn't working on windows. | - | ||||||||||||||||||
1276 | perfLevel = Deformable; | - | ||||||||||||||||||
1277 | #endif | - | ||||||||||||||||||
1278 | - | |||||||||||||||||||
1279 | #ifdef Q_OS_MAC | - | ||||||||||||||||||
1280 | // OS X 10.8.3 introduced a bug in the AMD drivers, for at least the 2011 macbook pros, | - | ||||||||||||||||||
1281 | // causing point sprites who read gl_PointCoord in the frag shader to come out as | - | ||||||||||||||||||
1282 | // green-red blobs. | - | ||||||||||||||||||
1283 | const GLubyte *glVendor = QOpenGLContext::currentContext()->functions()->glGetString(GL_VENDOR); | - | ||||||||||||||||||
1284 | if (perfLevel < Deformable && glVendor && strstr((char *) glVendor, "ATI")) { | - | ||||||||||||||||||
1285 | perfLevel = Deformable; | - | ||||||||||||||||||
1286 | } | - | ||||||||||||||||||
1287 | #endif | - | ||||||||||||||||||
1288 | - | |||||||||||||||||||
1289 | #ifdef Q_OS_LINUX | - | ||||||||||||||||||
1290 | // Nouveau drivers can potentially freeze a machine entirely when taking the point-sprite path. | - | ||||||||||||||||||
1291 | const GLubyte *glVendor = QOpenGLContext::currentContext()->functions()->glGetString(GL_VENDOR); | - | ||||||||||||||||||
1292 | if (perfLevel < Deformable && glVendor && strstr((const char *) glVendor, "nouveau"))
| 0-87 | ||||||||||||||||||
1293 | perfLevel = Deformable; never executed: perfLevel = Deformable; | 0 | ||||||||||||||||||
1294 | #endif | - | ||||||||||||||||||
1295 | - | |||||||||||||||||||
1296 | if (perfLevel >= Colored && !m_color.isValid())
| 4-83 | ||||||||||||||||||
1297 | m_color = QColor(Qt::white);//Hidden default, but different from unset executed 12 times by 3 tests: m_color = QColor(Qt::white); Executed by:
| 12 | ||||||||||||||||||
1298 | - | |||||||||||||||||||
1299 | clearShadows(); | - | ||||||||||||||||||
1300 | if (m_material)
| 0-99 | ||||||||||||||||||
1301 | m_material = nullptr; never executed: m_material = nullptr; | 0 | ||||||||||||||||||
1302 | - | |||||||||||||||||||
1303 | //Setup material | - | ||||||||||||||||||
1304 | QImage colortable; | - | ||||||||||||||||||
1305 | QImage sizetable; | - | ||||||||||||||||||
1306 | QImage opacitytable; | - | ||||||||||||||||||
1307 | QImage image; | - | ||||||||||||||||||
1308 | bool imageLoaded = false; | - | ||||||||||||||||||
1309 | switch (perfLevel) {//Fallthrough intended | - | ||||||||||||||||||
1310 | case Sprites: executed 4 times by 2 tests: case Sprites: Executed by:
| 4 | ||||||||||||||||||
1311 | if (!m_spriteEngine) {
| 0-4 | ||||||||||||||||||
1312 | qWarning() << "ImageParticle: No sprite engine..."; | - | ||||||||||||||||||
1313 | //Sprite performance mode with static image is supported, but not advised | - | ||||||||||||||||||
1314 | //Note that in this case it always uses shadow data | - | ||||||||||||||||||
1315 | } else { never executed: end of block | 0 | ||||||||||||||||||
1316 | image = m_spriteEngine->assembledImage(); | - | ||||||||||||||||||
1317 | if (image.isNull())//Warning is printed in engine
| 0-4 | ||||||||||||||||||
1318 | return; never executed: return; | 0 | ||||||||||||||||||
1319 | imageLoaded = true; | - | ||||||||||||||||||
1320 | } executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||||||||||||||
1321 | m_material = SpriteMaterial::createMaterial(); | - | ||||||||||||||||||
1322 | if (imageLoaded)
| 0-4 | ||||||||||||||||||
1323 | getState<ImageMaterialData>(m_material)->texture = QSGPlainTexture::fromImage(image); executed 4 times by 2 tests: getState<ImageMaterialData>(m_material)->texture = QSGPlainTexture::fromImage(image); Executed by:
| 4 | ||||||||||||||||||
1324 | getState<ImageMaterialData>(m_material)->animSheetSize = QSizeF(image.size() / image.devicePixelRatioF()); | - | ||||||||||||||||||
1325 | if (m_spriteEngine)
| 0-4 | ||||||||||||||||||
1326 | m_spriteEngine->setCount(m_count); executed 4 times by 2 tests: m_spriteEngine->setCount(m_count); Executed by:
| 4 | ||||||||||||||||||
1327 | Q_FALLTHROUGH(); | - | ||||||||||||||||||
1328 | case Tabled: code before this statement executed 4 times by 2 tests: case Tabled: Executed by:
executed 2 times by 1 test: case Tabled: Executed by:
| 2-4 | ||||||||||||||||||
1329 | if (!m_material)
| 2-4 | ||||||||||||||||||
1330 | m_material = TabledMaterial::createMaterial(); executed 2 times by 1 test: m_material = TabledMaterial::createMaterial(); Executed by:
| 2 | ||||||||||||||||||
1331 | - | |||||||||||||||||||
1332 | if (m_colorTable) {
| 2-4 | ||||||||||||||||||
1333 | if (m_colorTable->pix.isReady())
| 0-2 | ||||||||||||||||||
1334 | colortable = m_colorTable->pix.image(); executed 2 times by 1 test: colortable = m_colorTable->pix.image(); Executed by:
| 2 | ||||||||||||||||||
1335 | else | - | ||||||||||||||||||
1336 | qmlWarning(this) << "Error loading color table: " << m_colorTable->pix.error(); never executed: qmlWarning(this) << "Error loading color table: " << m_colorTable->pix.error(); | 0 | ||||||||||||||||||
1337 | } | - | ||||||||||||||||||
1338 | - | |||||||||||||||||||
1339 | if (m_sizeTable) {
| 2-4 | ||||||||||||||||||
1340 | if (m_sizeTable->pix.isReady())
| 0-2 | ||||||||||||||||||
1341 | sizetable = m_sizeTable->pix.image(); executed 2 times by 1 test: sizetable = m_sizeTable->pix.image(); Executed by:
| 2 | ||||||||||||||||||
1342 | else | - | ||||||||||||||||||
1343 | qmlWarning(this) << "Error loading size table: " << m_sizeTable->pix.error(); never executed: qmlWarning(this) << "Error loading size table: " << m_sizeTable->pix.error(); | 0 | ||||||||||||||||||
1344 | } | - | ||||||||||||||||||
1345 | - | |||||||||||||||||||
1346 | if (m_opacityTable) {
| 2-4 | ||||||||||||||||||
1347 | if (m_opacityTable->pix.isReady())
| 0-2 | ||||||||||||||||||
1348 | opacitytable = m_opacityTable->pix.image(); executed 2 times by 1 test: opacitytable = m_opacityTable->pix.image(); Executed by:
| 2 | ||||||||||||||||||
1349 | else | - | ||||||||||||||||||
1350 | qmlWarning(this) << "Error loading opacity table: " << m_opacityTable->pix.error(); never executed: qmlWarning(this) << "Error loading opacity table: " << m_opacityTable->pix.error(); | 0 | ||||||||||||||||||
1351 | } | - | ||||||||||||||||||
1352 | - | |||||||||||||||||||
1353 | if (colortable.isNull()){//###Goes through image just for this
| 2-4 | ||||||||||||||||||
1354 | colortable = QImage(1,1,QImage::Format_ARGB32_Premultiplied); | - | ||||||||||||||||||
1355 | colortable.fill(Qt::white); | - | ||||||||||||||||||
1356 | } executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||||||||||||||
1357 | getState<ImageMaterialData>(m_material)->colorTable = QSGPlainTexture::fromImage(colortable); | - | ||||||||||||||||||
1358 | fillUniformArrayFromImage(getState<ImageMaterialData>(m_material)->sizeTable, sizetable, UNIFORM_ARRAY_SIZE); | - | ||||||||||||||||||
1359 | fillUniformArrayFromImage(getState<ImageMaterialData>(m_material)->opacityTable, opacitytable, UNIFORM_ARRAY_SIZE); | - | ||||||||||||||||||
1360 | Q_FALLTHROUGH(); | - | ||||||||||||||||||
1361 | case Deformable: code before this statement executed 6 times by 2 tests: case Deformable: Executed by:
executed 6 times by 2 tests: case Deformable: Executed by:
| 6 | ||||||||||||||||||
1362 | if (!m_material)
| 6 | ||||||||||||||||||
1363 | m_material = DeformableMaterial::createMaterial(); executed 6 times by 2 tests: m_material = DeformableMaterial::createMaterial(); Executed by:
| 6 | ||||||||||||||||||
1364 | Q_FALLTHROUGH(); | - | ||||||||||||||||||
1365 | case Colored: code before this statement executed 12 times by 3 tests: case Colored: Executed by:
executed 4 times by 1 test: case Colored: Executed by:
| 4-12 | ||||||||||||||||||
1366 | if (!m_material)
| 4-12 | ||||||||||||||||||
1367 | m_material = ColoredMaterial::createMaterial(); executed 4 times by 1 test: m_material = ColoredMaterial::createMaterial(); Executed by:
| 4 | ||||||||||||||||||
1368 | Q_FALLTHROUGH(); | - | ||||||||||||||||||
1369 | default://Also Simple code before this statement executed 16 times by 3 tests: default: Executed by:
executed 83 times by 20 tests: default: Executed by:
| 16-83 | ||||||||||||||||||
1370 | if (!m_material)
| 16-83 | ||||||||||||||||||
1371 | m_material = SimpleMaterial::createMaterial(); executed 83 times by 20 tests: m_material = SimpleMaterial::createMaterial(); Executed by:
| 83 | ||||||||||||||||||
1372 | if (!imageLoaded) {
| 4-95 | ||||||||||||||||||
1373 | if (!m_image || !m_image->pix.isReady()) {
| 0-95 | ||||||||||||||||||
1374 | if (m_image)
| 0 | ||||||||||||||||||
1375 | qmlWarning(this) << m_image->pix.error(); never executed: qmlWarning(this) << m_image->pix.error(); | 0 | ||||||||||||||||||
1376 | delete m_material; | - | ||||||||||||||||||
1377 | return; never executed: return; | 0 | ||||||||||||||||||
1378 | } | - | ||||||||||||||||||
1379 | //getState<ImageMaterialData>(m_material)->texture //TODO: Shouldn't this be better? But not crash? | - | ||||||||||||||||||
1380 | // = QQuickItemPrivate::get(this)->sceneGraphContext()->textureForFactory(m_imagePix.textureFactory()); | - | ||||||||||||||||||
1381 | getState<ImageMaterialData>(m_material)->texture = QSGPlainTexture::fromImage(m_image->pix.image()); | - | ||||||||||||||||||
1382 | } executed 95 times by 20 tests: end of block Executed by:
| 95 | ||||||||||||||||||
1383 | getState<ImageMaterialData>(m_material)->texture->setFiltering(QSGTexture::Linear); | - | ||||||||||||||||||
1384 | getState<ImageMaterialData>(m_material)->entry = (qreal) m_entryEffect; | - | ||||||||||||||||||
1385 | m_material->setFlag(QSGMaterial::Blending | QSGMaterial::RequiresFullMatrix); | - | ||||||||||||||||||
1386 | } executed 99 times by 21 tests: end of block Executed by:
| 99 | ||||||||||||||||||
1387 | - | |||||||||||||||||||
1388 | m_nodes.clear(); | - | ||||||||||||||||||
1389 | for (auto groupId : groupIds()) { | - | ||||||||||||||||||
1390 | int count = m_system->groupData[groupId]->size(); | - | ||||||||||||||||||
1391 | QSGGeometryNode* node = new QSGGeometryNode(); | - | ||||||||||||||||||
1392 | node->setMaterial(m_material); | - | ||||||||||||||||||
1393 | node->markDirty(QSGNode::DirtyMaterial); | - | ||||||||||||||||||
1394 | - | |||||||||||||||||||
1395 | m_nodes.insert(groupId, node); | - | ||||||||||||||||||
1396 | m_idxStarts.insert(groupId, m_lastIdxStart); | - | ||||||||||||||||||
1397 | m_startsIdx.append(qMakePair<int,int>(m_lastIdxStart, groupId)); | - | ||||||||||||||||||
1398 | m_lastIdxStart += count; | - | ||||||||||||||||||
1399 | - | |||||||||||||||||||
1400 | //Create Particle Geometry | - | ||||||||||||||||||
1401 | int vCount = count * 4; | - | ||||||||||||||||||
1402 | int iCount = count * 6; | - | ||||||||||||||||||
1403 | - | |||||||||||||||||||
1404 | QSGGeometry *g; | - | ||||||||||||||||||
1405 | if (perfLevel == Sprites)
| 4-107 | ||||||||||||||||||
1406 | g = new QSGGeometry(SpriteParticle_AttributeSet, vCount, iCount); executed 4 times by 2 tests: g = new QSGGeometry(SpriteParticle_AttributeSet, vCount, iCount); Executed by:
| 4 | ||||||||||||||||||
1407 | else if (perfLevel == Tabled)
| 2-105 | ||||||||||||||||||
1408 | g = new QSGGeometry(DeformableParticle_AttributeSet, vCount, iCount); executed 2 times by 1 test: g = new QSGGeometry(DeformableParticle_AttributeSet, vCount, iCount); Executed by:
| 2 | ||||||||||||||||||
1409 | else if (perfLevel == Deformable)
| 6-99 | ||||||||||||||||||
1410 | g = new QSGGeometry(DeformableParticle_AttributeSet, vCount, iCount); executed 6 times by 2 tests: g = new QSGGeometry(DeformableParticle_AttributeSet, vCount, iCount); Executed by:
| 6 | ||||||||||||||||||
1411 | else if (perfLevel == Colored)
| 4-95 | ||||||||||||||||||
1412 | g = new QSGGeometry(ColoredParticle_AttributeSet, count, 0); executed 4 times by 1 test: g = new QSGGeometry(ColoredParticle_AttributeSet, count, 0); Executed by:
| 4 | ||||||||||||||||||
1413 | else //Simple | - | ||||||||||||||||||
1414 | g = new QSGGeometry(SimpleParticle_AttributeSet, count, 0); executed 95 times by 20 tests: g = new QSGGeometry(SimpleParticle_AttributeSet, count, 0); Executed by:
| 95 | ||||||||||||||||||
1415 | - | |||||||||||||||||||
1416 | node->setFlag(QSGNode::OwnsGeometry); | - | ||||||||||||||||||
1417 | node->setGeometry(g); | - | ||||||||||||||||||
1418 | if (perfLevel <= Colored){
| 12-99 | ||||||||||||||||||
1419 | g->setDrawingMode(GL_POINTS); | - | ||||||||||||||||||
1420 | if (m_debugMode){
| 6-93 | ||||||||||||||||||
1421 | GLfloat pointSizeRange[2]; | - | ||||||||||||||||||
1422 | QOpenGLContext::currentContext()->functions()->glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, pointSizeRange); | - | ||||||||||||||||||
1423 | qDebug() << "Using point sprites, GL_ALIASED_POINT_SIZE_RANGE " <<pointSizeRange[0] << ":" << pointSizeRange[1]; | - | ||||||||||||||||||
1424 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||
1425 | }else executed 99 times by 20 tests: end of block Executed by:
| 99 | ||||||||||||||||||
1426 | g->setDrawingMode(GL_TRIANGLES); executed 12 times by 3 tests: g->setDrawingMode( 0x0004 ); Executed by:
| 12 | ||||||||||||||||||
1427 | - | |||||||||||||||||||
1428 | for (int p=0; p < count; ++p)
| 111-48570 | ||||||||||||||||||
1429 | commit(groupId, p);//commit sets geometry for the node, has its own perfLevel switch executed 48570 times by 21 tests: commit(groupId, p); Executed by:
| 48570 | ||||||||||||||||||
1430 | - | |||||||||||||||||||
1431 | if (perfLevel == Sprites)
| 4-107 | ||||||||||||||||||
1432 | initTexCoords<SpriteVertex>((SpriteVertex*)g->vertexData(), vCount); executed 4 times by 2 tests: initTexCoords<SpriteVertex>((SpriteVertex*)g->vertexData(), vCount); Executed by:
| 4 | ||||||||||||||||||
1433 | else if (perfLevel == Tabled)
| 2-105 | ||||||||||||||||||
1434 | initTexCoords<DeformableVertex>((DeformableVertex*)g->vertexData(), vCount); executed 2 times by 1 test: initTexCoords<DeformableVertex>((DeformableVertex*)g->vertexData(), vCount); Executed by:
| 2 | ||||||||||||||||||
1435 | else if (perfLevel == Deformable)
| 6-99 | ||||||||||||||||||
1436 | initTexCoords<DeformableVertex>((DeformableVertex*)g->vertexData(), vCount); executed 6 times by 2 tests: initTexCoords<DeformableVertex>((DeformableVertex*)g->vertexData(), vCount); Executed by:
| 6 | ||||||||||||||||||
1437 | - | |||||||||||||||||||
1438 | if (perfLevel > Colored){
| 12-99 | ||||||||||||||||||
1439 | quint16 *indices = g->indexDataAsUShort(); | - | ||||||||||||||||||
1440 | for (int i=0; i < count; ++i) {
| 12-6000 | ||||||||||||||||||
1441 | int o = i * 4; | - | ||||||||||||||||||
1442 | indices[0] = o; | - | ||||||||||||||||||
1443 | indices[1] = o + 1; | - | ||||||||||||||||||
1444 | indices[2] = o + 2; | - | ||||||||||||||||||
1445 | indices[3] = o + 1; | - | ||||||||||||||||||
1446 | indices[4] = o + 3; | - | ||||||||||||||||||
1447 | indices[5] = o + 2; | - | ||||||||||||||||||
1448 | indices += 6; | - | ||||||||||||||||||
1449 | } executed 6000 times by 3 tests: end of block Executed by:
| 6000 | ||||||||||||||||||
1450 | } executed 12 times by 3 tests: end of block Executed by:
| 12 | ||||||||||||||||||
1451 | } executed 111 times by 21 tests: end of block Executed by:
| 111 | ||||||||||||||||||
1452 | - | |||||||||||||||||||
1453 | if (perfLevel == Sprites)
| 4-95 | ||||||||||||||||||
1454 | spritesUpdate();//Gives all vertexes the initial sprite data, then maintained per frame executed 4 times by 2 tests: spritesUpdate(); Executed by:
| 4 | ||||||||||||||||||
1455 | - | |||||||||||||||||||
1456 | foreach (QSGGeometryNode* node, m_nodes){
| 0-210 | ||||||||||||||||||
1457 | if (node == *(m_nodes.begin()))
| 12-99 | ||||||||||||||||||
1458 | node->setFlag(QSGGeometryNode::OwnsMaterial);//Root node owns the material for memory management purposes executed 99 times by 21 tests: node->setFlag(QSGGeometryNode::OwnsMaterial); Executed by:
| 99 | ||||||||||||||||||
1459 | else | - | ||||||||||||||||||
1460 | (*(m_nodes.begin()))->appendChildNode(node); executed 12 times by 5 tests: (*(m_nodes.begin()))->appendChildNode(node); Executed by:
| 12 | ||||||||||||||||||
1461 | } | - | ||||||||||||||||||
1462 | - | |||||||||||||||||||
1463 | *node = *(m_nodes.begin()); | - | ||||||||||||||||||
1464 | update(); | - | ||||||||||||||||||
1465 | } executed 99 times by 21 tests: end of block Executed by:
| 99 | ||||||||||||||||||
1466 | - | |||||||||||||||||||
1467 | static inline bool isOpenGL(QSGRenderContext *rc) | - | ||||||||||||||||||
1468 | { | - | ||||||||||||||||||
1469 | QSGRendererInterface *rif = rc->sceneGraphContext()->rendererInterface(rc); | - | ||||||||||||||||||
1470 | return !rif || rif->graphicsApi() == QSGRendererInterface::OpenGL; executed 461 times by 22 tests: return !rif || rif->graphicsApi() == QSGRendererInterface::OpenGL; Executed by:
| 461 | ||||||||||||||||||
1471 | } | - | ||||||||||||||||||
1472 | - | |||||||||||||||||||
1473 | QSGNode *QQuickImageParticle::updatePaintNode(QSGNode *node, UpdatePaintNodeData *) | - | ||||||||||||||||||
1474 | { | - | ||||||||||||||||||
1475 | if (!node && !isOpenGL(QQuickItemPrivate::get(this)->sceneGraphRenderContext()))
| 0-3848 | ||||||||||||||||||
1476 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||
1477 | - | |||||||||||||||||||
1478 | if (m_pleaseReset){
| 331-3978 | ||||||||||||||||||
1479 | if (node)
| 37-294 | ||||||||||||||||||
1480 | delete node; executed 37 times by 4 tests: delete node; Executed by:
| 37 | ||||||||||||||||||
1481 | node = nullptr; | - | ||||||||||||||||||
1482 | - | |||||||||||||||||||
1483 | m_lastLevel = perfLevel; | - | ||||||||||||||||||
1484 | m_nodes.clear(); | - | ||||||||||||||||||
1485 | - | |||||||||||||||||||
1486 | m_idxStarts.clear(); | - | ||||||||||||||||||
1487 | m_startsIdx.clear(); | - | ||||||||||||||||||
1488 | m_lastIdxStart = 0; | - | ||||||||||||||||||
1489 | - | |||||||||||||||||||
1490 | m_material = nullptr; | - | ||||||||||||||||||
1491 | - | |||||||||||||||||||
1492 | m_pleaseReset = false; | - | ||||||||||||||||||
1493 | m_startedImageLoading = 0;//Cancel a part-way build (may still have a pending load) | - | ||||||||||||||||||
1494 | } executed 331 times by 22 tests: end of block Executed by:
| 331 | ||||||||||||||||||
1495 | - | |||||||||||||||||||
1496 | if (m_system && m_system->isRunning() && !m_system->isPaused()){
| 0-4309 | ||||||||||||||||||
1497 | prepareNextFrame(&node); | - | ||||||||||||||||||
1498 | if (node) {
| 389-3910 | ||||||||||||||||||
1499 | update(); | - | ||||||||||||||||||
1500 | foreach (QSGGeometryNode* n, m_nodes)
| 0-8503 | ||||||||||||||||||
1501 | n->markDirty(QSGNode::DirtyGeometry); executed 4593 times by 21 tests: n->markDirty(QSGNode::DirtyGeometry); Executed by:
| 4593 | ||||||||||||||||||
1502 | } else if (m_startedImageLoading < 2) { executed 3910 times by 21 tests: end of block Executed by:
| 4-3910 | ||||||||||||||||||
1503 | update();//To call prepareNextFrame() again from the renderThread | - | ||||||||||||||||||
1504 | } executed 385 times by 22 tests: end of block Executed by:
| 385 | ||||||||||||||||||
1505 | } executed 4299 times by 22 tests: end of block Executed by:
| 4299 | ||||||||||||||||||
1506 | - | |||||||||||||||||||
1507 | return node; executed 4309 times by 22 tests: return node; Executed by:
| 4309 | ||||||||||||||||||
1508 | } | - | ||||||||||||||||||
1509 | - | |||||||||||||||||||
1510 | void QQuickImageParticle::prepareNextFrame(QSGNode **node) | - | ||||||||||||||||||
1511 | { | - | ||||||||||||||||||
1512 | if (*node == nullptr){//TODO: Staggered loading (as emitted)
| 488-3811 | ||||||||||||||||||
1513 | buildParticleNodes(node); | - | ||||||||||||||||||
1514 | if (m_debugMode) {
| 12-476 | ||||||||||||||||||
1515 | qDebug() << "QQuickImageParticle Feature level: " << perfLevel; | - | ||||||||||||||||||
1516 | qDebug() << "QQuickImageParticle Nodes: "; | - | ||||||||||||||||||
1517 | int count = 0; | - | ||||||||||||||||||
1518 | for (auto it = m_nodes.keyBegin(), end = m_nodes.keyEnd(); it != end; ++it) {
| 12 | ||||||||||||||||||
1519 | qDebug() << "Group " << *it << " (" << m_system->groupData[*it]->size() | - | ||||||||||||||||||
1520 | << " particles)"; | - | ||||||||||||||||||
1521 | count += m_system->groupData[*it]->size(); | - | ||||||||||||||||||
1522 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||
1523 | qDebug() << "Total count: " << count; | - | ||||||||||||||||||
1524 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||
1525 | if (*node == nullptr)
| 99-389 | ||||||||||||||||||
1526 | return; executed 389 times by 22 tests: return; Executed by:
| 389 | ||||||||||||||||||
1527 | } executed 99 times by 21 tests: end of block Executed by:
| 99 | ||||||||||||||||||
1528 | qint64 timeStamp = m_system->systemSync(this); | - | ||||||||||||||||||
1529 | - | |||||||||||||||||||
1530 | qreal time = timeStamp / 1000.; | - | ||||||||||||||||||
1531 | - | |||||||||||||||||||
1532 | switch (perfLevel){//Fall-through intended | - | ||||||||||||||||||
1533 | case Sprites: executed 267 times by 2 tests: case Sprites: Executed by:
| 267 | ||||||||||||||||||
1534 | //Advance State | - | ||||||||||||||||||
1535 | if (m_spriteEngine)
| 0-267 | ||||||||||||||||||
1536 | m_spriteEngine->updateSprites(timeStamp);//fires signals if anim changed executed 267 times by 2 tests: m_spriteEngine->updateSprites(timeStamp); Executed by:
| 267 | ||||||||||||||||||
1537 | spritesUpdate(time); | - | ||||||||||||||||||
1538 | Q_FALLTHROUGH(); | - | ||||||||||||||||||
1539 | case Tabled: code before this statement executed 267 times by 2 tests: case Tabled: Executed by:
executed 125 times by 1 test: case Tabled: Executed by:
| 125-267 | ||||||||||||||||||
1540 | case Deformable: executed 308 times by 2 tests: case Deformable: Executed by:
| 308 | ||||||||||||||||||
1541 | case Colored: executed 258 times by 1 test: case Colored: Executed by:
| 258 | ||||||||||||||||||
1542 | case Simple: executed 2952 times by 20 tests: case Simple: Executed by:
| 2952 | ||||||||||||||||||
1543 | default: //Also Simple never executed: default: | 0 | ||||||||||||||||||
1544 | getState<ImageMaterialData>(m_material)->timestamp = time; | - | ||||||||||||||||||
1545 | break; executed 3910 times by 21 tests: break; Executed by:
| 3910 | ||||||||||||||||||
1546 | } | - | ||||||||||||||||||
1547 | foreach (QSGGeometryNode* node, m_nodes)
| 0-8503 | ||||||||||||||||||
1548 | node->markDirty(QSGNode::DirtyMaterial); executed 4593 times by 21 tests: node->markDirty(QSGNode::DirtyMaterial); Executed by:
| 4593 | ||||||||||||||||||
1549 | } executed 3910 times by 21 tests: end of block Executed by:
| 3910 | ||||||||||||||||||
1550 | - | |||||||||||||||||||
1551 | void QQuickImageParticle::spritesUpdate(qreal time) | - | ||||||||||||||||||
1552 | { | - | ||||||||||||||||||
1553 | // Sprite progression handled CPU side, so as to have per-frame control. | - | ||||||||||||||||||
1554 | for (auto groupId : groupIds()) { | - | ||||||||||||||||||
1555 | for (QQuickParticleData* mainDatum : qAsConst(m_system->groupData[groupId]->data)) { | - | ||||||||||||||||||
1556 | QSGGeometryNode *node = m_nodes[groupId]; | - | ||||||||||||||||||
1557 | if (!node)
| 0-135500 | ||||||||||||||||||
1558 | continue; never executed: continue; | 0 | ||||||||||||||||||
1559 | //TODO: Interpolate between two different animations if it's going to transition next frame | - | ||||||||||||||||||
1560 | // This is particularly important for cut-up sprites. | - | ||||||||||||||||||
1561 | QQuickParticleData* datum = (mainDatum->animationOwner == this ? mainDatum : getShadowDatum(mainDatum));
| 58119-77381 | ||||||||||||||||||
1562 | int spriteIdx = 0; | - | ||||||||||||||||||
1563 | for (int i = 0; i<m_startsIdx.count(); i++) {
| 0-135500 | ||||||||||||||||||
1564 | if (m_startsIdx[i].second == groupId){
| 0-135500 | ||||||||||||||||||
1565 | spriteIdx = m_startsIdx[i].first + datum->index; | - | ||||||||||||||||||
1566 | break; executed 135500 times by 2 tests: break; Executed by:
| 135500 | ||||||||||||||||||
1567 | } | - | ||||||||||||||||||
1568 | } never executed: end of block | 0 | ||||||||||||||||||
1569 | - | |||||||||||||||||||
1570 | double frameAt; | - | ||||||||||||||||||
1571 | qreal progress = 0; | - | ||||||||||||||||||
1572 | - | |||||||||||||||||||
1573 | if (datum->frameDuration > 0) {
| 0-135500 | ||||||||||||||||||
1574 | qreal frame = (time - datum->animT)/(datum->frameDuration / 1000.0); | - | ||||||||||||||||||
1575 | frame = qBound((qreal)0.0, frame, (qreal)((qreal)datum->frameCount - 1.0));//Stop at count-1 frames until we have between anim interpolation | - | ||||||||||||||||||
1576 | if (m_spritesInterpolate)
| 0-135500 | ||||||||||||||||||
1577 | progress = std::modf(frame,&frameAt); executed 135500 times by 2 tests: progress = std::modf(frame,&frameAt); Executed by:
| 135500 | ||||||||||||||||||
1578 | else | - | ||||||||||||||||||
1579 | std::modf(frame,&frameAt); never executed: std::modf(frame,&frameAt); | 0 | ||||||||||||||||||
1580 | } else { | - | ||||||||||||||||||
1581 | datum->frameAt++; | - | ||||||||||||||||||
1582 | if (datum->frameAt >= datum->frameCount){
| 0 | ||||||||||||||||||
1583 | datum->frameAt = 0; | - | ||||||||||||||||||
1584 | m_spriteEngine->advance(spriteIdx); | - | ||||||||||||||||||
1585 | } never executed: end of block | 0 | ||||||||||||||||||
1586 | frameAt = datum->frameAt; | - | ||||||||||||||||||
1587 | } never executed: end of block | 0 | ||||||||||||||||||
1588 | if (m_spriteEngine->sprite(spriteIdx)->reverse())//### Store this in datum too?
| 0-135500 | ||||||||||||||||||
1589 | frameAt = (datum->frameCount - 1) - frameAt; never executed: frameAt = (datum->frameCount - 1) - frameAt; | 0 | ||||||||||||||||||
1590 | QSizeF sheetSize = getState<ImageMaterialData>(m_material)->animSheetSize; | - | ||||||||||||||||||
1591 | qreal y = datum->animY / sheetSize.height(); | - | ||||||||||||||||||
1592 | qreal w = datum->animWidth / sheetSize.width(); | - | ||||||||||||||||||
1593 | qreal h = datum->animHeight / sheetSize.height(); | - | ||||||||||||||||||
1594 | qreal x1 = datum->animX / sheetSize.width(); | - | ||||||||||||||||||
1595 | x1 += frameAt * w; | - | ||||||||||||||||||
1596 | qreal x2 = x1; | - | ||||||||||||||||||
1597 | if (frameAt < (datum->frameCount-1))
| 58471-77029 | ||||||||||||||||||
1598 | x2 += w; executed 77029 times by 2 tests: x2 += w; Executed by:
| 77029 | ||||||||||||||||||
1599 | - | |||||||||||||||||||
1600 | SpriteVertex *spriteVertices = (SpriteVertex *) node->geometry()->vertexData(); | - | ||||||||||||||||||
1601 | spriteVertices += datum->index*4; | - | ||||||||||||||||||
1602 | for (int i=0; i<4; i++) {
| 135500-542000 | ||||||||||||||||||
1603 | spriteVertices[i].animX1 = x1; | - | ||||||||||||||||||
1604 | spriteVertices[i].animY1 = y; | - | ||||||||||||||||||
1605 | spriteVertices[i].animX2 = x2; | - | ||||||||||||||||||
1606 | spriteVertices[i].animY2 = y; | - | ||||||||||||||||||
1607 | spriteVertices[i].animW = w; | - | ||||||||||||||||||
1608 | spriteVertices[i].animH = h; | - | ||||||||||||||||||
1609 | spriteVertices[i].animProgress = progress; | - | ||||||||||||||||||
1610 | } executed 542000 times by 2 tests: end of block Executed by:
| 542000 | ||||||||||||||||||
1611 | } executed 135500 times by 2 tests: end of block Executed by:
| 135500 | ||||||||||||||||||
1612 | } executed 271 times by 2 tests: end of block Executed by:
| 271 | ||||||||||||||||||
1613 | } executed 271 times by 2 tests: end of block Executed by:
| 271 | ||||||||||||||||||
1614 | - | |||||||||||||||||||
1615 | void QQuickImageParticle::spriteAdvance(int spriteIdx) | - | ||||||||||||||||||
1616 | { | - | ||||||||||||||||||
1617 | if (!m_startsIdx.count())//Probably overly defensive
| 0-1200 | ||||||||||||||||||
1618 | return; never executed: return; | 0 | ||||||||||||||||||
1619 | - | |||||||||||||||||||
1620 | int gIdx = -1; | - | ||||||||||||||||||
1621 | int i; | - | ||||||||||||||||||
1622 | for (i = 0; i<m_startsIdx.count(); i++) {
| 1200 | ||||||||||||||||||
1623 | if (spriteIdx < m_startsIdx[i].first) {
| 0-1200 | ||||||||||||||||||
1624 | gIdx = m_startsIdx[i-1].second; | - | ||||||||||||||||||
1625 | break; never executed: break; | 0 | ||||||||||||||||||
1626 | } | - | ||||||||||||||||||
1627 | } executed 1200 times by 1 test: end of block Executed by:
| 1200 | ||||||||||||||||||
1628 | if (gIdx == -1)
| 0-1200 | ||||||||||||||||||
1629 | gIdx = m_startsIdx[i-1].second; executed 1200 times by 1 test: gIdx = m_startsIdx[i-1].second; Executed by:
| 1200 | ||||||||||||||||||
1630 | int pIdx = spriteIdx - m_startsIdx[i-1].first; | - | ||||||||||||||||||
1631 | - | |||||||||||||||||||
1632 | QQuickParticleData* mainDatum = m_system->groupData[gIdx]->data[pIdx]; | - | ||||||||||||||||||
1633 | QQuickParticleData* datum = (mainDatum->animationOwner == this ? mainDatum : getShadowDatum(mainDatum));
| 0-1200 | ||||||||||||||||||
1634 | - | |||||||||||||||||||
1635 | datum->animIdx = m_spriteEngine->spriteState(spriteIdx); | - | ||||||||||||||||||
1636 | datum->animT = m_spriteEngine->spriteStart(spriteIdx)/1000.0; | - | ||||||||||||||||||
1637 | datum->frameCount = m_spriteEngine->spriteFrames(spriteIdx); | - | ||||||||||||||||||
1638 | datum->frameDuration = m_spriteEngine->spriteDuration(spriteIdx) / datum->frameCount; | - | ||||||||||||||||||
1639 | datum->animX = m_spriteEngine->spriteX(spriteIdx); | - | ||||||||||||||||||
1640 | datum->animY = m_spriteEngine->spriteY(spriteIdx); | - | ||||||||||||||||||
1641 | datum->animWidth = m_spriteEngine->spriteWidth(spriteIdx); | - | ||||||||||||||||||
1642 | datum->animHeight = m_spriteEngine->spriteHeight(spriteIdx); | - | ||||||||||||||||||
1643 | } executed 1200 times by 1 test: end of block Executed by:
| 1200 | ||||||||||||||||||
1644 | - | |||||||||||||||||||
1645 | void QQuickImageParticle::reloadColor(const Color4ub &c, QQuickParticleData* d) | - | ||||||||||||||||||
1646 | { | - | ||||||||||||||||||
1647 | d->color = c; | - | ||||||||||||||||||
1648 | //TODO: get index for reload - or make function take an index | - | ||||||||||||||||||
1649 | } never executed: end of block | 0 | ||||||||||||||||||
1650 | - | |||||||||||||||||||
1651 | void QQuickImageParticle::initialize(int gIdx, int pIdx) | - | ||||||||||||||||||
1652 | { | - | ||||||||||||||||||
1653 | Color4ub color; | - | ||||||||||||||||||
1654 | QQuickParticleData* datum = m_system->groupData[gIdx]->data[pIdx]; | - | ||||||||||||||||||
1655 | qreal redVariation = m_color_variation + m_redVariation; | - | ||||||||||||||||||
1656 | qreal greenVariation = m_color_variation + m_greenVariation; | - | ||||||||||||||||||
1657 | qreal blueVariation = m_color_variation + m_blueVariation; | - | ||||||||||||||||||
1658 | int spriteIdx = 0; | - | ||||||||||||||||||
1659 | if (m_spriteEngine) {
| 2464-44412 | ||||||||||||||||||
1660 | spriteIdx = m_idxStarts[gIdx] + datum->index; | - | ||||||||||||||||||
1661 | if (spriteIdx >= m_spriteEngine->count())
| 15-2449 | ||||||||||||||||||
1662 | m_spriteEngine->setCount(spriteIdx+1); executed 15 times by 1 test: m_spriteEngine->setCount(spriteIdx+1); Executed by:
| 15 | ||||||||||||||||||
1663 | } executed 2464 times by 2 tests: end of block Executed by:
| 2464 | ||||||||||||||||||
1664 | - | |||||||||||||||||||
1665 | float rotation; | - | ||||||||||||||||||
1666 | float rotationVelocity; | - | ||||||||||||||||||
1667 | float autoRotate; | - | ||||||||||||||||||
1668 | switch (perfLevel){//Fall-through is intended on all of them | - | ||||||||||||||||||
1669 | case Sprites: executed 2448 times by 2 tests: case Sprites: Executed by:
| 2448 | ||||||||||||||||||
1670 | // Initial Sprite State | - | ||||||||||||||||||
1671 | if (m_explicitAnimation && m_spriteEngine){
| 0-2448 | ||||||||||||||||||
1672 | if (!datum->animationOwner)
| 452-1996 | ||||||||||||||||||
1673 | datum->animationOwner = this; executed 1996 times by 2 tests: datum->animationOwner = this; Executed by:
| 1996 | ||||||||||||||||||
1674 | QQuickParticleData* writeTo = (datum->animationOwner == this ? datum : getShadowDatum(datum));
| 0-2448 | ||||||||||||||||||
1675 | writeTo->animT = writeTo->t; | - | ||||||||||||||||||
1676 | //writeTo->animInterpolate = m_spritesInterpolate; | - | ||||||||||||||||||
1677 | if (m_spriteEngine){
| 0-2448 | ||||||||||||||||||
1678 | m_spriteEngine->start(spriteIdx); | - | ||||||||||||||||||
1679 | writeTo->frameCount = m_spriteEngine->spriteFrames(spriteIdx); | - | ||||||||||||||||||
1680 | writeTo->frameDuration = m_spriteEngine->spriteDuration(spriteIdx) / writeTo->frameCount; | - | ||||||||||||||||||
1681 | writeTo->animIdx = 0;//Always starts at 0 | - | ||||||||||||||||||
1682 | writeTo->frameAt = -1; | - | ||||||||||||||||||
1683 | writeTo->animX = m_spriteEngine->spriteX(spriteIdx); | - | ||||||||||||||||||
1684 | writeTo->animY = m_spriteEngine->spriteY(spriteIdx); | - | ||||||||||||||||||
1685 | writeTo->animWidth = m_spriteEngine->spriteWidth(spriteIdx); | - | ||||||||||||||||||
1686 | writeTo->animHeight = m_spriteEngine->spriteHeight(spriteIdx); | - | ||||||||||||||||||
1687 | } executed 2448 times by 2 tests: end of block Executed by:
| 2448 | ||||||||||||||||||
1688 | } else { executed 2448 times by 2 tests: end of block Executed by:
| 2448 | ||||||||||||||||||
1689 | QQuickParticleData* writeTo = getShadowDatum(datum); | - | ||||||||||||||||||
1690 | writeTo->animT = datum->t; | - | ||||||||||||||||||
1691 | writeTo->frameCount = 1; | - | ||||||||||||||||||
1692 | writeTo->frameDuration = 60000000.0; | - | ||||||||||||||||||
1693 | writeTo->frameAt = -1; | - | ||||||||||||||||||
1694 | writeTo->animIdx = 0; | - | ||||||||||||||||||
1695 | writeTo->animT = 0; | - | ||||||||||||||||||
1696 | writeTo->animX = writeTo->animY = 0; | - | ||||||||||||||||||
1697 | writeTo->animWidth = getState<ImageMaterialData>(m_material)->animSheetSize.width(); | - | ||||||||||||||||||
1698 | writeTo->animHeight = getState<ImageMaterialData>(m_material)->animSheetSize.height(); | - | ||||||||||||||||||
1699 | } never executed: end of block | 0 | ||||||||||||||||||
1700 | Q_FALLTHROUGH(); | - | ||||||||||||||||||
1701 | case Tabled: code before this statement executed 2448 times by 2 tests: case Tabled: Executed by:
executed 1280 times by 1 test: case Tabled: Executed by:
| 1280-2448 | ||||||||||||||||||
1702 | case Deformable: executed 3776 times by 2 tests: case Deformable: Executed by:
| 3776 | ||||||||||||||||||
1703 | //Initial Rotation | - | ||||||||||||||||||
1704 | if (m_explicitDeformation){
| 1264-6240 | ||||||||||||||||||
1705 | if (!datum->deformationOwner)
| 266-998 | ||||||||||||||||||
1706 | datum->deformationOwner = this; executed 998 times by 1 test: datum->deformationOwner = this; Executed by:
| 998 | ||||||||||||||||||
1707 | if (m_xVector){
| 0-1264 | ||||||||||||||||||
1708 | const QPointF &ret = m_xVector->sample(QPointF(datum->x, datum->y)); | - | ||||||||||||||||||
1709 | if (datum->deformationOwner == this) {
| 0-1264 | ||||||||||||||||||
1710 | datum->xx = ret.x(); | - | ||||||||||||||||||
1711 | datum->xy = ret.y(); | - | ||||||||||||||||||
1712 | } else { executed 1264 times by 1 test: end of block Executed by:
| 1264 | ||||||||||||||||||
1713 | getShadowDatum(datum)->xx = ret.x(); | - | ||||||||||||||||||
1714 | getShadowDatum(datum)->xy = ret.y(); | - | ||||||||||||||||||
1715 | } never executed: end of block | 0 | ||||||||||||||||||
1716 | } | - | ||||||||||||||||||
1717 | if (m_yVector){
| 0-1264 | ||||||||||||||||||
1718 | const QPointF &ret = m_yVector->sample(QPointF(datum->x, datum->y)); | - | ||||||||||||||||||
1719 | if (datum->deformationOwner == this) {
| 0-1264 | ||||||||||||||||||
1720 | datum->yx = ret.x(); | - | ||||||||||||||||||
1721 | datum->yy = ret.y(); | - | ||||||||||||||||||
1722 | } else { executed 1264 times by 1 test: end of block Executed by:
| 1264 | ||||||||||||||||||
1723 | getShadowDatum(datum)->yx = ret.x(); | - | ||||||||||||||||||
1724 | getShadowDatum(datum)->yy = ret.y(); | - | ||||||||||||||||||
1725 | } never executed: end of block | 0 | ||||||||||||||||||
1726 | } | - | ||||||||||||||||||
1727 | } executed 1264 times by 1 test: end of block Executed by:
| 1264 | ||||||||||||||||||
1728 | - | |||||||||||||||||||
1729 | if (m_explicitRotation){
| 3728-3776 | ||||||||||||||||||
1730 | if (!datum->rotationOwner)
| 782-2994 | ||||||||||||||||||
1731 | datum->rotationOwner = this; executed 2994 times by 2 tests: datum->rotationOwner = this; Executed by:
| 2994 | ||||||||||||||||||
1732 | rotation = | - | ||||||||||||||||||
1733 | (m_rotation + (m_rotationVariation - 2*QRandomGenerator::global()->bounded(m_rotationVariation)) ) * CONV; | - | ||||||||||||||||||
1734 | rotationVelocity = | - | ||||||||||||||||||
1735 | (m_rotationVelocity + (m_rotationVelocityVariation - 2*QRandomGenerator::global()->bounded(m_rotationVelocityVariation)) ) * CONV; | - | ||||||||||||||||||
1736 | autoRotate = m_autoRotation?1.0:0.0;
| 1264-2512 | ||||||||||||||||||
1737 | if (datum->rotationOwner == this) {
| 0-3776 | ||||||||||||||||||
1738 | datum->rotation = rotation; | - | ||||||||||||||||||
1739 | datum->rotationVelocity = rotationVelocity; | - | ||||||||||||||||||
1740 | datum->autoRotate = autoRotate; | - | ||||||||||||||||||
1741 | } else { executed 3776 times by 2 tests: end of block Executed by:
| 3776 | ||||||||||||||||||
1742 | getShadowDatum(datum)->rotation = rotation; | - | ||||||||||||||||||
1743 | getShadowDatum(datum)->rotationVelocity = rotationVelocity; | - | ||||||||||||||||||
1744 | getShadowDatum(datum)->autoRotate = autoRotate; | - | ||||||||||||||||||
1745 | } never executed: end of block | 0 | ||||||||||||||||||
1746 | } | - | ||||||||||||||||||
1747 | Q_FALLTHROUGH(); | - | ||||||||||||||||||
1748 | case Colored: code before this statement executed 7504 times by 3 tests: case Colored: Executed by:
executed 2528 times by 1 test: case Colored: Executed by:
| 2528-7504 | ||||||||||||||||||
1749 | //Color initialization | - | ||||||||||||||||||
1750 | // Particle color | - | ||||||||||||||||||
1751 | if (m_explicitColor) {
| 2528-7504 | ||||||||||||||||||
1752 | if (!datum->colorOwner)
| 532-1996 | ||||||||||||||||||
1753 | datum->colorOwner = this; executed 1996 times by 1 test: datum->colorOwner = this; Executed by:
| 1996 | ||||||||||||||||||
1754 | color.r = m_color.red() * (1 - redVariation) + QRandomGenerator::global()->bounded(256) * redVariation; | - | ||||||||||||||||||
1755 | color.g = m_color.green() * (1 - greenVariation) + QRandomGenerator::global()->bounded(256) * greenVariation; | - | ||||||||||||||||||
1756 | color.b = m_color.blue() * (1 - blueVariation) + QRandomGenerator::global()->bounded(256) * blueVariation; | - | ||||||||||||||||||
1757 | color.a = m_alpha * m_color.alpha() * (1 - m_alphaVariation) + QRandomGenerator::global()->bounded(256) * m_alphaVariation; | - | ||||||||||||||||||
1758 | if (datum->colorOwner == this)
| 0-2528 | ||||||||||||||||||
1759 | datum->color = color; executed 2528 times by 1 test: datum->color = color; Executed by:
| 2528 | ||||||||||||||||||
1760 | else | - | ||||||||||||||||||
1761 | getShadowDatum(datum)->color = color; never executed: getShadowDatum(datum)->color = color; | 0 | ||||||||||||||||||
1762 | } | - | ||||||||||||||||||
1763 | default: code before this statement executed 10032 times by 3 tests: default: Executed by:
executed 46876 times by 21 tests: default: Executed by:
| 10032-46876 | ||||||||||||||||||
1764 | break; executed 46876 times by 21 tests: break; Executed by:
| 46876 | ||||||||||||||||||
1765 | } | - | ||||||||||||||||||
1766 | } | - | ||||||||||||||||||
1767 | - | |||||||||||||||||||
1768 | void QQuickImageParticle::commit(int gIdx, int pIdx) | - | ||||||||||||||||||
1769 | { | - | ||||||||||||||||||
1770 | if (m_pleaseReset)
| 0-230487 | ||||||||||||||||||
1771 | return; never executed: return; | 0 | ||||||||||||||||||
1772 | QSGGeometryNode *node = m_nodes[gIdx]; | - | ||||||||||||||||||
1773 | if (!node)
| 0-230487 | ||||||||||||||||||
1774 | return; never executed: return; | 0 | ||||||||||||||||||
1775 | QQuickParticleData* datum = m_system->groupData[gIdx]->data[pIdx]; | - | ||||||||||||||||||
1776 | SpriteVertex *spriteVertices = (SpriteVertex *) node->geometry()->vertexData(); | - | ||||||||||||||||||
1777 | DeformableVertex *deformableVertices = (DeformableVertex *) node->geometry()->vertexData(); | - | ||||||||||||||||||
1778 | ColoredVertex *coloredVertices = (ColoredVertex *) node->geometry()->vertexData(); | - | ||||||||||||||||||
1779 | SimpleVertex *simpleVertices = (SimpleVertex *) node->geometry()->vertexData(); | - | ||||||||||||||||||
1780 | switch (perfLevel){//No automatic fall through intended on this one | - | ||||||||||||||||||
1781 | case Sprites: executed 4432 times by 2 tests: case Sprites: Executed by:
| 4432 | ||||||||||||||||||
1782 | spriteVertices += pIdx*4; | - | ||||||||||||||||||
1783 | for (int i=0; i<4; i++){
| 4432-17728 | ||||||||||||||||||
1784 | spriteVertices[i].x = datum->x - m_systemOffset.x(); | - | ||||||||||||||||||
1785 | spriteVertices[i].y = datum->y - m_systemOffset.y(); | - | ||||||||||||||||||
1786 | spriteVertices[i].t = datum->t; | - | ||||||||||||||||||
1787 | spriteVertices[i].lifeSpan = datum->lifeSpan; | - | ||||||||||||||||||
1788 | spriteVertices[i].size = datum->size; | - | ||||||||||||||||||
1789 | spriteVertices[i].endSize = datum->endSize; | - | ||||||||||||||||||
1790 | spriteVertices[i].vx = datum->vx; | - | ||||||||||||||||||
1791 | spriteVertices[i].vy = datum->vy; | - | ||||||||||||||||||
1792 | spriteVertices[i].ax = datum->ax; | - | ||||||||||||||||||
1793 | spriteVertices[i].ay = datum->ay; | - | ||||||||||||||||||
1794 | if (m_explicitDeformation && datum->deformationOwner != this) {
| 0-17728 | ||||||||||||||||||
1795 | QQuickParticleData* shadow = getShadowDatum(datum); | - | ||||||||||||||||||
1796 | spriteVertices[i].xx = shadow->xx; | - | ||||||||||||||||||
1797 | spriteVertices[i].xy = shadow->xy; | - | ||||||||||||||||||
1798 | spriteVertices[i].yx = shadow->yx; | - | ||||||||||||||||||
1799 | spriteVertices[i].yy = shadow->yy; | - | ||||||||||||||||||
1800 | } else { never executed: end of block | 0 | ||||||||||||||||||
1801 | spriteVertices[i].xx = datum->xx; | - | ||||||||||||||||||
1802 | spriteVertices[i].xy = datum->xy; | - | ||||||||||||||||||
1803 | spriteVertices[i].yx = datum->yx; | - | ||||||||||||||||||
1804 | spriteVertices[i].yy = datum->yy; | - | ||||||||||||||||||
1805 | } executed 17728 times by 2 tests: end of block Executed by:
| 17728 | ||||||||||||||||||
1806 | if (m_explicitRotation && datum->rotationOwner != this) {
| 0-17728 | ||||||||||||||||||
1807 | QQuickParticleData* shadow = getShadowDatum(datum); | - | ||||||||||||||||||
1808 | spriteVertices[i].rotation = shadow->rotation; | - | ||||||||||||||||||
1809 | spriteVertices[i].rotationVelocity = shadow->rotationVelocity; | - | ||||||||||||||||||
1810 | spriteVertices[i].autoRotate = shadow->autoRotate; | - | ||||||||||||||||||
1811 | } else { never executed: end of block | 0 | ||||||||||||||||||
1812 | spriteVertices[i].rotation = datum->rotation; | - | ||||||||||||||||||
1813 | spriteVertices[i].rotationVelocity = datum->rotationVelocity; | - | ||||||||||||||||||
1814 | spriteVertices[i].autoRotate = datum->autoRotate; | - | ||||||||||||||||||
1815 | } executed 17728 times by 2 tests: end of block Executed by:
| 17728 | ||||||||||||||||||
1816 | //Sprite-related vertices updated per-frame in spritesUpdate(), not on demand | - | ||||||||||||||||||
1817 | if (m_explicitColor && datum->colorOwner != this) {
| 0-17728 | ||||||||||||||||||
1818 | QQuickParticleData* shadow = getShadowDatum(datum); | - | ||||||||||||||||||
1819 | spriteVertices[i].color.r = shadow->color.r; | - | ||||||||||||||||||
1820 | spriteVertices[i].color.g = shadow->color.g; | - | ||||||||||||||||||
1821 | spriteVertices[i].color.b = shadow->color.b; | - | ||||||||||||||||||
1822 | spriteVertices[i].color.a = shadow->color.a; | - | ||||||||||||||||||
1823 | } else { never executed: end of block | 0 | ||||||||||||||||||
1824 | spriteVertices[i].color.r = datum->color.r; | - | ||||||||||||||||||
1825 | spriteVertices[i].color.g = datum->color.g; | - | ||||||||||||||||||
1826 | spriteVertices[i].color.b = datum->color.b; | - | ||||||||||||||||||
1827 | spriteVertices[i].color.a = datum->color.a; | - | ||||||||||||||||||
1828 | } executed 17728 times by 2 tests: end of block Executed by:
| 17728 | ||||||||||||||||||
1829 | } | - | ||||||||||||||||||
1830 | break; executed 4432 times by 2 tests: break; Executed by:
| 4432 | ||||||||||||||||||
1831 | case Tabled: //Fall through until it has its own vertex class executed 2264 times by 1 test: case Tabled: Executed by:
| 2264 | ||||||||||||||||||
1832 | case Deformable: executed 6696 times by 2 tests: case Deformable: Executed by:
| 6696 | ||||||||||||||||||
1833 | deformableVertices += pIdx*4; | - | ||||||||||||||||||
1834 | for (int i=0; i<4; i++){
| 8960-35840 | ||||||||||||||||||
1835 | deformableVertices[i].x = datum->x - m_systemOffset.x(); | - | ||||||||||||||||||
1836 | deformableVertices[i].y = datum->y - m_systemOffset.y(); | - | ||||||||||||||||||
1837 | deformableVertices[i].t = datum->t; | - | ||||||||||||||||||
1838 | deformableVertices[i].lifeSpan = datum->lifeSpan; | - | ||||||||||||||||||
1839 | deformableVertices[i].size = datum->size; | - | ||||||||||||||||||
1840 | deformableVertices[i].endSize = datum->endSize; | - | ||||||||||||||||||
1841 | deformableVertices[i].vx = datum->vx; | - | ||||||||||||||||||
1842 | deformableVertices[i].vy = datum->vy; | - | ||||||||||||||||||
1843 | deformableVertices[i].ax = datum->ax; | - | ||||||||||||||||||
1844 | deformableVertices[i].ay = datum->ay; | - | ||||||||||||||||||
1845 | if (m_explicitDeformation && datum->deformationOwner != this) {
| 4000-26848 | ||||||||||||||||||
1846 | QQuickParticleData* shadow = getShadowDatum(datum); | - | ||||||||||||||||||
1847 | deformableVertices[i].xx = shadow->xx; | - | ||||||||||||||||||
1848 | deformableVertices[i].xy = shadow->xy; | - | ||||||||||||||||||
1849 | deformableVertices[i].yx = shadow->yx; | - | ||||||||||||||||||
1850 | deformableVertices[i].yy = shadow->yy; | - | ||||||||||||||||||
1851 | } else { executed 4000 times by 1 test: end of block Executed by:
| 4000 | ||||||||||||||||||
1852 | deformableVertices[i].xx = datum->xx; | - | ||||||||||||||||||
1853 | deformableVertices[i].xy = datum->xy; | - | ||||||||||||||||||
1854 | deformableVertices[i].yx = datum->yx; | - | ||||||||||||||||||
1855 | deformableVertices[i].yy = datum->yy; | - | ||||||||||||||||||
1856 | } executed 31840 times by 2 tests: end of block Executed by:
| 31840 | ||||||||||||||||||
1857 | if (m_explicitRotation && datum->rotationOwner != this) {
| 9056-26784 | ||||||||||||||||||
1858 | QQuickParticleData* shadow = getShadowDatum(datum); | - | ||||||||||||||||||
1859 | deformableVertices[i].rotation = shadow->rotation; | - | ||||||||||||||||||
1860 | deformableVertices[i].rotationVelocity = shadow->rotationVelocity; | - | ||||||||||||||||||
1861 | deformableVertices[i].autoRotate = shadow->autoRotate; | - | ||||||||||||||||||
1862 | } else { executed 12000 times by 2 tests: end of block Executed by:
| 12000 | ||||||||||||||||||
1863 | deformableVertices[i].rotation = datum->rotation; | - | ||||||||||||||||||
1864 | deformableVertices[i].rotationVelocity = datum->rotationVelocity; | - | ||||||||||||||||||
1865 | deformableVertices[i].autoRotate = datum->autoRotate; | - | ||||||||||||||||||
1866 | } executed 23840 times by 2 tests: end of block Executed by:
| 23840 | ||||||||||||||||||
1867 | if (m_explicitColor && datum->colorOwner != this) {
| 0-35840 | ||||||||||||||||||
1868 | QQuickParticleData* shadow = getShadowDatum(datum); | - | ||||||||||||||||||
1869 | deformableVertices[i].color.r = shadow->color.r; | - | ||||||||||||||||||
1870 | deformableVertices[i].color.g = shadow->color.g; | - | ||||||||||||||||||
1871 | deformableVertices[i].color.b = shadow->color.b; | - | ||||||||||||||||||
1872 | deformableVertices[i].color.a = shadow->color.a; | - | ||||||||||||||||||
1873 | } else { never executed: end of block | 0 | ||||||||||||||||||
1874 | deformableVertices[i].color.r = datum->color.r; | - | ||||||||||||||||||
1875 | deformableVertices[i].color.g = datum->color.g; | - | ||||||||||||||||||
1876 | deformableVertices[i].color.b = datum->color.b; | - | ||||||||||||||||||
1877 | deformableVertices[i].color.a = datum->color.a; | - | ||||||||||||||||||
1878 | } executed 35840 times by 2 tests: end of block Executed by:
| 35840 | ||||||||||||||||||
1879 | } | - | ||||||||||||||||||
1880 | break; executed 8960 times by 2 tests: break; Executed by:
| 8960 | ||||||||||||||||||
1881 | case Colored: executed 4512 times by 1 test: case Colored: Executed by:
| 4512 | ||||||||||||||||||
1882 | coloredVertices += pIdx*1; | - | ||||||||||||||||||
1883 | for (int i=0; i<1; i++){
| 4512 | ||||||||||||||||||
1884 | coloredVertices[i].x = datum->x - m_systemOffset.x(); | - | ||||||||||||||||||
1885 | coloredVertices[i].y = datum->y - m_systemOffset.y(); | - | ||||||||||||||||||
1886 | coloredVertices[i].t = datum->t; | - | ||||||||||||||||||
1887 | coloredVertices[i].lifeSpan = datum->lifeSpan; | - | ||||||||||||||||||
1888 | coloredVertices[i].size = datum->size; | - | ||||||||||||||||||
1889 | coloredVertices[i].endSize = datum->endSize; | - | ||||||||||||||||||
1890 | coloredVertices[i].vx = datum->vx; | - | ||||||||||||||||||
1891 | coloredVertices[i].vy = datum->vy; | - | ||||||||||||||||||
1892 | coloredVertices[i].ax = datum->ax; | - | ||||||||||||||||||
1893 | coloredVertices[i].ay = datum->ay; | - | ||||||||||||||||||
1894 | if (m_explicitColor && datum->colorOwner != this) {
| 0-4512 | ||||||||||||||||||
1895 | QQuickParticleData* shadow = getShadowDatum(datum); | - | ||||||||||||||||||
1896 | coloredVertices[i].color.r = shadow->color.r; | - | ||||||||||||||||||
1897 | coloredVertices[i].color.g = shadow->color.g; | - | ||||||||||||||||||
1898 | coloredVertices[i].color.b = shadow->color.b; | - | ||||||||||||||||||
1899 | coloredVertices[i].color.a = shadow->color.a; | - | ||||||||||||||||||
1900 | } else { executed 2016 times by 1 test: end of block Executed by:
| 2016 | ||||||||||||||||||
1901 | coloredVertices[i].color.r = datum->color.r; | - | ||||||||||||||||||
1902 | coloredVertices[i].color.g = datum->color.g; | - | ||||||||||||||||||
1903 | coloredVertices[i].color.b = datum->color.b; | - | ||||||||||||||||||
1904 | coloredVertices[i].color.a = datum->color.a; | - | ||||||||||||||||||
1905 | } executed 2496 times by 1 test: end of block Executed by:
| 2496 | ||||||||||||||||||
1906 | } | - | ||||||||||||||||||
1907 | break; executed 4512 times by 1 test: break; Executed by:
| 4512 | ||||||||||||||||||
1908 | case Simple: executed 212583 times by 20 tests: case Simple: Executed by:
| 212583 | ||||||||||||||||||
1909 | simpleVertices += pIdx*1; | - | ||||||||||||||||||
1910 | for (int i=0; i<1; i++){
| 212583 | ||||||||||||||||||
1911 | simpleVertices[i].x = datum->x - m_systemOffset.x(); | - | ||||||||||||||||||
1912 | simpleVertices[i].y = datum->y - m_systemOffset.y(); | - | ||||||||||||||||||
1913 | simpleVertices[i].t = datum->t; | - | ||||||||||||||||||
1914 | simpleVertices[i].lifeSpan = datum->lifeSpan; | - | ||||||||||||||||||
1915 | simpleVertices[i].size = datum->size; | - | ||||||||||||||||||
1916 | simpleVertices[i].endSize = datum->endSize; | - | ||||||||||||||||||
1917 | simpleVertices[i].vx = datum->vx; | - | ||||||||||||||||||
1918 | simpleVertices[i].vy = datum->vy; | - | ||||||||||||||||||
1919 | simpleVertices[i].ax = datum->ax; | - | ||||||||||||||||||
1920 | simpleVertices[i].ay = datum->ay; | - | ||||||||||||||||||
1921 | } executed 212583 times by 20 tests: end of block Executed by:
| 212583 | ||||||||||||||||||
1922 | break; executed 212583 times by 20 tests: break; Executed by:
| 212583 | ||||||||||||||||||
1923 | default: never executed: default: | 0 | ||||||||||||||||||
1924 | break; never executed: break; | 0 | ||||||||||||||||||
1925 | } | - | ||||||||||||||||||
1926 | } | - | ||||||||||||||||||
1927 | - | |||||||||||||||||||
1928 | - | |||||||||||||||||||
1929 | - | |||||||||||||||||||
1930 | QT_END_NAMESPACE | - | ||||||||||||||||||
1931 | - | |||||||||||||||||||
1932 | #include "moc_qquickimageparticle_p.cpp" | - | ||||||||||||||||||
Source code | Switch to Preprocessed file |