diff options
author | David Robillard <d@drobilla.net> | 2019-07-22 17:21:52 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2019-09-03 08:32:16 +0200 |
commit | dacaaa5f328ac2598123aa1f0744ddd68c87e9cc (patch) | |
tree | 31bdcb5effdff7d84f946a577cd77d6462dd6083 /pugl/detail | |
parent | 61476f5de49b20a6836186a82082bc2b7c70e971 (diff) | |
download | pugl-dacaaa5f328ac2598123aa1f0744ddd68c87e9cc.tar.gz pugl-dacaaa5f328ac2598123aa1f0744ddd68c87e9cc.tar.bz2 pugl-dacaaa5f328ac2598123aa1f0744ddd68c87e9cc.zip |
Move puglGetTime() to PuglWorld
Diffstat (limited to 'pugl/detail')
-rw-r--r-- | pugl/detail/implementation.c | 3 | ||||
-rw-r--r-- | pugl/detail/mac.m | 4 | ||||
-rw-r--r-- | pugl/detail/types.h | 2 | ||||
-rw-r--r-- | pugl/detail/win.c | 6 | ||||
-rw-r--r-- | pugl/detail/x11.c | 4 |
5 files changed, 10 insertions, 9 deletions
diff --git a/pugl/detail/implementation.c b/pugl/detail/implementation.c index 29daf15..6ec19c2 100644 --- a/pugl/detail/implementation.c +++ b/pugl/detail/implementation.c @@ -67,6 +67,8 @@ puglNewWorld(void) return NULL; } + world->startTime = puglGetTime(world); + return world; } @@ -90,7 +92,6 @@ puglNewView(PuglWorld* const world) view->world = world; view->width = 640; view->height = 480; - view->start_time = puglGetTime(view); puglSetDefaultHints(view->hints); diff --git a/pugl/detail/mac.m b/pugl/detail/mac.m index 23344ed..527724d 100644 --- a/pugl/detail/mac.m +++ b/pugl/detail/mac.m @@ -868,9 +868,9 @@ puglGetProcAddress(const char *name) } double -puglGetTime(PuglView* view) +puglGetTime(const PuglWorld* world) { - return (mach_absolute_time() / 1e9) - view->start_time; + return (mach_absolute_time() / 1e9) - world->startTime; } void diff --git a/pugl/detail/types.h b/pugl/detail/types.h index fdfb0f6..e279833 100644 --- a/pugl/detail/types.h +++ b/pugl/detail/types.h @@ -54,7 +54,6 @@ struct PuglViewImpl { PuglEventFunc eventFunc; char* windowClass; PuglNativeWindow parent; - double start_time; uintptr_t transient_parent; PuglHints hints; int width; @@ -71,6 +70,7 @@ struct PuglViewImpl { /** Cross-platform world definition. */ struct PuglWorldImpl { PuglWorldInternals* impl; + double startTime; size_t numViews; PuglView** views; }; diff --git a/pugl/detail/win.c b/pugl/detail/win.c index 804c883..6a0825a 100644 --- a/pugl/detail/win.c +++ b/pugl/detail/win.c @@ -704,12 +704,12 @@ wndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) } double -puglGetTime(PuglView* view) +puglGetTime(const PuglWorld* world) { LARGE_INTEGER count; QueryPerformanceCounter(&count); - return ((double)count.QuadPart / view->world->impl->timerFrequency - - view->start_time); + return ((double)count.QuadPart / world->impl->timerFrequency - + world->startTime); } void diff --git a/pugl/detail/x11.c b/pugl/detail/x11.c index e0b3dea..d54f1bf 100644 --- a/pugl/detail/x11.c +++ b/pugl/detail/x11.c @@ -600,11 +600,11 @@ puglProcessEvents(PuglView* view) } double -puglGetTime(PuglView* view) +puglGetTime(const PuglWorld* world) { struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); - return ((double)ts.tv_sec + ts.tv_nsec / 1000000000.0) - view->start_time; + return ((double)ts.tv_sec + ts.tv_nsec / 1000000000.0) - world->startTime; } void |