src/corelib/animation/qabstractanimation.cpp
changeset 33 3e2da88830cd
parent 30 5dc02b23752f
equal deleted inserted replaced
30:5dc02b23752f 33:3e2da88830cd
   166 #endif
   166 #endif
   167 
   167 
   168 QUnifiedTimer::QUnifiedTimer() :
   168 QUnifiedTimer::QUnifiedTimer() :
   169     QObject(), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL),
   169     QObject(), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL),
   170     currentAnimationIdx(0), consistentTiming(false), slowMode(false),
   170     currentAnimationIdx(0), consistentTiming(false), slowMode(false),
   171     isPauseTimerActive(false), runningLeafAnimations(0)
   171     slowdownFactor(5.0f), isPauseTimerActive(false), runningLeafAnimations(0)
   172 {
   172 {
   173     time.invalidate();
   173     time.invalidate();
   174 }
   174 }
   175 
   175 
   176 
   176 
   203         inst->updateAnimationsTime();
   203         inst->updateAnimationsTime();
   204 }
   204 }
   205 
   205 
   206 void QUnifiedTimer::updateAnimationsTime()
   206 void QUnifiedTimer::updateAnimationsTime()
   207 {
   207 {
       
   208     qint64 totalElapsed = time.elapsed();
   208     // ignore consistentTiming in case the pause timer is active
   209     // ignore consistentTiming in case the pause timer is active
   209     int delta = (consistentTiming && !isPauseTimerActive) ?
   210     int delta = (consistentTiming && !isPauseTimerActive) ?
   210                         timingInterval : time.elapsed() - lastTick;
   211                         timingInterval : totalElapsed - lastTick;
   211     if (slowMode)
   212     if (slowMode) {
   212         delta /= 5;
   213         if (slowdownFactor > 0)
   213     lastTick = time.elapsed();
   214             delta = qRound(delta / slowdownFactor);
       
   215         else
       
   216             delta = 0;
       
   217     }
       
   218 
       
   219     lastTick = totalElapsed;
   214 
   220 
   215     //we make sure we only call update time if the time has actually changed
   221     //we make sure we only call update time if the time has actually changed
   216     //it might happen in some cases that the time doesn't change because events are delayed
   222     //it might happen in some cases that the time doesn't change because events are delayed
   217     //when the CPU load is high
   223     //when the CPU load is high
   218     if (delta) {
   224     if (delta) {