diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2017-08-15 23:22:36 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2017-09-15 14:22:51 +0200 |
commit | 73bc364347fc8325a632f17fcda220ce7d6f5945 (patch) | |
tree | fd2ee517f8d15d3c5ffe2ef044aed12df89f9b47 /canvas | |
parent | cef9cf59f8064be99ce3b7d0738ab0775715112c (diff) |
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 <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'canvas')
-rw-r--r-- | canvas/Library_canvastools.mk | 6 | ||||
-rw-r--r-- | canvas/source/tools/elapsedtime.cxx | 81 |
2 files changed, 2 insertions, 85 deletions
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 <sal/config.h> -#include <osl/time.h> - #include <canvas/elapsedtime.hxx> -#if defined(_WIN32) - -#if defined _MSC_VER -#pragma warning(push,1) -#endif - -// TEMP!!! -// Awaiting corresponding functionality in OSL - -#define WIN32_LEAN_AND_MEAN -#include <windows.h> -#include <winbase.h> -#include <mmsystem.h> -#endif - -#if defined _MSC_VER -#pragma warning(pop) -#endif +#include <tools/time.hxx> #include <algorithm> #include <limits> @@ -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<LARGE_INTEGER *>(&nPerfCountFreq) ) ) - { - // read initial time: - QueryPerformanceCounter( - reinterpret_cast<LARGE_INTEGER *>(&nInitialCount) ); - bPerfTimerAvailable = true; - } - bTimeSetupDone = true; - } - - if( bPerfTimerAvailable ) - { - LONGLONG nCurrCount; - QueryPerformanceCounter( - reinterpret_cast<LARGE_INTEGER *>(&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 ), |