Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/particles/qquickitemparticle.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||
2 | - | |||||||||||||||||||
3 | QQuickItemParticle::QQuickItemParticle(QQuickItem *parent) : | - | ||||||||||||||||||
4 | QQuickParticlePainter(parent), m_fade(true), m_lastT(0), m_activeCount(0), m_delegate(nullptr) | - | ||||||||||||||||||
5 | { | - | ||||||||||||||||||
6 | setFlag(QQuickItem::ItemHasContents); | - | ||||||||||||||||||
7 | clock = new Clock(this); | - | ||||||||||||||||||
8 | clock->start(); | - | ||||||||||||||||||
9 | } executed 8 times by 2 tests: end of block Executed by:
| 8 | ||||||||||||||||||
10 | - | |||||||||||||||||||
11 | QQuickItemParticle::~QQuickItemParticle() | - | ||||||||||||||||||
12 | { | - | ||||||||||||||||||
13 | delete clock; | - | ||||||||||||||||||
14 | } executed 8 times by 2 tests: end of block Executed by:
| 8 | ||||||||||||||||||
15 | - | |||||||||||||||||||
16 | void QQuickItemParticle::freeze(QQuickItem* item) | - | ||||||||||||||||||
17 | { | - | ||||||||||||||||||
18 | m_stasis << item; | - | ||||||||||||||||||
19 | } never executed: end of block | 0 | ||||||||||||||||||
20 | - | |||||||||||||||||||
21 | - | |||||||||||||||||||
22 | void QQuickItemParticle::unfreeze(QQuickItem* item) | - | ||||||||||||||||||
23 | { | - | ||||||||||||||||||
24 | m_stasis.remove(item); | - | ||||||||||||||||||
25 | } never executed: end of block | 0 | ||||||||||||||||||
26 | - | |||||||||||||||||||
27 | void QQuickItemParticle::take(QQuickItem *item, bool prioritize) | - | ||||||||||||||||||
28 | { | - | ||||||||||||||||||
29 | if (prioritize
| 0-904 | ||||||||||||||||||
30 | m_pendingItems.push_front(item); never executed: m_pendingItems.push_front(item); | 0 | ||||||||||||||||||
31 | else | - | ||||||||||||||||||
32 | m_pendingItems.push_back(item); executed 904 times by 1 test: m_pendingItems.push_back(item); Executed by:
| 904 | ||||||||||||||||||
33 | } | - | ||||||||||||||||||
34 | - | |||||||||||||||||||
35 | void QQuickItemParticle::give(QQuickItem *item) | - | ||||||||||||||||||
36 | { | - | ||||||||||||||||||
37 | - | |||||||||||||||||||
38 | (void)item;; | - | ||||||||||||||||||
39 | } never executed: end of block | 0 | ||||||||||||||||||
40 | - | |||||||||||||||||||
41 | void QQuickItemParticle::initialize(int gIdx, int pIdx) | - | ||||||||||||||||||
42 | { | - | ||||||||||||||||||
43 | m_loadables << m_system->groupData[gIdx]->data[pIdx]; | - | ||||||||||||||||||
44 | } executed 3392 times by 1 test: end of block Executed by:
| 3392 | ||||||||||||||||||
45 | - | |||||||||||||||||||
46 | void QQuickItemParticle::commit(int, int) | - | ||||||||||||||||||
47 | { | - | ||||||||||||||||||
48 | } | - | ||||||||||||||||||
49 | - | |||||||||||||||||||
50 | void QQuickItemParticle::processDeletables() | - | ||||||||||||||||||
51 | { | - | ||||||||||||||||||
52 | for (auto _container_ = QtPrivate::qMakeForeachContainer(m_deletables); _container_.control
| 0-1966 | ||||||||||||||||||
53 | if (m_fade
| 0-1716 | ||||||||||||||||||
54 | item->setOpacity(0.); executed 1716 times by 1 test: item->setOpacity(0.); Executed by:
| 1716 | ||||||||||||||||||
55 | item->setVisible(false); | - | ||||||||||||||||||
56 | QQuickItemParticleAttached* mpa; | - | ||||||||||||||||||
57 | if ((
| 0-1716 | ||||||||||||||||||
58 | mpa->detach(); executed 1716 times by 1 test: mpa->detach(); Executed by:
| 1716 | ||||||||||||||||||
59 | int idx = -1; | - | ||||||||||||||||||
60 | if ((
| 704-1012 | ||||||||||||||||||
61 | m_managed.takeAt(idx); | - | ||||||||||||||||||
62 | delete item; | - | ||||||||||||||||||
63 | } executed 1012 times by 1 test: end of block Executed by:
| 1012 | ||||||||||||||||||
64 | m_activeCount--; | - | ||||||||||||||||||
65 | } executed 1716 times by 1 test: end of block Executed by:
| 1716 | ||||||||||||||||||
66 | m_deletables.clear(); | - | ||||||||||||||||||
67 | } executed 250 times by 2 tests: end of block Executed by:
| 250 | ||||||||||||||||||
68 | - | |||||||||||||||||||
69 | void QQuickItemParticle::tick(int time) | - | ||||||||||||||||||
70 | { | - | ||||||||||||||||||
71 | (void)time;; | - | ||||||||||||||||||
72 | processDeletables(); | - | ||||||||||||||||||
73 | - | |||||||||||||||||||
74 | for (auto _container_ = QtPrivate::qMakeForeachContainer(m_loadables); _container_.control
| 0-3522 | ||||||||||||||||||
75 | ((d) ? static_cast<void>(0) : qt_assert("d", __FILE__, 192)); | - | ||||||||||||||||||
76 | if (m_stasis.contains(d->delegate)
| 0-3296 | ||||||||||||||||||
77 | QMessageLogger(__FILE__, 194, __PRETTY_FUNCTION__).warning() << "Current model particles prefers overwrite:false"; never executed: QMessageLogger(__FILE__, 194, __PRETTY_FUNCTION__).warning() << "Current model particles prefers overwrite:false"; | 0 | ||||||||||||||||||
78 | - | |||||||||||||||||||
79 | if (d->delegate
| 1484-1812 | ||||||||||||||||||
80 | m_deletables << d->delegate; | - | ||||||||||||||||||
81 | d->delegate = nullptr; | - | ||||||||||||||||||
82 | } executed 1812 times by 1 test: end of block Executed by:
| 1812 | ||||||||||||||||||
83 | if (!m_pendingItems.isEmpty()
| 904-2392 | ||||||||||||||||||
84 | d->delegate = m_pendingItems.front(); | - | ||||||||||||||||||
85 | m_pendingItems.pop_front(); | - | ||||||||||||||||||
86 | } executed 904 times by 1 test: else if (m_delegateend of block Executed by:
| 120-2272 | ||||||||||||||||||
87 | d->delegate = qobject_cast<QQuickItem*>(m_delegate->create(qmlContext(this))); | - | ||||||||||||||||||
88 | if (d->delegate
| 0-2272 | ||||||||||||||||||
89 | m_managed << d->delegate; executed 2272 times by 1 test: m_managed << d->delegate; Executed by:
| 2272 | ||||||||||||||||||
90 | } executed 2272 times by 1 test: end of block Executed by:
| 2272 | ||||||||||||||||||
91 | if (d
| 0-3296 | ||||||||||||||||||
92 | d->delegate->setX(d->curX(m_system) - d->delegate->width() / 2); | - | ||||||||||||||||||
93 | d->delegate->setY(d->curY(m_system) - d->delegate->height() / 2); | - | ||||||||||||||||||
94 | QQuickItemParticleAttached* mpa = qobject_cast<QQuickItemParticleAttached*>(qmlAttachedPropertiesObject<QQuickItemParticle>(d->delegate)); | - | ||||||||||||||||||
95 | if (mpa
| 0-3176 | ||||||||||||||||||
96 | mpa->m_mp = this; | - | ||||||||||||||||||
97 | mpa->attach(); | - | ||||||||||||||||||
98 | } executed 3176 times by 1 test: end of block Executed by:
| 3176 | ||||||||||||||||||
99 | d->delegate->setParentItem(this); | - | ||||||||||||||||||
100 | if (m_fade
| 0-3176 | ||||||||||||||||||
101 | d->delegate->setOpacity(0.); executed 3176 times by 1 test: d->delegate->setOpacity(0.); Executed by:
| 3176 | ||||||||||||||||||
102 | d->delegate->setVisible(false); | - | ||||||||||||||||||
103 | m_activeCount++; | - | ||||||||||||||||||
104 | } executed 3176 times by 1 test: end of block Executed by:
| 3176 | ||||||||||||||||||
105 | } executed 3296 times by 1 test: end of block Executed by:
| 3296 | ||||||||||||||||||
106 | m_loadables.clear(); | - | ||||||||||||||||||
107 | } executed 226 times by 2 tests: end of block Executed by:
| 226 | ||||||||||||||||||
108 | - | |||||||||||||||||||
109 | void QQuickItemParticle::reset() | - | ||||||||||||||||||
110 | { | - | ||||||||||||||||||
111 | QQuickParticlePainter::reset(); | - | ||||||||||||||||||
112 | m_loadables.clear(); | - | ||||||||||||||||||
113 | - | |||||||||||||||||||
114 | - | |||||||||||||||||||
115 | - | |||||||||||||||||||
116 | QSet<QQuickItem*> lost = QSet<QQuickItem*>::fromList(m_managed); | - | ||||||||||||||||||
117 | for (auto groupId : groupIds()) { | - | ||||||||||||||||||
118 | for (QQuickParticleData* d : qAsConst(m_system->groupData[groupId]->data)) { | - | ||||||||||||||||||
119 | lost.remove(d->delegate); | - | ||||||||||||||||||
120 | } executed 2824 times by 2 tests: end of block Executed by:
| 2824 | ||||||||||||||||||
121 | } executed 16 times by 2 tests: end of block Executed by:
| 16 | ||||||||||||||||||
122 | m_deletables.append(lost.toList()); | - | ||||||||||||||||||
123 | - | |||||||||||||||||||
124 | processDeletables(); | - | ||||||||||||||||||
125 | } executed 24 times by 2 tests: end of block Executed by:
| 24 | ||||||||||||||||||
126 | - | |||||||||||||||||||
127 | - | |||||||||||||||||||
128 | QSGNode* QQuickItemParticle::updatePaintNode(QSGNode* n, UpdatePaintNodeData* d) | - | ||||||||||||||||||
129 | { | - | ||||||||||||||||||
130 | - | |||||||||||||||||||
131 | if (m_pleaseReset
| 8-346 | ||||||||||||||||||
132 | m_pleaseReset = false; | - | ||||||||||||||||||
133 | - | |||||||||||||||||||
134 | - | |||||||||||||||||||
135 | for (auto groupId : groupIds()) { | - | ||||||||||||||||||
136 | for (QQuickParticleData* d : qAsConst(m_system->groupData[groupId]->data)) { | - | ||||||||||||||||||
137 | if (!d->delegate
| 0-1412 | ||||||||||||||||||
138 | m_loadables << d; | - | ||||||||||||||||||
139 | } never executed: end of block | 0 | ||||||||||||||||||
140 | } executed 1412 times by 2 tests: end of block Executed by:
| 1412 | ||||||||||||||||||
141 | } executed 8 times by 2 tests: end of block Executed by:
| 8 | ||||||||||||||||||
142 | } executed 8 times by 2 tests: end of block Executed by:
| 8 | ||||||||||||||||||
143 | prepareNextFrame(); | - | ||||||||||||||||||
144 | - | |||||||||||||||||||
145 | update(); | - | ||||||||||||||||||
146 | if (n
| 0-354 | ||||||||||||||||||
147 | n->markDirty(QSGNode::DirtyMaterial); never executed: n->markDirty(QSGNode::DirtyMaterial); | 0 | ||||||||||||||||||
148 | return executed 354 times by 2 tests: QQuickItem::updatePaintNode(n,d);return QQuickItem::updatePaintNode(n,d); Executed by:
executed 354 times by 2 tests: return QQuickItem::updatePaintNode(n,d); Executed by:
| 354 | ||||||||||||||||||
149 | } | - | ||||||||||||||||||
150 | - | |||||||||||||||||||
151 | void QQuickItemParticle::prepareNextFrame() | - | ||||||||||||||||||
152 | { | - | ||||||||||||||||||
153 | if (!m_system
| 0-354 | ||||||||||||||||||
154 | return; never executed: return; | 0 | ||||||||||||||||||
155 | qint64 timeStamp = m_system->systemSync(this); | - | ||||||||||||||||||
156 | qreal curT = timeStamp/1000.0; | - | ||||||||||||||||||
157 | qreal dt = curT - m_lastT; | - | ||||||||||||||||||
158 | m_lastT = curT; | - | ||||||||||||||||||
159 | if (!m_activeCount
| 33-321 | ||||||||||||||||||
160 | return; executed 33 times by 2 tests: return; Executed by:
| 33 | ||||||||||||||||||
161 | - | |||||||||||||||||||
162 | - | |||||||||||||||||||
163 | for (auto groupId : groupIds()) { | - | ||||||||||||||||||
164 | for (QQuickParticleData* data : qAsConst(m_system->groupData[groupId]->data)) { | - | ||||||||||||||||||
165 | QQuickItem* item = data->delegate; | - | ||||||||||||||||||
166 | if (!item
| 29113-52987 | ||||||||||||||||||
167 | continue; executed 29113 times by 1 test: continue; Executed by:
| 29113 | ||||||||||||||||||
168 | float t = ((timeStamp / 1000.0f) - data->t) / data->lifeSpan; | - | ||||||||||||||||||
169 | if (m_stasis.contains(item)
| 0-52987 | ||||||||||||||||||
170 | data->t += dt; | - | ||||||||||||||||||
171 | continue; never executed: continue; | 0 | ||||||||||||||||||
172 | } | - | ||||||||||||||||||
173 | if (t >= 1.0f
| 0-52987 | ||||||||||||||||||
174 | m_deletables << item; | - | ||||||||||||||||||
175 | data->delegate = nullptr; | - | ||||||||||||||||||
176 | } never executed: else{end of block | 0 | ||||||||||||||||||
177 | data->delegate->setVisible(true); | - | ||||||||||||||||||
178 | if (m_fade
| 0-52987 | ||||||||||||||||||
179 | float o = 1.f; | - | ||||||||||||||||||
180 | if (t <0.2f
| 13262-39725 | ||||||||||||||||||
181 | o = t * 5; executed 13262 times by 1 test: o = t * 5; Executed by:
| 13262 | ||||||||||||||||||
182 | if (t > 0.8f
| 5907-47080 | ||||||||||||||||||
183 | o = (1-t)*5; executed 5907 times by 1 test: o = (1-t)*5; Executed by:
| 5907 | ||||||||||||||||||
184 | item->setOpacity(o); | - | ||||||||||||||||||
185 | } executed 52987 times by 1 test: end of block Executed by:
| 52987 | ||||||||||||||||||
186 | } executed 52987 times by 1 test: end of block Executed by:
| 52987 | ||||||||||||||||||
187 | item->setX(data->curX(m_system) - item->width() / 2 - m_systemOffset.x()); | - | ||||||||||||||||||
188 | item->setY(data->curY(m_system) - item->height() / 2 - m_systemOffset.y()); | - | ||||||||||||||||||
189 | } executed 52987 times by 1 test: end of block Executed by:
| 52987 | ||||||||||||||||||
190 | } executed 321 times by 1 test: end of block Executed by:
| 321 | ||||||||||||||||||
191 | } executed 321 times by 1 test: end of block Executed by:
| 321 | ||||||||||||||||||
192 | - | |||||||||||||||||||
193 | QQuickItemParticleAttached *QQuickItemParticle::qmlAttachedProperties(QObject *object) | - | ||||||||||||||||||
194 | { | - | ||||||||||||||||||
195 | return executed 2472 times by 1 test: new QQuickItemParticleAttached(object);return new QQuickItemParticleAttached(object); Executed by:
executed 2472 times by 1 test: return new QQuickItemParticleAttached(object); Executed by:
| 2472 | ||||||||||||||||||
196 | } | - | ||||||||||||||||||
197 | - | |||||||||||||||||||
198 | - | |||||||||||||||||||
199 | - | |||||||||||||||||||
Switch to Source code | Preprocessed file |