Make timer init part of platform API

This is part of runtime platform selection because the null backend
needs the timer implementation for the current OS.
This commit is contained in:
Camilla Löwy 2021-07-16 13:53:31 +02:00
parent 6d51b39106
commit e31deedc99
13 changed files with 10 additions and 44 deletions

View File

@ -547,8 +547,6 @@ int _glfwPlatformInit(void)
if (!initializeTIS())
return GLFW_FALSE;
_glfwInitTimerNS();
_glfwPollMonitorsNS();
if (![[NSRunningApplication currentApplication] isFinishedLaunching])

View File

@ -191,8 +191,6 @@ typedef struct _GLFWtimerNS
} _GLFWtimerNS;
void _glfwInitTimerNS(void);
void _glfwPollMonitorsNS(void);
void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired);
void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor);

View File

@ -32,12 +32,10 @@
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
// Initialise timer
//
void _glfwInitTimerNS(void)
void _glfwPlatformInitTimer(void)
{
mach_timebase_info_data_t info;
mach_timebase_info(&info);
@ -45,11 +43,6 @@ void _glfwInitTimerNS(void)
_glfw.timer.ns.frequency = (info.denom * 1e9) / info.numer;
}
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
uint64_t _glfwPlatformGetTimerValue(void)
{
return mach_absolute_time();

View File

@ -340,9 +340,11 @@ GLFWAPI int glfwInit(void)
_glfwInitGamepadMappings();
_glfw.initialized = GLFW_TRUE;
_glfwPlatformInitTimer();
_glfw.timer.offset = _glfwPlatformGetTimerValue();
_glfw.initialized = GLFW_TRUE;
glfwDefaultWindowHints();
return GLFW_TRUE;
}

View File

@ -644,6 +644,7 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode);
void _glfwPlatformUpdateGamepadGUID(char* guid);
const char* _glfwPlatformGetMappingName(void);
void _glfwPlatformInitTimer(void);
uint64_t _glfwPlatformGetTimerValue(void);
uint64_t _glfwPlatformGetTimerFrequency(void);

View File

@ -38,7 +38,6 @@
int _glfwPlatformInit(void)
{
_glfwInitTimerPOSIX();
_glfwPollMonitorsNull();
return GLFW_TRUE;

View File

@ -34,12 +34,10 @@
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
// Initialise timer
//
void _glfwInitTimerPOSIX(void)
void _glfwPlatformInitTimer(void)
{
_glfw.timer.posix.clock = CLOCK_REALTIME;
_glfw.timer.posix.frequency = 1000000000;
@ -51,11 +49,6 @@ void _glfwInitTimerPOSIX(void)
#endif
}
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
uint64_t _glfwPlatformGetTimerValue(void)
{
struct timespec ts;

View File

@ -39,6 +39,3 @@ typedef struct _GLFWtimerPOSIX
uint64_t frequency;
} _GLFWtimerPOSIX;
void _glfwInitTimerPOSIX(void);

View File

@ -576,8 +576,6 @@ int _glfwPlatformInit(void)
if (!createHelperWindow())
return GLFW_FALSE;
_glfwInitTimerWin32();
_glfwPollMonitorsWin32();
return GLFW_TRUE;
}

View File

@ -445,8 +445,6 @@ BOOL _glfwIsWindows10BuildOrGreaterWin32(WORD build);
void _glfwInputErrorWin32(int error, const char* description);
void _glfwUpdateKeyNamesWin32(void);
void _glfwInitTimerWin32(void);
void _glfwPollMonitorsWin32(void);
void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired);
void _glfwRestoreVideoModeWin32(_GLFWmonitor* monitor);

View File

@ -31,12 +31,10 @@
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
// Initialise timer
//
void _glfwInitTimerWin32(void)
void _glfwPlatformInitTimer(void)
{
uint64_t frequency;
@ -52,11 +50,6 @@ void _glfwInitTimerWin32(void)
}
}
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
uint64_t _glfwPlatformGetTimerValue(void)
{
if (_glfw.timer.win32.hasPC)

View File

@ -1227,8 +1227,6 @@ int _glfwPlatformInit(void)
// Sync so we got all initial output events
wl_display_roundtrip(_glfw.wl.display);
_glfwInitTimerPOSIX();
_glfw.wl.timerfd = -1;
if (_glfw.wl.seatVersion >= 4)
_glfw.wl.timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);

View File

@ -1381,8 +1381,6 @@ int _glfwPlatformInit(void)
NULL);
}
_glfwInitTimerPOSIX();
_glfwPollMonitorsX11();
return GLFW_TRUE;
}