mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-28 02:30:35 +00:00
(OSX) Create get_backing_scale_factor
This commit is contained in:
parent
85575f4acc
commit
09a183df3f
@ -152,6 +152,22 @@ void *get_chosen_screen(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float get_backing_scale_factor(void)
|
||||||
|
{
|
||||||
|
#if __has_feature(objc_arc)
|
||||||
|
RAScreen *screen = (__bridge RAScreen*)get_chosen_screen();
|
||||||
|
#else
|
||||||
|
RAScreen *screen = (RAScreen*)get_chosen_screen();
|
||||||
|
#endif
|
||||||
|
if (!screen)
|
||||||
|
return 0.0;
|
||||||
|
#if MAC_OS_X_VERSION_10_7
|
||||||
|
return screen.backingScaleFactor;
|
||||||
|
#else
|
||||||
|
return 1.0f;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void cocoagl_gfx_ctx_update(void)
|
void cocoagl_gfx_ctx_update(void)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_COCOA)
|
#if defined(HAVE_COCOA)
|
||||||
@ -419,11 +435,7 @@ static bool cocoagl_gfx_ctx_get_metrics(void *data, enum display_metric_types ty
|
|||||||
float display_height = display_pixel_size.height;
|
float display_height = display_pixel_size.height;
|
||||||
float physical_width = display_physical_size.width;
|
float physical_width = display_physical_size.width;
|
||||||
float physical_height = display_physical_size.height;
|
float physical_height = display_physical_size.height;
|
||||||
#if MAC_OS_X_VERSION_10_7
|
float scale = get_backing_scale_factor();
|
||||||
float scale = screen.backingScaleFactor;
|
|
||||||
#else
|
|
||||||
float scale = 1.0f;
|
|
||||||
#endif
|
|
||||||
float dpi = (display_width/ physical_width) * 25.4f * scale;
|
float dpi = (display_width/ physical_width) * 25.4f * scale;
|
||||||
#elif defined(HAVE_COCOATOUCH)
|
#elif defined(HAVE_COCOATOUCH)
|
||||||
float scale = cocoagl_gfx_ctx_get_native_scale();
|
float scale = cocoagl_gfx_ctx_get_native_scale();
|
||||||
|
@ -33,7 +33,8 @@
|
|||||||
|
|
||||||
static id apple_platform;
|
static id apple_platform;
|
||||||
|
|
||||||
void *get_chosen_screen(void);
|
extern void *get_chosen_screen(void);
|
||||||
|
extern float get_backing_scale_factor(void)
|
||||||
|
|
||||||
void apple_rarch_exited(void)
|
void apple_rarch_exited(void)
|
||||||
{
|
{
|
||||||
@ -108,25 +109,15 @@ void apple_rarch_exited(void)
|
|||||||
NSPoint pos;
|
NSPoint pos;
|
||||||
NSPoint mouse_pos;
|
NSPoint mouse_pos;
|
||||||
CGFloat backing_scale_factor = 1.0f;
|
CGFloat backing_scale_factor = 1.0f;
|
||||||
|
apple = (cocoa_input_data_t*)input_driver_get_data();
|
||||||
#if __has_feature(objc_arc)
|
float backing_scale_factor = get_backing_scale_factor();
|
||||||
RAScreen *screen = (__bridge RAScreen*)get_chosen_screen();
|
if (!apple || (backing_scale_factor == 0.0)
|
||||||
#else
|
|
||||||
RAScreen *screen = (RAScreen*)get_chosen_screen();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
apple = (cocoa_input_data_t*)input_driver_get_data();
|
|
||||||
if (!apple || !screen)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Relative */
|
/* Relative */
|
||||||
apple->mouse_rel_x = event.deltaX;
|
apple->mouse_rel_x = event.deltaX;
|
||||||
apple->mouse_rel_y = event.deltaY;
|
apple->mouse_rel_y = event.deltaY;
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_10_7
|
|
||||||
backing_scale_factor = screen.backingScaleFactor;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Absolute */
|
/* Absolute */
|
||||||
pos = [[CocoaView get] convertPoint:[event locationInWindow] fromView:nil];
|
pos = [[CocoaView get] convertPoint:[event locationInWindow] fromView:nil];
|
||||||
apple->touches[0].screen_x = pos.x * backing_scale_factor;
|
apple->touches[0].screen_x = pos.x * backing_scale_factor;
|
||||||
|
Loading…
Reference in New Issue
Block a user