(cocoa_gl_ctx.m) Style nits

This commit is contained in:
twinaphex 2020-09-15 11:28:04 +02:00
parent c436ac83cd
commit 26b2295759
1 changed files with 112 additions and 122 deletions

View File

@ -52,9 +52,6 @@
typedef struct cocoa_ctx_data
{
bool is_syncing;
bool core_hw_context_enable;
bool use_hw_ctx;
#ifdef HAVE_VULKAN
gfx_ctx_vulkan_data_t vk;
int swap_interval;
@ -62,6 +59,9 @@ typedef struct cocoa_ctx_data
int fast_forward_skips;
unsigned width;
unsigned height;
bool is_syncing;
bool core_hw_context_enable;
bool use_hw_ctx;
} cocoa_ctx_data_t;
/* TODO/FIXME - static globals */
@ -108,10 +108,7 @@ void *nsview_get_ptr(void)
return (BRIDGE void *)g_instance;
}
void nsview_set_ptr(CocoaView *p)
{
g_instance = p;
}
void nsview_set_ptr(CocoaView *p) { g_instance = p; }
#if TARGET_OS_OSX
static SEL sel_flushBuffer;
@ -168,7 +165,6 @@ static uint32_t cocoagl_gfx_ctx_get_flags(void *data)
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))
@ -198,7 +194,8 @@ void cocoagl_bind_game_view_fbo(void)
}
#endif
static float get_from_selector(Class obj_class, id obj_id, SEL selector, CGFloat *ret)
static float get_from_selector(
Class obj_class, id obj_id, SEL selector, CGFloat *ret)
{
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:
[obj_class instanceMethodSignatureForSelector:selector]];
@ -333,8 +330,6 @@ static enum gfx_ctx_api cocoagl_gfx_ctx_get_api(void *data)
static void cocoagl_gfx_ctx_show_mouse(void *data, bool state)
{
(void)data;
#if TARGET_OS_OSX
if (state)
[NSCursor unhide];
@ -383,7 +378,8 @@ static void cocoagl_gfx_ctx_update_title(void *data)
}
#endif
static bool cocoagl_gfx_ctx_get_metrics(void *data, enum display_metric_types type,
static bool cocoagl_gfx_ctx_get_metrics(
void *data, enum display_metric_types type,
float *value)
{
RAScreen *screen = (BRIDGE RAScreen*)get_chosen_screen();
@ -418,12 +414,11 @@ static bool cocoagl_gfx_ctx_get_metrics(void *data, enum display_metric_types ty
dpi = 132 * scale;
break;
case UIUserInterfaceIdiomPhone:
if (maxSize >= 2208.0) {
// Larger iPhones: iPhone Plus, X, XR, XS, XS Max, 11, 11 Pro Max
/* Larger iPhones: iPhone Plus, X, XR, XS, XS Max, 11, 11 Pro Max */
if (maxSize >= 2208.0)
dpi = 81 * scale;
} else {
else
dpi = 163 * scale;
}
break;
case UIUserInterfaceIdiomTV:
case UIUserInterfaceIdiomCarPlay:
@ -456,7 +451,6 @@ static bool cocoagl_gfx_ctx_get_metrics(void *data, enum display_metric_types ty
static bool cocoagl_gfx_ctx_has_focus(void *data)
{
(void)data;
#if defined(HAVE_COCOATOUCH)
return ([[UIApplication sharedApplication] applicationState] == UIApplicationStateActive);
#else
@ -464,13 +458,7 @@ static bool cocoagl_gfx_ctx_has_focus(void *data)
#endif
}
static bool cocoagl_gfx_ctx_suppress_screensaver(void *data, bool enable)
{
(void)data;
(void)enable;
return false;
}
static bool cocoagl_gfx_ctx_suppress_screensaver(void *data, bool enable) { return false; }
static void cocoagl_gfx_ctx_input_driver(void *data,
const char *name,
@ -480,7 +468,8 @@ static void cocoagl_gfx_ctx_input_driver(void *data,
*input_data = NULL;
}
static void cocoagl_gfx_ctx_get_video_size(void *data, unsigned* width, unsigned* height)
static void cocoagl_gfx_ctx_get_video_size(void *data,
unsigned* width, unsigned* height)
{
float screenscale = cocoagl_gfx_ctx_get_native_scale();
#if TARGET_OS_OSX
@ -591,8 +580,9 @@ static void cocoagl_gfx_ctx_swap_interval(void *data, int i)
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.
#if defined(HAVE_COCOATOUCH)
/* < No way to disable Vsync on iOS? */
/* Just skip presents so fast forward still works. */
cocoa_ctx->is_syncing = interval ? true : false;
cocoa_ctx->fast_forward_skips = interval ? 0 : 3;
#elif defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
@ -660,7 +650,6 @@ static void cocoagl_gfx_ctx_swap_buffers(void *data)
static bool cocoagl_gfx_ctx_bind_api(void *data, enum gfx_ctx_api api,
unsigned major, unsigned minor)
{
(void)data;
switch (api)
{
#if defined(HAVE_COCOATOUCH)
@ -704,6 +693,8 @@ static bool cocoagl_gfx_ctx_set_video_mode(void *data,
#endif
cocoa_ctx_data_t *cocoa_ctx = (cocoa_ctx_data_t*)data;
#if TARGET_OS_OSX
static bool
has_went_fullscreen = false;
cocoa_ctx->width = width;
cocoa_ctx->height = height;
#endif
@ -723,7 +714,7 @@ static bool cocoagl_gfx_ctx_set_video_mode(void *data,
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAAllowOfflineRenderers,
NSOpenGLPFADepthSize,
(NSOpenGLPixelFormatAttribute)16, // 16 bit depth buffer
(NSOpenGLPixelFormatAttribute)16, /* 16 bit depth buffer */
0, /* profile */
0, /* profile enum */
(NSOpenGLPixelFormatAttribute)0
@ -790,9 +781,7 @@ static bool cocoagl_gfx_ctx_set_video_mode(void *data,
}
#if TARGET_OS_OSX
static bool has_went_fullscreen = false;
/* TODO: Screen mode support. */
if (fullscreen)
{
if (!has_went_fullscreen)
@ -820,8 +809,8 @@ static bool cocoagl_gfx_ctx_set_video_mode(void *data,
has_went_fullscreen = fullscreen;
#endif
/* TODO: Maybe iOS users should be able to show/hide the status bar here? */
/* TODO: Maybe iOS users should be able to
* show/hide the status bar here? */
return true;
}
@ -840,11 +829,14 @@ static void *cocoagl_gfx_ctx_init(void *video_driver)
#if defined(HAVE_COCOATOUCH)
case GFX_CTX_OPENGL_ES_API:
#if defined(HAVE_COCOA_METAL)
// the metal build supports both the OpenGL and Metal video drivers
/* the metal build supports both the OpenGL
* and Metal video drivers */
[apple_platform setViewType:APPLE_VIEW_TYPE_OPENGL_ES];
#endif
/* setViewType is not (yet?) defined for iOS */
#if 0
[apple_platform setViewType:APPLE_VIEW_TYPE_OPENGL_ES];
#endif
// setViewType is not (yet?) defined for iOS
// [apple_platform setViewType:APPLE_VIEW_TYPE_OPENGL_ES];
break;
#elif defined(HAVE_COCOA_METAL)
case GFX_CTX_OPENGL_API:
@ -891,19 +883,17 @@ static bool cocoagl_gfx_ctx_set_resize(void *data, unsigned width, unsigned heig
cocoa_ctx->width = width;
cocoa_ctx->height = height;
if (vulkan_create_swapchain(&cocoa_ctx->vk,
if (!vulkan_create_swapchain(&cocoa_ctx->vk,
width, height, cocoa_ctx->swap_interval))
{
cocoa_ctx->vk.context.invalid_swapchain = true;
if (cocoa_ctx->vk.created_new_swapchain)
vulkan_acquire_next_image(&cocoa_ctx->vk);
}
else
{
RARCH_ERR("[macOS/Vulkan]: Failed to update swapchain.\n");
return false;
}
cocoa_ctx->vk.context.invalid_swapchain = true;
if (cocoa_ctx->vk.created_new_swapchain)
vulkan_acquire_next_image(&cocoa_ctx->vk);
cocoa_ctx->vk.need_new_swapchain = false;
#endif
break;