diff options
author | bobo1on1 <bobo1on1@svn> | 2010-06-25 21:43:57 +0000 |
---|---|---|
committer | bobo1on1 <bobo1on1@svn> | 2010-06-25 21:43:57 +0000 |
commit | 774ddb974336df6985246d7fc579e15ee65ef5ff (patch) | |
tree | 7d471adc991edb15c4e7d7767b62b4a6311739b4 | |
parent | f4a78c4b4ca4da5b3a1558bd38659411bf53063f (diff) |
added: option to use frametime in CStopWatch (thanks AlTheKiller)
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@31399 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
-rw-r--r-- | xbmc/GUIWindowVisualisation.cpp | 3 | ||||
-rw-r--r-- | xbmc/utils/Stopwatch.cpp | 13 | ||||
-rw-r--r-- | xbmc/utils/Stopwatch.h | 3 |
3 files changed, 15 insertions, 4 deletions
diff --git a/xbmc/GUIWindowVisualisation.cpp b/xbmc/GUIWindowVisualisation.cpp index fa475063e5..e1b1f5f7e2 100644 --- a/xbmc/GUIWindowVisualisation.cpp +++ b/xbmc/GUIWindowVisualisation.cpp @@ -41,7 +41,8 @@ using namespace ADDON; #define CONTROL_VIS 2 CGUIWindowVisualisation::CGUIWindowVisualisation(void) - : CGUIWindow(WINDOW_VISUALISATION, "MusicVisualisation.xml") + : CGUIWindow(WINDOW_VISUALISATION, "MusicVisualisation.xml"), + m_initTimer(true), m_lockedTimer(true) { m_bShowPreset = false; } diff --git a/xbmc/utils/Stopwatch.cpp b/xbmc/utils/Stopwatch.cpp index fe153e0438..1190e4b1e8 100644 --- a/xbmc/utils/Stopwatch.cpp +++ b/xbmc/utils/Stopwatch.cpp @@ -25,19 +25,26 @@ #endif #include "utils/TimeUtils.h" -CStopWatch::CStopWatch() +CStopWatch::CStopWatch(bool useFrameTime /*=false*/) { m_timerPeriod = 0.0f; m_startTick = 0; m_isRunning = false; + m_useFrameTime = useFrameTime; + if (m_useFrameTime) + { + m_timerPeriod = 1.0f / 1000.0f; //frametime is in milliseconds + } + else + { // Get the timer frequency (ticks per second) #ifndef _LINUX m_timerPeriod = 1.0f / (float)CurrentHostFrequency(); #else m_timerPeriod = 1.0f / 1000.0f; // we want seconds #endif - + } } CStopWatch::~CStopWatch() @@ -90,6 +97,8 @@ float CStopWatch::GetElapsedMilliseconds() const int64_t CStopWatch::GetTicks() const { + if (m_useFrameTime) + return CTimeUtils::GetFrameTime(); #ifndef _LINUX return CurrentHostCounter(); #else diff --git a/xbmc/utils/Stopwatch.h b/xbmc/utils/Stopwatch.h index 3109494988..932c711f54 100644 --- a/xbmc/utils/Stopwatch.h +++ b/xbmc/utils/Stopwatch.h @@ -26,7 +26,7 @@ class CStopWatch { public: - CStopWatch(); + CStopWatch(bool useFrameTime=false); ~CStopWatch(); bool IsRunning() const; @@ -42,4 +42,5 @@ private: float m_timerPeriod; // to save division in GetElapsed...() int64_t m_startTick; bool m_isRunning; + bool m_useFrameTime; }; |