Use explicit Qt::TimerTypes when starting animation timers.

Similar to commit 4e1ad49998, we know that
CoarseTimers are worst in their first firing, so we prefer a
PreciseTimer for short pause animations to avoid inaccuracies. If the
timeout is too big, we use a CoarseTimer anyway (current threshold is
2000ms).

The timer that drives the QDefaultAnimationDriver is always a
PreciseTimer.

Change-Id: I0939357d768b804f9f9bab3adf5ed1d0f7e012e7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
This commit is contained in:
Bradley T. Hughes 2012-01-02 12:47:15 +01:00 committed by Qt by Nokia
parent 9498f1aa54
commit eb0ce0d5c1

View File

@ -158,6 +158,7 @@
#define DEFAULT_TIMER_INTERVAL 16
#define STARTSTOP_TIMER_DELAY 0
#define PAUSE_TIMER_COARSE_THRESHOLD 2000
QT_BEGIN_NAMESPACE
@ -264,7 +265,9 @@ void QUnifiedTimer::restartAnimationTimer()
qDebug() << closestPauseAnimationTimeToFinish();
}
driver->stop();
pauseTimer.start(closestTimeToFinish, this);
// use a precise timer if the pause will be short
Qt::TimerType timerType = closestTimeToFinish < PAUSE_TIMER_COARSE_THRESHOLD ? Qt::PreciseTimer : Qt::CoarseTimer;
pauseTimer.start(closestTimeToFinish, timerType, this);
} else if (!driver->isRunning()) {
if (pauseTimer.isActive())
pauseTimer.stop();
@ -619,7 +622,8 @@ void QDefaultAnimationDriver::timerEvent(QTimerEvent *e)
void QDefaultAnimationDriver::startTimer()
{
m_timer.start(m_unified_timer->timingInterval, this);
// always use a precise timer to drive animations
m_timer.start(m_unified_timer->timingInterval, Qt::PreciseTimer, this);
}
void QDefaultAnimationDriver::stopTimer()