From 73bc364347fc8325a632f17fcda220ce7d6f5945 Mon Sep 17 00:00:00 2001 From: Jan-Marek Glogowski Date: Tue, 15 Aug 2017 23:22:36 +0200 Subject: Add tools::Time::GetMonotonicTicks (us) This moves a combination of tools::Time::GetSystemTicks(), canvas ElapsedTime::getSystemTime() and the opencl timing implementation into tools::Time::GetMonotonicTicks() as a monotonic microsecond time source. Change-Id: I5c9263540b8af55b2eeca6126e288129427f6e8e Reviewed-on: https://gerrit.libreoffice.org/41991 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- canvas/Library_canvastools.mk | 6 --- canvas/source/tools/elapsedtime.cxx | 81 +------------------------------------ 2 files changed, 2 insertions(+), 85 deletions(-) (limited to 'canvas') diff --git a/canvas/Library_canvastools.mk b/canvas/Library_canvastools.mk index 50658b362f6b..a87e53fd1043 100644 --- a/canvas/Library_canvastools.mk +++ b/canvas/Library_canvastools.mk @@ -69,10 +69,4 @@ $(eval $(call gb_Library_add_defs,canvastools,\ endif endif -ifeq ($(OS),WNT) -$(eval $(call gb_Library_use_system_win32_libs,canvastools,\ - winmm \ -)) -endif - # vim: set noet sw=4 ts=4: diff --git a/canvas/source/tools/elapsedtime.cxx b/canvas/source/tools/elapsedtime.cxx index e82df7dbe3fb..6cb7fd546a8e 100644 --- a/canvas/source/tools/elapsedtime.cxx +++ b/canvas/source/tools/elapsedtime.cxx @@ -19,28 +19,9 @@ #include -#include - #include -#if defined(_WIN32) - -#if defined _MSC_VER -#pragma warning(push,1) -#endif - -// TEMP!!! -// Awaiting corresponding functionality in OSL - -#define WIN32_LEAN_AND_MEAN -#include -#include -#include -#endif - -#if defined _MSC_VER -#pragma warning(pop) -#endif +#include #include #include @@ -48,69 +29,11 @@ namespace canvas { namespace tools { - -#if defined(_WIN32) -// TODO(Q2): is 0 okay for the failure case here? double ElapsedTime::getSystemTime() { - // TEMP!!! - // Awaiting corresponding functionality in OSL - - - // is there a performance counter available? - static bool bTimeSetupDone( false ); - static bool bPerfTimerAvailable( false ); - static LONGLONG nPerfCountFreq; - - // TODO(F1): This _might_ cause problems, as it prevents correct - // time handling for very long lifetimes of this class's - // surrounding component in memory. When the difference between - // current sys time and nInitialCount exceeds IEEE double's - // mantissa, time will start to run jerky. - static LONGLONG nInitialCount; - - if( !bTimeSetupDone ) - { - if( QueryPerformanceFrequency( - reinterpret_cast(&nPerfCountFreq) ) ) - { - // read initial time: - QueryPerformanceCounter( - reinterpret_cast(&nInitialCount) ); - bPerfTimerAvailable = true; - } - bTimeSetupDone = true; - } - - if( bPerfTimerAvailable ) - { - LONGLONG nCurrCount; - QueryPerformanceCounter( - reinterpret_cast(&nCurrCount) ); - nCurrCount -= nInitialCount; - return double(nCurrCount) / nPerfCountFreq; - } - else - { - LONGLONG nCurrTime = timeGetTime(); - return double(nCurrTime) / 1000.0; - } + return ::tools::Time::GetMonotonicTicks() / 1.0E6; } -#else // ! WNT - -// TODO(Q2): is 0 okay for the failure case here? -double ElapsedTime::getSystemTime() -{ - TimeValue aTimeVal; - if( osl_getSystemTime( &aTimeVal ) ) - return ((aTimeVal.Nanosec * 10e-10) + aTimeVal.Seconds); - else - return 0.0; -} - -#endif - ElapsedTime::ElapsedTime() : m_pTimeBase(), m_fLastQueriedTime( 0.0 ), -- cgit