summaryrefslogtreecommitdiffstats
path: root/src/corelib/animation
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2010-02-18 17:27:45 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2010-03-17 10:54:17 (GMT)
commitcd33d38ce0067719b0215264a22685a91b2e08dc (patch)
tree6dce3760c20b9631ca3be96b59bc0351381cedcb /src/corelib/animation
parent8c9446cd2058fde086df92f6b7d97e4770cf8dc6 (diff)
downloadQt-cd33d38ce0067719b0215264a22685a91b2e08dc.zip
Qt-cd33d38ce0067719b0215264a22685a91b2e08dc.tar.gz
Qt-cd33d38ce0067719b0215264a22685a91b2e08dc.tar.bz2
Port QtCore uses of QTime as a stopwatch to QTimestamp.
tst_qtimeline improvement: from 56187446 to 53915928 (callgrind)
Diffstat (limited to 'src/corelib/animation')
-rw-r--r--src/corelib/animation/qabstractanimation.cpp1
-rw-r--r--src/corelib/animation/qabstractanimation_p.h57
2 files changed, 3 insertions, 55 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index f834a80..82b3003 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -170,6 +170,7 @@ QUnifiedTimer::QUnifiedTimer() :
currentAnimationIdx(0), consistentTiming(false), slowMode(false),
isPauseTimerActive(false), runningLeafAnimations(0)
{
+ time.invalidate();
}
QUnifiedTimer *QUnifiedTimer::instance()
diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h
index 8bc3224..3eb4948 100644
--- a/src/corelib/animation/qabstractanimation_p.h
+++ b/src/corelib/animation/qabstractanimation_p.h
@@ -56,6 +56,7 @@
#include <QtCore/qbasictimer.h>
#include <QtCore/qdatetime.h>
#include <QtCore/qtimer.h>
+#include <QtCore/qtimestamp.h>
#include <private/qobject_p.h>
#ifdef Q_OS_WIN
@@ -113,61 +114,7 @@ private:
Q_DECLARE_PUBLIC(QAbstractAnimation)
};
-class ElapsedTimer
-{
-public:
- ElapsedTimer() {
- invalidate();
- }
-
- void invalidate() {
- m_started = -1;
- }
-
- bool isValid() const {
- return m_started >= 0;
- }
-
- void start() {
- m_started = getTickCount_sys();
- }
-
- qint64 elapsed() const {
- qint64 current = getTickCount_sys();
- qint64 delta = current - m_started;
- if (delta < 0)
- delta += getPeriod_sys(); //we wrapped around
- return delta;
- }
-
-private:
- enum {
- MSECS_PER_HOUR = 3600000,
- MSECS_PER_MIN = 60000
- };
-
- qint64 m_started;
-
- quint64 getPeriod_sys() const {
-#ifdef Q_OS_WIN
- return Q_UINT64_C(0x100000000);
-#else
- // fallback
- return 86400 * 1000;
-#endif
- }
-
- qint64 getTickCount_sys() const {
-#ifdef Q_OS_WIN
- return ::GetTickCount();
-#else
- // fallback
- const QTime t = QTime::currentTime();
- return MSECS_PER_HOUR * t.hour() + MSECS_PER_MIN * t.minute() + 1000 * t.second() + t.msec();
-#endif
- }
-};
-
+typedef QTimestamp ElapsedTimer;
class QUnifiedTimer : public QObject
{