From 165b502948c289d351489f748bc88cc36d56373a Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Tue, 21 Apr 2015 12:57:35 +0200 Subject: [PATCH] Make get_native_scale code more expandable --- gfx/drivers_context/cocoa_gl_ctx.m | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/gfx/drivers_context/cocoa_gl_ctx.m b/gfx/drivers_context/cocoa_gl_ctx.m index 583eaec303..ec71a27544 100644 --- a/gfx/drivers_context/cocoa_gl_ctx.m +++ b/gfx/drivers_context/cocoa_gl_ctx.m @@ -271,6 +271,18 @@ static bool cocoagl_gfx_ctx_set_video_mode(void *data, unsigned width, unsigned return true; } +static float cocoagl_gfx_ctx_get_scale_from_selector(RAScreen *screen, SEL selector) +{ + float ret; + NSInvocation *invocation = [NSInvocation invocationWithMethodSignature: + [[screen class] instanceMethodSignatureForSelector:selector]]; + [invocation setSelector:selector]; + [invocation setTarget:screen]; + [invocation invoke]; + [invocation getReturnValue:&ret]; + return ret; +} + float cocoagl_gfx_ctx_get_native_scale(void) { static float ret = 0.0f; @@ -283,15 +295,7 @@ float cocoagl_gfx_ctx_get_native_scale(void) return 0.0f; if ([screen respondsToSelector:selector]) - { - NSInvocation *invocation = [NSInvocation invocationWithMethodSignature: - [[screen class] instanceMethodSignatureForSelector:selector]]; - [invocation setSelector:selector]; - [invocation setTarget:screen]; - [invocation invoke]; - [invocation getReturnValue:&ret]; - return ret; - } + return cocoagl_gfx_ctx_get_scale_from_selector(screen, selector); ret = 1.0f; if ([screen respondsToSelector:@selector(scale)])