diff --git a/apple/common/apple_gfx_context.c.inl b/apple/common/apple_gfx_context.c.inl index 7da67684f1..682da6b833 100644 --- a/apple/common/apple_gfx_context.c.inl +++ b/apple/common/apple_gfx_context.c.inl @@ -234,21 +234,17 @@ CGFloat apple_gfx_ctx_get_native_scale(void) if (!screen) return 0.0f; - (void)selector; - -#ifdef IOS - if ([[UIScreen mainScreen] respondsToSelector:selector]) + if ([screen respondsToSelector:selector]) { float ret; NSInvocation *invocation = [NSInvocation invocationWithMethodSignature: - [[[UIScreen mainScreen] class] instanceMethodSignatureForSelector:selector]]; + [[screen class] instanceMethodSignatureForSelector:selector]]; [invocation setSelector:selector]; - [invocation setTarget:[UIScreen mainScreen]]; + [invocation setTarget:screen]; [invocation invoke]; [invocation getReturnValue:&ret]; return ret; } -#endif return screen.scale; } @@ -258,7 +254,10 @@ static void apple_gfx_ctx_get_video_size(void *data, unsigned* width, unsigned* RAScreen *screen = (RAScreen*)get_chosen_screen(); CGRect size = screen.bounds; gl_t *gl = (gl_t*)data; - CGFloat screenscale = apple_gfx_ctx_get_native_scale(); + static CGFloat screenscale = 0.0f; + + if (screenscale == 0.0f) + screenscale = apple_gfx_ctx_get_native_scale(); if (gl) { diff --git a/apple/iOS/platform.m b/apple/iOS/platform.m index 85e822883c..cf039a42e9 100644 --- a/apple/iOS/platform.m +++ b/apple/iOS/platform.m @@ -90,10 +90,12 @@ static void handle_touch_event(NSArray* touches) { NSUInteger i; apple_input_data_t *apple = (apple_input_data_t*)driver.input_data; - const float scale = apple_gfx_ctx_get_native_scale(); + static CGFloat scale = 0.0f; if (!apple) return; + if (scale == 0.0f) + scale = apple_gfx_ctx_get_native_scale(); apple->touch_count = 0;