diff --git a/gfx/drivers_context/cocoa_gl_ctx.m b/gfx/drivers_context/cocoa_gl_ctx.m index 815b850fbc..73866e5764 100644 --- a/gfx/drivers_context/cocoa_gl_ctx.m +++ b/gfx/drivers_context/cocoa_gl_ctx.m @@ -35,7 +35,8 @@ #include #include -#import "../../ui/drivers/cocoa/cocoa_common.h" +#include "../../ui/drivers/ui_cocoa.h" +#include "../../ui/drivers/cocoa/cocoa_common.h" #include "../video_driver.h" #include "../../configuration.h" #include "../../verbosity.h" @@ -97,7 +98,6 @@ static bool g_is_syncing = true; static bool g_use_hw_ctx = false; #if defined(HAVE_COCOA) -#include "../../ui/drivers/ui_cocoa.h" static NSOpenGLPixelFormat* g_format; void *glcontext_get_ptr(void) @@ -121,6 +121,8 @@ static void glkitview_init_xibs(void) } #endif +#include "cocoa_gl_shared.h" + void *glkitview_init(void) { #if defined(HAVE_COCOATOUCH) @@ -625,28 +627,6 @@ static void cocoagl_gfx_ctx_bind_hw_render(void *data, bool enable) [g_context makeCurrentContext]; } -static uint32_t cocoagl_gfx_ctx_get_flags(void *data) -{ - uint32_t flags = 0; - cocoa_ctx_data_t *cocoa_ctx = (cocoa_ctx_data_t*)data; - - BIT32_SET(flags, GFX_CTX_FLAGS_NONE); - - if (cocoa_ctx->core_hw_context_enable) - BIT32_SET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT); - - return flags; -} - -static void cocoagl_gfx_ctx_set_flags(void *data, uint32_t flags) -{ - (void)flags; - cocoa_ctx_data_t *cocoa_ctx = (cocoa_ctx_data_t*)data; - - if (BIT32_GET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT)) - cocoa_ctx->core_hw_context_enable = true; -} - const gfx_ctx_driver_t gfx_ctx_cocoagl = { cocoagl_gfx_ctx_init, cocoagl_gfx_ctx_destroy, diff --git a/gfx/drivers_context/cocoa_gl_ctx_metal.m b/gfx/drivers_context/cocoa_gl_ctx_metal.m index 3cd1fede81..be2a7f30c5 100644 --- a/gfx/drivers_context/cocoa_gl_ctx_metal.m +++ b/gfx/drivers_context/cocoa_gl_ctx_metal.m @@ -34,7 +34,8 @@ #include #include -#import "../../ui/drivers/cocoa/cocoa_common.h" +#include "../../ui/drivers/ui_cocoa.h" +#include "../../ui/drivers/cocoa/cocoa_common.h" #include "../video_driver.h" #include "../../configuration.h" #include "../../verbosity.h" @@ -55,6 +56,7 @@ #define UIUserInterfaceIdiomCarPlay 3 #endif + @interface EAGLContext (OSXCompat) @end @implementation EAGLContext (OSXCompat) + (void)clearCurrentContext { [EAGLContext setCurrentContext:nil]; } @@ -104,8 +106,6 @@ static int g_fast_forward_skips; static bool g_is_syncing = true; static bool g_use_hw_ctx = false; -#include "../../ui/drivers/ui_cocoa.h" - #if defined(HAVE_COCOA_METAL) static NSOpenGLPixelFormat* g_format; @@ -130,6 +130,8 @@ static void glkitview_init_xibs(void) } #endif +#include "cocoa_gl_shared.h" + void *glkitview_init(void) { #if defined(HAVE_COCOATOUCH) @@ -850,28 +852,6 @@ static void cocoagl_gfx_ctx_bind_hw_render(void *data, bool enable) } } -static uint32_t cocoagl_gfx_ctx_get_flags(void *data) -{ - uint32_t flags = 0; - cocoa_ctx_data_t *cocoa_ctx = (cocoa_ctx_data_t*)data; - - BIT32_SET(flags, GFX_CTX_FLAGS_NONE); - - if (cocoa_ctx->core_hw_context_enable) - BIT32_SET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT); - - return flags; -} - -static void cocoagl_gfx_ctx_set_flags(void *data, uint32_t flags) -{ - (void)flags; - cocoa_ctx_data_t *cocoa_ctx = (cocoa_ctx_data_t*)data; - - if (BIT32_GET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT)) - cocoa_ctx->core_hw_context_enable = true; -} - const gfx_ctx_driver_t gfx_ctx_cocoagl = { .init = cocoagl_gfx_ctx_init, .destroy = cocoagl_gfx_ctx_destroy, diff --git a/gfx/drivers_context/cocoa_gl_shared.h b/gfx/drivers_context/cocoa_gl_shared.h new file mode 100644 index 0000000000..33aec26b11 --- /dev/null +++ b/gfx/drivers_context/cocoa_gl_shared.h @@ -0,0 +1,22 @@ + +static uint32_t cocoagl_gfx_ctx_get_flags(void *data) +{ + uint32_t flags = 0; + cocoa_ctx_data_t *cocoa_ctx = (cocoa_ctx_data_t*)data; + + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + + if (cocoa_ctx->core_hw_context_enable) + BIT32_SET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT); + + return flags; +} + +static void cocoagl_gfx_ctx_set_flags(void *data, uint32_t flags) +{ + (void)flags; + cocoa_ctx_data_t *cocoa_ctx = (cocoa_ctx_data_t*)data; + + if (BIT32_GET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT)) + cocoa_ctx->core_hw_context_enable = true; +} diff --git a/ui/drivers/ui_cocoa.m b/ui/drivers/ui_cocoa.m index 7ef1bc35b2..42c0f16655 100644 --- a/ui/drivers/ui_cocoa.m +++ b/ui/drivers/ui_cocoa.m @@ -499,7 +499,7 @@ static char** waiting_argv; - (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames { - if (filenames.count == 1 && [filenames objectAtIndex:0]) + if (filenames.count == 1 && filenames[0]) { struct retro_system_info *system = runloop_get_libretro_system_info(); NSString *__core = filenames[0];