Make get_native_scale code more expandable
This commit is contained in:
parent
af00b958d5
commit
165b502948
|
@ -271,6 +271,18 @@ static bool cocoagl_gfx_ctx_set_video_mode(void *data, unsigned width, unsigned
|
||||||
return true;
|
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)
|
float cocoagl_gfx_ctx_get_native_scale(void)
|
||||||
{
|
{
|
||||||
static float ret = 0.0f;
|
static float ret = 0.0f;
|
||||||
|
@ -283,15 +295,7 @@ float cocoagl_gfx_ctx_get_native_scale(void)
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
|
|
||||||
if ([screen respondsToSelector:selector])
|
if ([screen respondsToSelector:selector])
|
||||||
{
|
return cocoagl_gfx_ctx_get_scale_from_selector(screen, selector);
|
||||||
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:
|
|
||||||
[[screen class] instanceMethodSignatureForSelector:selector]];
|
|
||||||
[invocation setSelector:selector];
|
|
||||||
[invocation setTarget:screen];
|
|
||||||
[invocation invoke];
|
|
||||||
[invocation getReturnValue:&ret];
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = 1.0f;
|
ret = 1.0f;
|
||||||
if ([screen respondsToSelector:@selector(scale)])
|
if ([screen respondsToSelector:@selector(scale)])
|
||||||
|
|
Loading…
Reference in New Issue