From a45c9b6eb4e81b2d1adb271aae409e381596b7ff Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Aug 2019 12:52:40 +0200 Subject: [PATCH] Duplicate aspect ratio code that was being ran twice --- gfx/drivers/ctr_gfx.c | 22 +---------------- gfx/drivers/d3d8.c | 21 ----------------- gfx/drivers/d3d9.c | 21 ----------------- gfx/drivers/dispmanx_gfx.c | 32 +------------------------ gfx/drivers/exynos_gfx.c | 20 ++-------------- gfx/drivers/gl.c | 23 +----------------- gfx/drivers/gl1.c | 23 +----------------- gfx/drivers/gl_core.c | 23 +----------------- gfx/drivers/gx2_gfx.c | 20 ---------------- gfx/drivers/gx_gfx.c | 23 +----------------- gfx/drivers/metal.m | 21 ----------------- gfx/drivers/ps2_gfx.c | 14 ++--------- gfx/drivers/psp1_gfx.c | 23 +++--------------- gfx/drivers/sdl2_gfx.c | 30 ++++------------------- gfx/drivers/sdl_gfx.c | 25 +------------------- gfx/drivers/sunxi_gfx.c | 2 +- gfx/drivers/switch_nx_gfx.c | 47 ++++++++++++++----------------------- gfx/drivers/vita2d_gfx.c | 21 ----------------- gfx/drivers/vulkan.c | 23 +----------------- retroarch.c | 7 +++--- 20 files changed, 42 insertions(+), 399 deletions(-) diff --git a/gfx/drivers/ctr_gfx.c b/gfx/drivers/ctr_gfx.c index af3e432e64..191595ecc3 100644 --- a/gfx/drivers/ctr_gfx.c +++ b/gfx/drivers/ctr_gfx.c @@ -1067,30 +1067,10 @@ static void ctr_set_aspect_ratio(void* data, unsigned aspect_ratio_idx) { ctr_video_t *ctr = (ctr_video_t*)data; - switch (aspect_ratio_idx) - { - case ASPECT_RATIO_SQUARE: - video_driver_set_viewport_square_pixel(); - break; - - case ASPECT_RATIO_CORE: - video_driver_set_viewport_core(); - break; - - case ASPECT_RATIO_CONFIG: - video_driver_set_viewport_config(); - break; - - default: - break; - } - - video_driver_set_aspect_ratio_value(aspectratio_lut[aspect_ratio_idx].value); - if(!ctr) return; - ctr->keep_aspect = true; + ctr->keep_aspect = true; ctr->should_resize = true; } diff --git a/gfx/drivers/d3d8.c b/gfx/drivers/d3d8.c index 9284e1f482..011d01372f 100644 --- a/gfx/drivers/d3d8.c +++ b/gfx/drivers/d3d8.c @@ -1078,27 +1078,6 @@ static void d3d8_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) { d3d8_video_t *d3d = (d3d8_video_t*)data; - switch (aspect_ratio_idx) - { - case ASPECT_RATIO_SQUARE: - video_driver_set_viewport_square_pixel(); - break; - - case ASPECT_RATIO_CORE: - video_driver_set_viewport_core(); - break; - - case ASPECT_RATIO_CONFIG: - video_driver_set_viewport_config(); - break; - - default: - break; - } - - video_driver_set_aspect_ratio_value( - aspectratio_lut[aspect_ratio_idx].value); - if (!d3d) return; diff --git a/gfx/drivers/d3d9.c b/gfx/drivers/d3d9.c index a345844f06..2f35fba975 100644 --- a/gfx/drivers/d3d9.c +++ b/gfx/drivers/d3d9.c @@ -1095,27 +1095,6 @@ static void d3d9_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) { d3d9_video_t *d3d = (d3d9_video_t*)data; - switch (aspect_ratio_idx) - { - case ASPECT_RATIO_SQUARE: - video_driver_set_viewport_square_pixel(); - break; - - case ASPECT_RATIO_CORE: - video_driver_set_viewport_core(); - break; - - case ASPECT_RATIO_CONFIG: - video_driver_set_viewport_config(); - break; - - default: - break; - } - - video_driver_set_aspect_ratio_value( - aspectratio_lut[aspect_ratio_idx].value); - if (!d3d) return; diff --git a/gfx/drivers/dispmanx_gfx.c b/gfx/drivers/dispmanx_gfx.c index ba876537d1..bf511439fa 100644 --- a/gfx/drivers/dispmanx_gfx.c +++ b/gfx/drivers/dispmanx_gfx.c @@ -586,36 +586,6 @@ static bool dispmanx_gfx_set_shader(void *data, return false; } -static void dispmanx_set_aspect_ratio (void *data, unsigned aspect_ratio_idx) -{ - /* Due to RetroArch setting the data pointer to NULL internally - * on core change, data is going to be NULL here after we load - * a new core from the GUI, so we can't count on accessing it - * to store the aspect ratio we are going to use, so we tell RA - * to keep track of the new aspect ratio and we get it in gfx_frame() - * with video_driver_get_aspect_ratio() to find out if it has changed. */ - - switch (aspect_ratio_idx) - { - case ASPECT_RATIO_SQUARE: - video_driver_set_viewport_square_pixel(); - break; - - case ASPECT_RATIO_CORE: - video_driver_set_viewport_core(); - break; - - case ASPECT_RATIO_CONFIG: - video_driver_set_viewport_config(); - break; - - default: - break; - } - - video_driver_set_aspect_ratio_value(aspectratio_lut[aspect_ratio_idx].value); -} - static uint32_t dispmanx_get_flags(void *data) { uint32_t flags = 0; @@ -635,7 +605,7 @@ static const video_poke_interface_t dispmanx_poke_interface = { NULL, /* get_video_output_next */ NULL, /* get_current_framebuffer */ NULL, /* get_proc_address */ - dispmanx_set_aspect_ratio, + NULL, /* set_aspect_ratio */ NULL, /* dispmanx_apply_state_changes */ dispmanx_set_texture_frame, dispmanx_set_texture_enable, diff --git a/gfx/drivers/exynos_gfx.c b/gfx/drivers/exynos_gfx.c index d184d64fac..6213cec92a 100644 --- a/gfx/drivers/exynos_gfx.c +++ b/gfx/drivers/exynos_gfx.c @@ -1408,25 +1408,9 @@ static void exynos_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) { struct exynos_video *vid = (struct exynos_video*)data; - switch (aspect_ratio_idx) - { - case ASPECT_RATIO_SQUARE: - video_driver_set_viewport_square_pixel(); - break; + if (!vid) + return; - case ASPECT_RATIO_CORE: - video_driver_set_viewport_core(); - break; - - case ASPECT_RATIO_CONFIG: - video_driver_set_viewport_config(); - break; - - default: - break; - } - - video_driver_set_aspect_ratio_value(aspectratio_lut[aspect_ratio_idx].value); vid->aspect_changed = true; } diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index f04a6e0331..6047b0dcc6 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -4379,31 +4379,10 @@ static void gl2_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) { gl_t *gl = (gl_t*)data; - switch (aspect_ratio_idx) - { - case ASPECT_RATIO_SQUARE: - video_driver_set_viewport_square_pixel(); - break; - - case ASPECT_RATIO_CORE: - video_driver_set_viewport_core(); - break; - - case ASPECT_RATIO_CONFIG: - video_driver_set_viewport_config(); - break; - - default: - break; - } - - video_driver_set_aspect_ratio_value( - aspectratio_lut[aspect_ratio_idx].value); - if (!gl) return; - gl->keep_aspect = true; + gl->keep_aspect = true; gl->should_resize = true; } diff --git a/gfx/drivers/gl1.c b/gfx/drivers/gl1.c index 2a8f3121df..bc56790819 100644 --- a/gfx/drivers/gl1.c +++ b/gfx/drivers/gl1.c @@ -1275,31 +1275,10 @@ static void gl1_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) { gl1_t *gl1 = (gl1_t*)data; - switch (aspect_ratio_idx) - { - case ASPECT_RATIO_SQUARE: - video_driver_set_viewport_square_pixel(); - break; - - case ASPECT_RATIO_CORE: - video_driver_set_viewport_core(); - break; - - case ASPECT_RATIO_CONFIG: - video_driver_set_viewport_config(); - break; - - default: - break; - } - - video_driver_set_aspect_ratio_value( - aspectratio_lut[aspect_ratio_idx].value); - if (!gl1) return; - gl1->keep_aspect = true; + gl1->keep_aspect = true; gl1->should_resize = true; } diff --git a/gfx/drivers/gl_core.c b/gfx/drivers/gl_core.c index 89920c6b01..f26c02bd5f 100644 --- a/gfx/drivers/gl_core.c +++ b/gfx/drivers/gl_core.c @@ -1771,31 +1771,10 @@ static void gl_core_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) { gl_core_t *gl = (gl_core_t*)data; - switch (aspect_ratio_idx) - { - case ASPECT_RATIO_SQUARE: - video_driver_set_viewport_square_pixel(); - break; - - case ASPECT_RATIO_CORE: - video_driver_set_viewport_core(); - break; - - case ASPECT_RATIO_CONFIG: - video_driver_set_viewport_config(); - break; - - default: - break; - } - - video_driver_set_aspect_ratio_value( - aspectratio_lut[aspect_ratio_idx].value); - if (!gl) return; - gl->keep_aspect = true; + gl->keep_aspect = true; gl->should_resize = true; } diff --git a/gfx/drivers/gx2_gfx.c b/gfx/drivers/gx2_gfx.c index ae0922a5fa..a43b285d3b 100644 --- a/gfx/drivers/gx2_gfx.c +++ b/gfx/drivers/gx2_gfx.c @@ -173,26 +173,6 @@ static void wiiu_gfx_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) { wiiu_video_t *wiiu = (wiiu_video_t *)data; - switch (aspect_ratio_idx) - { - case ASPECT_RATIO_SQUARE: - video_driver_set_viewport_square_pixel(); - break; - - case ASPECT_RATIO_CORE: - video_driver_set_viewport_core(); - break; - - case ASPECT_RATIO_CONFIG: - video_driver_set_viewport_config(); - break; - - default: - break; - } - - video_driver_set_aspect_ratio_value(aspectratio_lut[aspect_ratio_idx].value); - if (!wiiu) return; diff --git a/gfx/drivers/gx_gfx.c b/gfx/drivers/gx_gfx.c index b9890bc530..23bac324e3 100644 --- a/gfx/drivers/gx_gfx.c +++ b/gfx/drivers/gx_gfx.c @@ -562,31 +562,10 @@ static void gx_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) { gx_video_t *gx = (gx_video_t*)data; - switch (aspect_ratio_idx) - { - case ASPECT_RATIO_SQUARE: - video_driver_set_viewport_square_pixel(); - break; - - case ASPECT_RATIO_CORE: - video_driver_set_viewport_core(); - break; - - case ASPECT_RATIO_CONFIG: - video_driver_set_viewport_config(); - break; - - default: - break; - } - - video_driver_set_aspect_ratio_value( - aspectratio_lut[aspect_ratio_idx].value); - if (!gx) return; - gx->keep_aspect = true; + gx->keep_aspect = true; gx->should_resize = true; } diff --git a/gfx/drivers/metal.m b/gfx/drivers/metal.m index dc75c9ff1b..942e625fa7 100644 --- a/gfx/drivers/metal.m +++ b/gfx/drivers/metal.m @@ -244,27 +244,6 @@ static void metal_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) { MetalDriver *md = (__bridge MetalDriver *)data; - switch (aspect_ratio_idx) - { - case ASPECT_RATIO_SQUARE: - video_driver_set_viewport_square_pixel(); - break; - - case ASPECT_RATIO_CORE: - video_driver_set_viewport_core(); - break; - - case ASPECT_RATIO_CONFIG: - video_driver_set_viewport_config(); - break; - - default: - break; - } - - video_driver_set_aspect_ratio_value( - aspectratio_lut[aspect_ratio_idx].value); - md.keepAspect = YES; [md setNeedsResize]; } diff --git a/gfx/drivers/ps2_gfx.c b/gfx/drivers/ps2_gfx.c index b6606e5e03..32949824ee 100644 --- a/gfx/drivers/ps2_gfx.c +++ b/gfx/drivers/ps2_gfx.c @@ -391,16 +391,6 @@ static void ps2_set_filtering(void *data, unsigned index, bool smooth) ps2->menu_filter = smooth ? GS_FILTER_LINEAR : GS_FILTER_NEAREST; } -static void ps2_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) -{ - ps2_video_t *ps2 = (ps2_video_t*)data; -} - -static void ps2_apply_state_changes(void *data) -{ - ps2_video_t *ps2 = (ps2_video_t*)data; -} - static void ps2_set_texture_frame(void *data, const void *frame, bool rgb32, unsigned width, unsigned height, float alpha) { @@ -458,8 +448,8 @@ static const video_poke_interface_t ps2_poke_interface = { NULL, /* get_video_output_next */ NULL, /* get_current_framebuffer */ NULL, /* get_proc_address */ - ps2_set_aspect_ratio, - ps2_apply_state_changes, + NULL, /* set_aspect_ratio */ + NULL, /* apply_state_changes */ ps2_set_texture_frame, ps2_set_texture_enable, ps2_set_osd_msg, /* set_osd_msg */ diff --git a/gfx/drivers/psp1_gfx.c b/gfx/drivers/psp1_gfx.c index d5bd04edc2..132b91afb3 100644 --- a/gfx/drivers/psp1_gfx.c +++ b/gfx/drivers/psp1_gfx.c @@ -790,27 +790,10 @@ static void psp_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) { psp1_video_t *psp = (psp1_video_t*)data; - switch (aspect_ratio_idx) - { - case ASPECT_RATIO_SQUARE: - video_driver_set_viewport_square_pixel(); - break; + if (!psp) + return; - case ASPECT_RATIO_CORE: - video_driver_set_viewport_core(); - break; - - case ASPECT_RATIO_CONFIG: - video_driver_set_viewport_config(); - break; - - default: - break; - } - - video_driver_set_aspect_ratio_value(aspectratio_lut[aspect_ratio_idx].value); - - psp->keep_aspect = true; + psp->keep_aspect = true; psp->should_resize = true; } diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index 3112bf2be1..7d4867b802 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -642,32 +642,12 @@ static void sdl2_poke_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) { sdl2_video_t *vid = (sdl2_video_t*)data; - switch (aspect_ratio_idx) - { - case ASPECT_RATIO_SQUARE: - video_driver_set_viewport_square_pixel(); - break; - - case ASPECT_RATIO_CORE: - video_driver_set_viewport_core(); - break; - - case ASPECT_RATIO_CONFIG: - video_driver_set_viewport_config(); - break; - - default: - break; - } - - video_driver_set_aspect_ratio_value(aspectratio_lut[aspect_ratio_idx].value); - /* FIXME: Why is vid NULL here when starting content? */ - if (vid) - { - vid->video.force_aspect = true; - vid->should_resize = true; - } + if (!vid) + return; + + vid->video.force_aspect = true; + vid->should_resize = true; } static void sdl2_poke_apply_state_changes(void *data) diff --git a/gfx/drivers/sdl_gfx.c b/gfx/drivers/sdl_gfx.c index 899bb76196..49b06e5707 100644 --- a/gfx/drivers/sdl_gfx.c +++ b/gfx/drivers/sdl_gfx.c @@ -442,29 +442,6 @@ static void sdl_set_filtering(void *data, unsigned index, bool smooth) vid->scaler.scaler_type = smooth ? SCALER_TYPE_BILINEAR : SCALER_TYPE_POINT; } -static void sdl_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) -{ - switch (aspect_ratio_idx) - { - case ASPECT_RATIO_SQUARE: - video_driver_set_viewport_square_pixel(); - break; - - case ASPECT_RATIO_CORE: - video_driver_set_viewport_core(); - break; - - case ASPECT_RATIO_CONFIG: - video_driver_set_viewport_config(); - break; - - default: - break; - } - - video_driver_set_aspect_ratio_value(aspectratio_lut[aspect_ratio_idx].value); -} - static void sdl_apply_state_changes(void *data) { (void)data; @@ -539,7 +516,7 @@ static const video_poke_interface_t sdl_poke_interface = { NULL, /* get_video_output_next */ NULL, /* get_current_framebuffer */ NULL, /* get_proc_address */ - sdl_set_aspect_ratio, + NULL, sdl_apply_state_changes, sdl_set_texture_frame, sdl_set_texture_enable, diff --git a/gfx/drivers/sunxi_gfx.c b/gfx/drivers/sunxi_gfx.c index 335362ff22..50e50ca507 100644 --- a/gfx/drivers/sunxi_gfx.c +++ b/gfx/drivers/sunxi_gfx.c @@ -916,7 +916,7 @@ static void sunxi_set_texture_frame(void *data, const void *frame, bool rgb32, } } -static void sunxi_set_aspect_ratio (void *data, unsigned aspect_ratio_idx) +static void sunxi_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) { struct sunxi_video *_dispvars = (struct sunxi_video*)data; float new_aspect = aspectratio_lut[aspect_ratio_idx].value; diff --git a/gfx/drivers/switch_nx_gfx.c b/gfx/drivers/switch_nx_gfx.c index 9047fe4288..13e9ee2051 100644 --- a/gfx/drivers/switch_nx_gfx.c +++ b/gfx/drivers/switch_nx_gfx.c @@ -319,46 +319,35 @@ static void switch_update_viewport(switch_video_t *sw, static void switch_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) { - switch_video_t *sw = (switch_video_t *)data; + settings_t *settings = config_get_ptr(); + switch_video_t *sw = (switch_video_t *)data; if (!sw) return; - sw->keep_aspect = true; - sw->o_size = false; - - settings_t *settings = config_get_ptr(); + sw->keep_aspect = true; + sw->o_size = false; switch (aspect_ratio_idx) { - case ASPECT_RATIO_SQUARE: - video_driver_set_viewport_square_pixel(); - break; + case ASPECT_RATIO_CORE: + sw->o_size = true; + sw->keep_aspect = false; + break; - case ASPECT_RATIO_CORE: - video_driver_set_viewport_core(); - sw->o_size = true; - sw->keep_aspect = false; - break; + case ASPECT_RATIO_CUSTOM: + if (settings->bools.video_scale_integer) + { + video_driver_set_viewport_core(); + sw->o_size = true; + sw->keep_aspect = false; + } + break; - case ASPECT_RATIO_CONFIG: - video_driver_set_viewport_config(); - break; - - case ASPECT_RATIO_CUSTOM: - if (settings->bools.video_scale_integer) - { - video_driver_set_viewport_core(); - sw->o_size = true; - sw->keep_aspect = false; - } - break; - - default: - break; + default: + break; } - video_driver_set_aspect_ratio_value(aspectratio_lut[aspect_ratio_idx].value); sw->should_resize = true; } diff --git a/gfx/drivers/vita2d_gfx.c b/gfx/drivers/vita2d_gfx.c index 6eaf2c6a7c..ef08acc75d 100644 --- a/gfx/drivers/vita2d_gfx.c +++ b/gfx/drivers/vita2d_gfx.c @@ -582,27 +582,6 @@ static void vita_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) { vita_video_t *vita = (vita_video_t*)data; - switch (aspect_ratio_idx) - { - case ASPECT_RATIO_SQUARE: - video_driver_set_viewport_square_pixel(); - break; - - case ASPECT_RATIO_CORE: - video_driver_set_viewport_core(); - break; - - case ASPECT_RATIO_CONFIG: - video_driver_set_viewport_config(); - break; - - default: - break; - } - - video_driver_set_aspect_ratio_value( - aspectratio_lut[aspect_ratio_idx].value); - if (!vita) return; vita->keep_aspect = true; diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index 95001c3f21..89785b1b16 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -2127,31 +2127,10 @@ static void vulkan_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) { vk_t *vk = (vk_t*)data; - switch (aspect_ratio_idx) - { - case ASPECT_RATIO_SQUARE: - video_driver_set_viewport_square_pixel(); - break; - - case ASPECT_RATIO_CORE: - video_driver_set_viewport_core(); - break; - - case ASPECT_RATIO_CONFIG: - video_driver_set_viewport_config(); - break; - - default: - break; - } - - video_driver_set_aspect_ratio_value( - aspectratio_lut[aspect_ratio_idx].value); - if (!vk) return; - vk->keep_aspect = true; + vk->keep_aspect = true; vk->should_resize = true; } diff --git a/retroarch.c b/retroarch.c index c38d50fd4b..a1637370b1 100644 --- a/retroarch.c +++ b/retroarch.c @@ -17492,10 +17492,9 @@ void video_driver_set_aspect_ratio(void) video_driver_set_aspect_ratio_value( aspectratio_lut[aspect_ratio_idx].value); - if (!video_driver_poke || !video_driver_poke->set_aspect_ratio) - return; - video_driver_poke->set_aspect_ratio( - video_driver_data, aspect_ratio_idx); + if (video_driver_poke && video_driver_poke->set_aspect_ratio) + video_driver_poke->set_aspect_ratio( + video_driver_data, aspect_ratio_idx); } void video_driver_update_viewport(