OpenCoverage

qquicktrailemitter.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/particles/qquicktrailemitter.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2QQuickTrailEmitter::QQuickTrailEmitter(QQuickItem *parent) :-
3 QQuickParticleEmitter(parent)-
4 , m_particlesPerParticlePerSecond(0)-
5 , m_lastTimeStamp(0)-
6 , m_emitterXVariation(0)-
7 , m_emitterYVariation(0)-
8 , m_followCount(0)-
9 , m_emissionExtruder(nullptr)-
10 , m_defaultEmissionExtruder(new QQuickParticleExtruder(this))-
11{-
12-
13 connect(this, qFlagLocation("2""followChanged(QString)" "\0" __FILE__ ":" "69"),-
14 this, qFlagLocation("1""recalcParticlesPerSecond()" "\0" __FILE__ ":" "70"));-
15 connect(this, qFlagLocation("2""particleDurationChanged(int)" "\0" __FILE__ ":" "71"),-
16 this, qFlagLocation("1""recalcParticlesPerSecond()" "\0" __FILE__ ":" "72"));-
17 connect(this, qFlagLocation("2""particlesPerParticlePerSecondChanged(int)" "\0" __FILE__ ":" "73"),-
18 this, qFlagLocation("1""recalcParticlesPerSecond()" "\0" __FILE__ ":" "74"));-
19}
executed 18 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquicktrailemitter
18
20bool QQuickTrailEmitter::isEmitFollowConnected()-
21{-
22 do { QObject *sender = (this); void (QQuickTrailEmitter::*signal)(QQmlV4Handle,QQmlV4Handle) = &QQuickTrailEmitter::emitFollowParticles; static QMetaMethod method = QMetaMethod::fromSignal(signal); static int signalIdx = QMetaObjectPrivate::signalIndex(method); return
executed 21850 times by 1 test: return QObjectPrivate::get(sender)->isSignalConnected(signalIdx);
Executed by:
  • tst_qquicktrailemitter
QObjectPrivate::get(sender)->isSignalConnected(signalIdx);
executed 21850 times by 1 test: return QObjectPrivate::get(sender)->isSignalConnected(signalIdx);
Executed by:
  • tst_qquicktrailemitter
} while (0);
21850
23}
never executed: end of block
0
24-
25void QQuickTrailEmitter::recalcParticlesPerSecond(){-
26 if (!m_system
!m_systemDescription
TRUEevaluated 50 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktrailemitter
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
)
2-50
27 return;
executed 50 times by 2 tests: return;
Executed by:
  • tst_examples
  • tst_qquicktrailemitter
50
28 m_followCount = m_system->groupData[m_system->groupIds[m_follow]]->size();-
29 if (!m_followCount
!m_followCountDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
){
0-2
30 setParticlesPerSecond(1);-
31 }
never executed: end of block
else{
0
32 setParticlesPerSecond(m_particlesPerParticlePerSecond * m_followCount);-
33 m_lastEmission.resize(m_followCount);-
34 m_lastEmission.fill(m_lastTimeStamp);-
35 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquicktrailemitter
2
36}-
37-
38void QQuickTrailEmitter::reset()-
39{-
40 m_followCount = 0;-
41}
executed 36 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquicktrailemitter
36
42-
43void QQuickTrailEmitter::emitWindow(int timeStamp)-
44{-
45 if (m_system == nullptr
m_system == nullptrDescription
TRUEnever evaluated
FALSEevaluated 76 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
)
0-76
46 return;
never executed: return;
0
47 if (!m_enabled
!m_enabledDescription
TRUEnever evaluated
FALSEevaluated 76 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
&& !m_pulseLeft
!m_pulseLeftDescription
TRUEnever evaluated
FALSEnever evaluated
&& m_burstQueue.isEmpty()
m_burstQueue.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0-76
48 return;
never executed: return;
0
49 if (m_followCount != m_system->groupData[m_system->groupIds[m_follow]]->size()
m_followCount ...llow]]->size()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
FALSEevaluated 74 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
){
2-74
50 qreal oldPPS = m_particlesPerSecond;-
51 recalcParticlesPerSecond();-
52 if (m_particlesPerSecond != oldPPS
m_particlesPerSecond != oldPPSDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
FALSEnever evaluated
)
0-2
53 return;
executed 2 times by 1 test: return;
Executed by:
  • tst_qquicktrailemitter
2
54 }
never executed: end of block
0
55-
56 if (m_pulseLeft
m_pulseLeftDescription
TRUEnever evaluated
FALSEevaluated 74 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
){
0-74
57 m_pulseLeft -= timeStamp - m_lastTimeStamp * 1000.;-
58 if (m_pulseLeft < 0
m_pulseLeft < 0Description
TRUEnever evaluated
FALSEnever evaluated
){
0
59 timeStamp += m_pulseLeft;-
60 m_pulseLeft = 0;-
61 }
never executed: end of block
0
62 }
never executed: end of block
0
63-
64-
65 qreal time = timeStamp / 1000.;-
66 qreal particleRatio = 1. / m_particlesPerParticlePerSecond;-
67 qreal pt;-
68 qreal maxLife = (m_particleDuration + m_particleDurationVariation)/1000.0;-
69-
70-
71 QPointF offset = m_system->mapFromItem(this, QPointF(0, 0));-
72 qreal sizeAtEnd = m_particleEndSize >= 0
m_particleEndSize >= 0Description
TRUEnever evaluated
FALSEevaluated 74 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
? m_particleEndSize : m_particleSize;
0-74
73-
74 int gId = m_system->groupIds[m_follow];-
75 int gId2 = groupId();-
76 for (int i=0; i<m_system->groupData[gId]->data.count()
i<m_system->gr...->data.count()Description
TRUEevaluated 37000 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
FALSEevaluated 74 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
; i++) {
74-37000
77 QQuickParticleData *d = m_system->groupData[gId]->data[i];-
78 if (!d->stillAlive(m_system)
!d->stillAlive(m_system)Description
TRUEevaluated 15150 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
FALSEevaluated 21850 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
){
15150-21850
79 m_lastEmission[i] = time;-
80 continue;
executed 15150 times by 1 test: continue;
Executed by:
  • tst_qquicktrailemitter
15150
81 }-
82 pt = m_lastEmission[i];-
83 if (pt < d->t
pt < d->tDescription
TRUEevaluated 978 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
FALSEevaluated 20872 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
)
978-20872
84 pt = d->t;
executed 978 times by 1 test: pt = d->t;
Executed by:
  • tst_qquicktrailemitter
978
85 if (pt + maxLife < time
pt + maxLife < timeDescription
TRUEnever evaluated
FALSEevaluated 21850 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
)
0-21850
86 pt = time - maxLife;
never executed: pt = time - maxLife;
0
87-
88 if ((width() || height()) && !effectiveExtruder()->contains(QRectF(offset.x(), offset.y(), width(), height()),
!effectiveExtr...rY(m_system)))Description
TRUEnever evaluated
FALSEnever evaluated
0
89 QPointF(d->curX(m_system), d->curY(m_system)))
!effectiveExtr...rY(m_system)))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
90 m_lastEmission[d->index] = time;-
91 continue;
never executed: continue;
0
92 }-
93-
94 QList<QQuickParticleData*> toEmit;-
95-
96 while (pt < time
pt < timeDescription
TRUEevaluated 1182 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
FALSEevaluated 21850 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
|| !m_burstQueue.isEmpty()
!m_burstQueue.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 21850 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
){
0-21850
97 QQuickParticleData* datum = m_system->newDatum(gId2, !m_overwrite);-
98 if (datum
datumDescription
TRUEevaluated 1182 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
FALSEnever evaluated
){
0-1182
99-
100 datum->t = pt;-
101 datum->lifeSpan =-
102 (m_particleDuration-
103 + (QRandomGenerator::global()->bounded((m_particleDurationVariation*2) + 1) - m_particleDurationVariation))-
104 / 1000.0;-
105-
106-
107-
108 qreal followT = pt - d->t;-
109 qreal followT2 = followT * followT * 0.5;-
110 qreal eW = m_emitterXVariation < 0
m_emitterXVariation < 0Description
TRUEnever evaluated
FALSEevaluated 1182 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
? d->curSize(m_system) : m_emitterXVariation;
0-1182
111 qreal eH = m_emitterYVariation < 0
m_emitterYVariation < 0Description
TRUEnever evaluated
FALSEevaluated 1182 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
? d->curSize(m_system) : m_emitterYVariation;
0-1182
112-
113 QRectF boundsRect(d->x - offset.x() + d->vx * followT + d->ax * followT2 - eW/2,-
114 d->y - offset.y() + d->vy * followT + d->ay * followT2 - eH/2,-
115 eW, eH);-
116-
117 QQuickParticleExtruder* effectiveEmissionExtruder = m_emissionExtruder
m_emissionExtruderDescription
TRUEnever evaluated
FALSEevaluated 1182 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
? m_emissionExtruder : m_defaultEmissionExtruder;
0-1182
118 const QPointF &newPos = effectiveEmissionExtruder->extrude(boundsRect);-
119 datum->x = newPos.x();-
120 datum->y = newPos.y();-
121-
122-
123 const QPointF &velocity = m_velocity->sample(newPos);-
124 datum->vx = velocity.x()-
125 + m_velocity_from_movement * d->vx;-
126 datum->vy = velocity.y()-
127 + m_velocity_from_movement * d->vy;-
128-
129-
130 const QPointF &accel = m_acceleration->sample(newPos);-
131 datum->ax = accel.x();-
132 datum->ay = accel.y();-
133-
134-
135 float sizeVariation = -m_particleSizeVariation-
136 + QRandomGenerator::global()->generateDouble() * m_particleSizeVariation * 2;-
137-
138 float size = qMax((qreal)0.0, m_particleSize + sizeVariation);-
139 float endSize = qMax((qreal)0.0, sizeAtEnd + sizeVariation);-
140-
141 datum->size = size * float(m_enabled);-
142 datum->endSize = endSize * float(m_enabled);-
143-
144 toEmit << datum;-
145-
146 m_system->emitParticle(datum, this);-
147 }
executed 1182 times by 1 test: end of block
Executed by:
  • tst_qquicktrailemitter
1182
148 if (!m_burstQueue.isEmpty()
!m_burstQueue.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 1182 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
){
0-1182
149 m_burstQueue.first().first--;-
150 if (m_burstQueue.first().first <= 0
m_burstQueue.f...t().first <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
151 m_burstQueue.pop_front();
never executed: m_burstQueue.pop_front();
0
152 }
never executed: end of block
else{
0
153 pt += particleRatio;-
154 }
executed 1182 times by 1 test: end of block
Executed by:
  • tst_qquicktrailemitter
1182
155 }-
156-
157 for (auto _container_ = QtPrivate::qMakeForeachContainer(toEmit); _container_.control
_container_.controlDescription
TRUEevaluated 23032 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
FALSEnever evaluated
&& _container_.i != _container_.e
_container_.i != _container_.eDescription
TRUEevaluated 1182 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
FALSEevaluated 21850 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
; ++_container_.i, _container_.control ^= 1) for (QQuickParticleData* d = *_container_.i; _container_.control
_container_.controlDescription
TRUEevaluated 1182 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
FALSEevaluated 1182 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
; _container_.control = 0)
0-23032
158 m_system->emitParticle(d, this);
executed 1182 times by 1 test: m_system->emitParticle(d, this);
Executed by:
  • tst_qquicktrailemitter
1182
159-
160 if (isEmitConnected()
isEmitConnected()Description
TRUEnever evaluated
FALSEevaluated 21850 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
|| isEmitFollowConnected()
isEmitFollowConnected()Description
TRUEnever evaluated
FALSEevaluated 21850 times by 1 test
Evaluated by:
  • tst_qquicktrailemitter
) {
0-21850
161 QQmlEngine *qmlEngine = ::qmlEngine(this);-
162 QV4::ExecutionEngine *v4 = qmlEngine->handle();-
163-
164 QV4::Scope scope(v4);-
165 QV4::ScopedArrayObject array(scope, v4->newArrayObject(toEmit.size()));-
166 QV4::ScopedValue v(scope);-
167 for (int i=0; i<toEmit.size()
i<toEmit.size()Description
TRUEnever evaluated
FALSEnever evaluated
; i++)
0
168 array->put(i, (v = toEmit[i]->v4Value(m_system)));
never executed: array->put(i, (v = toEmit[i]->v4Value(m_system)));
0
169-
170 if (isEmitFollowConnected()
isEmitFollowConnected()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
171 emitFollowParticles(QQmlV4Handle(array), d->v4Value(m_system));
never executed: emitFollowParticles(QQmlV4Handle(array), d->v4Value(m_system));
0
172 else if (isEmitConnected()
isEmitConnected()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
173 emitParticles(QQmlV4Handle(array));
never executed: emitParticles(QQmlV4Handle(array));
0
174 }
never executed: end of block
0
175 m_lastEmission[d->index] = pt;-
176 }
executed 21850 times by 1 test: end of block
Executed by:
  • tst_qquicktrailemitter
21850
177-
178 m_lastTimeStamp = time;-
179}
executed 74 times by 1 test: end of block
Executed by:
  • tst_qquicktrailemitter
74
180-
181-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.0