| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/particles/qquicktrailemitter.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | QQuickTrailEmitter::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 blockExecuted by:
| 18 | ||||||||||||||||||
| 20 | bool 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: QObjectPrivate::get(sender)->isSignalConnected(signalIdx);return QObjectPrivate::get(sender)->isSignalConnected(signalIdx);Executed by:
executed 21850 times by 1 test: } while (0);return QObjectPrivate::get(sender)->isSignalConnected(signalIdx);Executed by:
| 21850 | ||||||||||||||||||
| 23 | } never executed: end of block | 0 | ||||||||||||||||||
| 24 | - | |||||||||||||||||||
| 25 | void QQuickTrailEmitter::recalcParticlesPerSecond(){ | - | ||||||||||||||||||
| 26 | if (!m_system
| 2-50 | ||||||||||||||||||
| 27 | return; executed 50 times by 2 tests: return;Executed by:
| 50 | ||||||||||||||||||
| 28 | m_followCount = m_system->groupData[m_system->groupIds[m_follow]]->size(); | - | ||||||||||||||||||
| 29 | if (!m_followCount
| 0-2 | ||||||||||||||||||
| 30 | setParticlesPerSecond(1); | - | ||||||||||||||||||
| 31 | } never executed: else{end of block | 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 blockExecuted by:
| 2 | ||||||||||||||||||
| 36 | } | - | ||||||||||||||||||
| 37 | - | |||||||||||||||||||
| 38 | void QQuickTrailEmitter::reset() | - | ||||||||||||||||||
| 39 | { | - | ||||||||||||||||||
| 40 | m_followCount = 0; | - | ||||||||||||||||||
| 41 | } executed 36 times by 2 tests: end of blockExecuted by:
| 36 | ||||||||||||||||||
| 42 | - | |||||||||||||||||||
| 43 | void QQuickTrailEmitter::emitWindow(int timeStamp) | - | ||||||||||||||||||
| 44 | { | - | ||||||||||||||||||
| 45 | if (m_system == nullptr
| 0-76 | ||||||||||||||||||
| 46 | return; never executed: return; | 0 | ||||||||||||||||||
| 47 | if (!m_enabled
| 0-76 | ||||||||||||||||||
| 48 | return; never executed: return; | 0 | ||||||||||||||||||
| 49 | if (m_followCount != m_system->groupData[m_system->groupIds[m_follow]]->size()
| 2-74 | ||||||||||||||||||
| 50 | qreal oldPPS = m_particlesPerSecond; | - | ||||||||||||||||||
| 51 | recalcParticlesPerSecond(); | - | ||||||||||||||||||
| 52 | if (m_particlesPerSecond != oldPPS
| 0-2 | ||||||||||||||||||
| 53 | return; executed 2 times by 1 test: return;Executed by:
| 2 | ||||||||||||||||||
| 54 | } never executed: end of block | 0 | ||||||||||||||||||
| 55 | - | |||||||||||||||||||
| 56 | if (m_pulseLeft
| 0-74 | ||||||||||||||||||
| 57 | m_pulseLeft -= timeStamp - m_lastTimeStamp * 1000.; | - | ||||||||||||||||||
| 58 | if (m_pulseLeft < 0
| 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
| 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()
| 74-37000 | ||||||||||||||||||
| 77 | QQuickParticleData *d = m_system->groupData[gId]->data[i]; | - | ||||||||||||||||||
| 78 | if (!d->stillAlive(m_system)
| 15150-21850 | ||||||||||||||||||
| 79 | m_lastEmission[i] = time; | - | ||||||||||||||||||
| 80 | continue; executed 15150 times by 1 test: continue;Executed by:
| 15150 | ||||||||||||||||||
| 81 | } | - | ||||||||||||||||||
| 82 | pt = m_lastEmission[i]; | - | ||||||||||||||||||
| 83 | if (pt < d->t
| 978-20872 | ||||||||||||||||||
| 84 | pt = d->t; executed 978 times by 1 test: pt = d->t;Executed by:
| 978 | ||||||||||||||||||
| 85 | if (pt + maxLife < time
| 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()),
| 0 | ||||||||||||||||||
| 89 | QPointF(d->curX(m_system), d->curY(m_system)))
| 0 | ||||||||||||||||||
| 90 | m_lastEmission[d->index] = time; | - | ||||||||||||||||||
| 91 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 92 | } | - | ||||||||||||||||||
| 93 | - | |||||||||||||||||||
| 94 | QList<QQuickParticleData*> toEmit; | - | ||||||||||||||||||
| 95 | - | |||||||||||||||||||
| 96 | while (pt < time
| 0-21850 | ||||||||||||||||||
| 97 | QQuickParticleData* datum = m_system->newDatum(gId2, !m_overwrite); | - | ||||||||||||||||||
| 98 | if (datum
| 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
| 0-1182 | ||||||||||||||||||
| 111 | qreal eH = m_emitterYVariation < 0
| 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
| 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 blockExecuted by:
| 1182 | ||||||||||||||||||
| 148 | if (!m_burstQueue.isEmpty()
| 0-1182 | ||||||||||||||||||
| 149 | m_burstQueue.first().first--; | - | ||||||||||||||||||
| 150 | if (m_burstQueue.first().first <= 0
| 0 | ||||||||||||||||||
| 151 | m_burstQueue.pop_front(); never executed: m_burstQueue.pop_front(); | 0 | ||||||||||||||||||
| 152 | } never executed: else{end of block | 0 | ||||||||||||||||||
| 153 | pt += particleRatio; | - | ||||||||||||||||||
| 154 | } executed 1182 times by 1 test: end of blockExecuted by:
| 1182 | ||||||||||||||||||
| 155 | } | - | ||||||||||||||||||
| 156 | - | |||||||||||||||||||
| 157 | for (auto _container_ = QtPrivate::qMakeForeachContainer(toEmit); _container_.control
| 0-23032 | ||||||||||||||||||
| 158 | m_system->emitParticle(d, this); executed 1182 times by 1 test: m_system->emitParticle(d, this);Executed by:
| 1182 | ||||||||||||||||||
| 159 | - | |||||||||||||||||||
| 160 | if (isEmitConnected()
| 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()
| 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()
| 0 | ||||||||||||||||||
| 171 | emitFollowParticles(QQmlV4Handle(array), d->v4Value(m_system)); never executed: emitFollowParticles(QQmlV4Handle(array), d->v4Value(m_system)); | 0 | ||||||||||||||||||
| 172 | else if (isEmitConnected()
| 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 blockExecuted by:
| 21850 | ||||||||||||||||||
| 177 | - | |||||||||||||||||||
| 178 | m_lastTimeStamp = time; | - | ||||||||||||||||||
| 179 | } executed 74 times by 1 test: end of blockExecuted by:
| 74 | ||||||||||||||||||
| 180 | - | |||||||||||||||||||
| 181 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |