QUnifiedTimer: Add callback for timer ticks. Used for profiling
Change-Id: Ia7cf823dee7f0b491db2f041d29cdfc0e385f18e Reviewed-on: http://codereview.qt-project.org/6253 Reviewed-by: Kai Koehne <kai.koehne@nokia.com> Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
This commit is contained in:
parent
e5baaf05e8
commit
56921b1f88
@ -168,7 +168,7 @@ Q_GLOBAL_STATIC(QThreadStorage<QUnifiedTimer *>, unifiedTimer)
|
|||||||
QUnifiedTimer::QUnifiedTimer() :
|
QUnifiedTimer::QUnifiedTimer() :
|
||||||
QObject(), defaultDriver(this), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL),
|
QObject(), defaultDriver(this), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL),
|
||||||
currentAnimationIdx(0), insideTick(false), consistentTiming(false), slowMode(false),
|
currentAnimationIdx(0), insideTick(false), consistentTiming(false), slowMode(false),
|
||||||
slowdownFactor(5.0f), isPauseTimerActive(false), runningLeafAnimations(0)
|
slowdownFactor(5.0f), isPauseTimerActive(false), runningLeafAnimations(0), profilerCallback(0)
|
||||||
{
|
{
|
||||||
time.invalidate();
|
time.invalidate();
|
||||||
driver = &defaultDriver;
|
driver = &defaultDriver;
|
||||||
@ -234,12 +234,20 @@ void QUnifiedTimer::updateAnimationsTime(qint64 timeStep)
|
|||||||
int elapsed = QAbstractAnimationPrivate::get(animation)->totalCurrentTime
|
int elapsed = QAbstractAnimationPrivate::get(animation)->totalCurrentTime
|
||||||
+ (animation->direction() == QAbstractAnimation::Forward ? delta : -delta);
|
+ (animation->direction() == QAbstractAnimation::Forward ? delta : -delta);
|
||||||
animation->setCurrentTime(elapsed);
|
animation->setCurrentTime(elapsed);
|
||||||
|
|
||||||
|
if (profilerCallback)
|
||||||
|
profilerCallback(delta);
|
||||||
}
|
}
|
||||||
insideTick = false;
|
insideTick = false;
|
||||||
currentAnimationIdx = 0;
|
currentAnimationIdx = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QUnifiedTimer::registerProfilerCallback(void (*cb)(qint64))
|
||||||
|
{
|
||||||
|
profilerCallback = cb;
|
||||||
|
}
|
||||||
|
|
||||||
void QUnifiedTimer::updateAnimationTimer()
|
void QUnifiedTimer::updateAnimationTimer()
|
||||||
{
|
{
|
||||||
QUnifiedTimer *inst = QUnifiedTimer::instance(false);
|
QUnifiedTimer *inst = QUnifiedTimer::instance(false);
|
||||||
|
@ -189,6 +189,7 @@ public:
|
|||||||
|
|
||||||
//useful for profiling/debugging
|
//useful for profiling/debugging
|
||||||
int runningAnimationCount() { return animations.count(); }
|
int runningAnimationCount() { return animations.count(); }
|
||||||
|
void registerProfilerCallback(void (*cb)(qint64));
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void timerEvent(QTimerEvent *);
|
void timerEvent(QTimerEvent *);
|
||||||
@ -231,6 +232,8 @@ private:
|
|||||||
void unregisterRunningAnimation(QAbstractAnimation *animation);
|
void unregisterRunningAnimation(QAbstractAnimation *animation);
|
||||||
|
|
||||||
int closestPauseAnimationTimeToFinish();
|
int closestPauseAnimationTimeToFinish();
|
||||||
|
|
||||||
|
void (*profilerCallback)(qint64);
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
Loading…
Reference in New Issue
Block a user