(Cocoa) Cleanups

This commit is contained in:
twinaphex 2019-02-10 01:24:41 +01:00
parent ed458cd89b
commit b1c4bdf6f7
3 changed files with 39 additions and 52 deletions

View File

@ -46,21 +46,6 @@ static bool cocoagl_gfx_ctx_bind_api(void *data,
return true;
}
static void cocoagl_gfx_ctx_swap_interval(void *data, int i)
{
(void)data;
unsigned interval = (unsigned)i;
#if defined(HAVE_COCOATOUCH) // < No way to disable Vsync on iOS?
// Just skip presents so fast forward still works.
g_is_syncing = interval ? true : false;
g_fast_forward_skips = interval ? 0 : 3;
#elif defined(HAVE_COCOA)
GLint value = interval ? 1 : 0;
[g_context setValues:&value forParameter:NSOpenGLCPSwapInterval];
#endif
}
static bool cocoagl_gfx_ctx_set_video_mode(void *data,
video_frame_info_t *video_info,
unsigned width, unsigned height, bool fullscreen)

View File

@ -83,43 +83,6 @@ static bool cocoagl_gfx_ctx_bind_api(void *data, enum gfx_ctx_api api,
return true;
}
static void cocoagl_gfx_ctx_swap_interval(void *data, int interval)
{
#ifdef HAVE_VULKAN
cocoa_ctx_data_t *cocoa_ctx = (cocoa_ctx_data_t*)data;
#endif
switch (cocoagl_api)
{
case GFX_CTX_OPENGL_API:
case GFX_CTX_OPENGL_ES_API:
{
#if defined(HAVE_COCOATOUCH) // < No way to disable Vsync on iOS?
// Just skip presents so fast forward still works.
g_is_syncing = interval ? true : false;
g_fast_forward_skips = interval ? 0 : 3;
#elif defined(HAVE_COCOA_METAL)
GLint value = interval ? 1 : 0;
[g_context setValues:&value forParameter:NSOpenGLCPSwapInterval];
#endif
break;
}
case GFX_CTX_VULKAN_API:
#ifdef HAVE_VULKAN
if (cocoa_ctx->swap_interval != interval)
{
cocoa_ctx->swap_interval = interval;
if (cocoa_ctx->vk.swapchain)
cocoa_ctx->vk.need_new_swapchain = true;
}
#endif
break;
case GFX_CTX_NONE:
default:
break;
}
}
static bool cocoagl_gfx_ctx_set_video_mode(void *data,
video_frame_info_t *video_info,

View File

@ -544,3 +544,42 @@ static void cocoagl_gfx_ctx_check_window(void *data, bool *quit,
*resize = true;
}
}
static void cocoagl_gfx_ctx_swap_interval(void *data, int i)
{
unsigned interval = (unsigned)i;
#ifdef HAVE_VULKAN
cocoa_ctx_data_t *cocoa_ctx = (cocoa_ctx_data_t*)data;
#endif
switch (cocoagl_api)
{
case GFX_CTX_OPENGL_API:
case GFX_CTX_OPENGL_ES_API:
{
#if defined(HAVE_COCOATOUCH) // < No way to disable Vsync on iOS?
// Just skip presents so fast forward still works.
g_is_syncing = interval ? true : false;
g_fast_forward_skips = interval ? 0 : 3;
#elif defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
GLint value = interval ? 1 : 0;
[g_context setValues:&value forParameter:NSOpenGLCPSwapInterval];
#endif
break;
}
case GFX_CTX_VULKAN_API:
#ifdef HAVE_VULKAN
if (cocoa_ctx->swap_interval != interval)
{
cocoa_ctx->swap_interval = interval;
if (cocoa_ctx->vk.swapchain)
cocoa_ctx->vk.need_new_swapchain = true;
}
#endif
break;
case GFX_CTX_NONE:
default:
break;
}
}