void QQmlAnimationTimer::updateAnimationsTime(qint64 delta) { //setCurrentTime can get this called again while we're the for loop. At least with pauseAnimations if (insideTick) return; lastTick += delta; //we make sure we only call update time if the time has actually changed //it might happen in some cases that the time doesn't change because events are delayed //when the CPU load is high if (delta) { insideTick = true; for (currentAnimationIdx = 0; currentAnimationIdx < animations.count(); ++currentAnimationIdx) { QAbstractAnimationJob *animation = animations.at(currentAnimationIdx); int elapsed = animation->m_totalCurrentTime + (animation->direction() == QAbstractAnimationJob::Forward ? delta : -delta); animation->setCurrentTime(elapsed); } if (animationTickDump()) { qDebug() << "***** Dumping Animation Tree ***** ( tick:" << lastTick << "delta:" << delta << ")"; for (int i = 0; i < animations.count(); ++i) qDebug() << animations.at(i); } insideTick = false; currentAnimationIdx = 0; } }
int QQmlAnimationTimer::closestPauseAnimationTimeToFinish() { int closestTimeToFinish = INT_MAX; for (int i = 0; i < runningPauseAnimations.size(); ++i) { QAbstractAnimationJob *animation = runningPauseAnimations.at(i); int timeToFinish; if (animation->direction() == QAbstractAnimationJob::Forward) timeToFinish = animation->duration() - animation->currentLoopTime(); else timeToFinish = animation->currentLoopTime(); if (timeToFinish < closestTimeToFinish) closestTimeToFinish = timeToFinish; } return closestTimeToFinish; }