@@ -226,8 +226,7 @@ void SkParticleEffect::processEffectSpawnRequests(double now) {
226226 fSpawnRequests .reset ();
227227}
228228
229- int SkParticleEffect::runEffectScript (double now, const char * entry) {
230- fState .fBurst = 0 ;
229+ void SkParticleEffect::runEffectScript (double now, const char * entry) {
231230 if (const auto & byteCode = fParams ->fEffectProgram .fByteCode ) {
232231 if (auto fun = byteCode->getFunction (entry)) {
233232 for (const auto & value : fParams ->fEffectProgram .fExternalValues ) {
@@ -241,7 +240,6 @@ int SkParticleEffect::runEffectScript(double now, const char* entry) {
241240 this ->processEffectSpawnRequests (now);
242241 }
243242 }
244- return fState .fBurst ;
245243}
246244
247245void SkParticleEffect::processParticleSpawnRequests (double now, int start) {
@@ -304,24 +302,22 @@ void SkParticleEffect::advanceTime(double now) {
304302 this ->setCapacity (fParams ->fMaxCount );
305303 }
306304
307- int burstCount = 0 ;
308-
309305 // Is this the first update after calling start()?
310306 // Run 'effectSpawn' to set initial emitter properties.
311307 if (fState .fAge == 0 .0f && fState .fLoopCount == 0 ) {
312- burstCount += this ->runEffectScript (now, " effectSpawn" );
308+ this ->runEffectScript (now, " effectSpawn" );
313309 }
314310
315311 fState .fAge += fState .fDeltaTime / fState .fLifetime ;
316312 if (fState .fAge > 1 ) {
317313 // We always run effectDeath when age crosses 1, whether we're looping or actually dying
318- burstCount += this ->runEffectScript (now, " effectDeath" );
314+ this ->runEffectScript (now, " effectDeath" );
319315
320316 if (fLooping ) {
321317 // If we looped, then run effectSpawn again (with the updated loop count)
322318 fState .fLoopCount += sk_float_floor2int (fState .fAge );
323319 fState .fAge = fmodf (fState .fAge , 1 .0f );
324- burstCount += this ->runEffectScript (now, " effectSpawn" );
320+ this ->runEffectScript (now, " effectSpawn" );
325321 } else {
326322 // Effect is dead if we've reached the end (and are not looping)
327323 return ;
@@ -349,7 +345,7 @@ void SkParticleEffect::advanceTime(double now) {
349345 this ->runParticleScript (now, " death" , fCount , numDyingParticles);
350346
351347 // Run 'effectUpdate' to adjust emitter properties
352- burstCount += this ->runEffectScript (now, " effectUpdate" );
348+ this ->runEffectScript (now, " effectUpdate" );
353349
354350 // Do integration of effect position and orientation
355351 {
@@ -362,10 +358,11 @@ void SkParticleEffect::advanceTime(double now) {
362358 }
363359
364360 // Spawn new particles
365- float desired = fState .fRate * fState .fDeltaTime + fSpawnRemainder ;
361+ float desired = fState .fRate * fState .fDeltaTime + fSpawnRemainder + fState .fBurst ;
362+ fState .fBurst = 0 ;
366363 int numToSpawn = sk_float_round2int (desired);
367364 fSpawnRemainder = desired - numToSpawn;
368- numToSpawn = SkTPin (numToSpawn + burstCount , 0 , fParams ->fMaxCount - fCount );
365+ numToSpawn = SkTPin (numToSpawn, 0 , fParams ->fMaxCount - fCount );
369366 if (numToSpawn) {
370367 const int spawnBase = fCount ;
371368
0 commit comments