From 2f62cd65e2ddbba54bccff3da7cae5bf19b5b6ac Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2015 19:12:27 +0200 Subject: [PATCH] Start using video_viewport_get_custom everywhere --- configuration.c | 14 ++++++-------- gfx/d3d/d3d.cpp | 5 ++--- gfx/drivers/gx_gfx.c | 25 +++++++++++-------------- gfx/drivers/psp1_gfx.c | 3 +-- gfx/drivers/sdl2_gfx.c | 2 +- gfx/video_driver.c | 2 +- gfx/video_viewport.c | 12 ++++++++++++ gfx/video_viewport.h | 2 ++ menu/menu_entries_cbs_ok.c | 3 +-- settings.c | 9 +++++---- 10 files changed, 42 insertions(+), 35 deletions(-) diff --git a/configuration.c b/configuration.c index 92ebbf5ea1..95d874b06f 100644 --- a/configuration.c +++ b/configuration.c @@ -633,10 +633,7 @@ static void config_set_defaults(void) settings->core.set_supports_no_game_enable = true; - global->console.screen.viewports.custom_vp.width = 0; - global->console.screen.viewports.custom_vp.height = 0; - global->console.screen.viewports.custom_vp.x = 0; - global->console.screen.viewports.custom_vp.y = 0; + video_viewport_reset_custom(); /* Make sure settings from other configs carry over into defaults * for another config. */ @@ -2232,6 +2229,7 @@ bool config_save_file(const char *path) config_file_t *conf = config_file_new(path); settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); + video_viewport_t *custom_vp = video_viewport_get_custom(); if (!conf) conf = config_file_new(NULL); @@ -2473,13 +2471,13 @@ bool config_save_file(const char *path) config_set_int(conf, "current_resolution_id", global->console.screen.resolutions.current.id); config_set_int(conf, "custom_viewport_width", - global->console.screen.viewports.custom_vp.width); + custom_vp->width); config_set_int(conf, "custom_viewport_height", - global->console.screen.viewports.custom_vp.height); + custom_vp->height); config_set_int(conf, "custom_viewport_x", - global->console.screen.viewports.custom_vp.x); + custom_vp->x); config_set_int(conf, "custom_viewport_y", - global->console.screen.viewports.custom_vp.y); + custom_vp->y); config_set_float(conf, "video_font_size", settings->video.font_size); config_set_bool(conf, "block_sram_overwrite", diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 8f7a3dd5ee..7a75c3899f 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -431,10 +431,9 @@ static void d3d_calculate_rect(d3d_video_t *d3d, { if (settings->video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM) { - const video_viewport_t *custom = - &global->console.screen.viewports.custom_vp; + video_viewport_t *custom = video_viewport_get_custom(); - if (custom) + if (custom) d3d_set_viewport(d3d, custom->x, custom->y, custom->width, custom->height); } diff --git a/gfx/drivers/gx_gfx.c b/gfx/drivers/gx_gfx.c index d98c85d3b9..2b4b7c5d86 100644 --- a/gfx/drivers/gx_gfx.c +++ b/gfx/drivers/gx_gfx.c @@ -424,10 +424,7 @@ static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines, } /* custom viewports for older resolutions will most likely be corrupted, reset them */ - global->console.screen.viewports.custom_vp.x = 0; - global->console.screen.viewports.custom_vp.y = 0; - global->console.screen.viewports.custom_vp.width = 0; - global->console.screen.viewports.custom_vp.height = 0; + video_viewport_reset_custom(); g_current_framebuf = 0; } @@ -838,6 +835,7 @@ static void gx_resize(void *data) unsigned width = gx->vp.full_width, height = gx->vp.full_height; settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); + struct video_viewport *custom_vp = video_viewport_get_custom(); #ifdef HW_RVL VIDEO_SetTrapFilter(global->console.softfilter_enable); @@ -863,19 +861,18 @@ static void gx_resize(void *data) #ifdef RARCH_CONSOLE if (settings->video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM) { - if (!global->console.screen.viewports.custom_vp.width || - !global->console.screen.viewports.custom_vp.height) + if (!custom_vp->width || !custom_vp->height) { - global->console.screen.viewports.custom_vp.x = 0; - global->console.screen.viewports.custom_vp.y = 0; - global->console.screen.viewports.custom_vp.width = gx->vp.full_width; - global->console.screen.viewports.custom_vp.height = gx->vp.full_height; + custom_vp->x = 0; + custom_vp->y = 0; + custom_vp->width = gx->vp.full_width; + custom_vp->height = gx->vp.full_height; } - x = global->console.screen.viewports.custom_vp.x; - y = global->console.screen.viewports.custom_vp.y; - width = global->console.screen.viewports.custom_vp.width; - height = global->console.screen.viewports.custom_vp.height; + x = custom_vp->x; + y = custom_vp->y; + width = custom_vp->width; + height = custom_vp->height; } else #endif diff --git a/gfx/drivers/psp1_gfx.c b/gfx/drivers/psp1_gfx.c index 8aa8e44251..67a69fed90 100644 --- a/gfx/drivers/psp1_gfx.c +++ b/gfx/drivers/psp1_gfx.c @@ -715,8 +715,7 @@ static void psp_update_viewport(psp1_video_t* psp) #if defined(HAVE_MENU) if (settings->video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM) { - const struct video_viewport *custom = - &global->console.screen.viewports.custom_vp; + struct video_viewport *custom = video_viewport_get_custom(); if (custom) { diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index 75a17f00ed..5b7b2e111a 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -278,7 +278,7 @@ static void sdl_refresh_viewport(sdl2_video_t *vid) vid->video.force_aspect); else if (settings->video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM) { - const struct video_viewport *custom = &global->console.screen.viewports.custom_vp; + const struct video_viewport *custom = (const struct video_viewport*)video_viewport_get_custom(); if (custom) { diff --git a/gfx/video_driver.c b/gfx/video_driver.c index d89b682540..549122a346 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -497,7 +497,7 @@ void init_video(void) video_viewport_set_config(); /* Update CUSTOM viewport. */ - custom_vp = &global->console.screen.viewports.custom_vp; + custom_vp = video_viewport_get_custom(); if (settings->video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM) { diff --git a/gfx/video_viewport.c b/gfx/video_viewport.c index 3ac9cd0b8a..9fff5d858b 100644 --- a/gfx/video_viewport.c +++ b/gfx/video_viewport.c @@ -234,3 +234,15 @@ struct video_viewport *video_viewport_get_custom(void) return NULL; return &global->console.screen.viewports.custom_vp; } + +void video_viewport_reset_custom(void) +{ + struct video_viewport *custom_vp = video_viewport_get_custom(); + if (!custom_vp) + return; + + custom_vp->width = 0; + custom_vp->height = 0; + custom_vp->x = 0; + custom_vp->y = 0; +} diff --git a/gfx/video_viewport.h b/gfx/video_viewport.h index 2b3b26bb39..e97cb1d011 100644 --- a/gfx/video_viewport.h +++ b/gfx/video_viewport.h @@ -139,6 +139,8 @@ void video_viewport_get_scaled_integer(struct video_viewport *vp, struct retro_system_av_info *video_viewport_get_system_av_info(void); +void video_viewport_reset_custom(void); + struct video_viewport *video_viewport_get_custom(void); #ifdef __cplusplus diff --git a/menu/menu_entries_cbs_ok.c b/menu/menu_entries_cbs_ok.c index 0ab8613d62..f5549c1fd1 100644 --- a/menu/menu_entries_cbs_ok.c +++ b/menu/menu_entries_cbs_ok.c @@ -1037,8 +1037,7 @@ static int action_ok_custom_viewport(const char *path, { menu_displaylist_info_t info = {0}; int ret = 0; - global_t *global = global_get_ptr(); - video_viewport_t *custom = &global->console.screen.viewports.custom_vp; + video_viewport_t *custom = video_viewport_get_custom(); menu_handle_t *menu = menu_driver_get_ptr(); settings_t *settings = config_get_ptr(); diff --git a/settings.c b/settings.c index 8cd5cfb835..c21a7cf79d 100644 --- a/settings.c +++ b/settings.c @@ -4022,6 +4022,7 @@ static bool setting_append_list_video_options( rarch_setting_group_info_t subgroup_info; settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); + video_viewport_t *custom_vp = video_viewport_get_custom(); START_GROUP(group_info, "Video Settings"); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); @@ -4254,7 +4255,7 @@ static bool setting_append_list_video_options( general_read_handler); CONFIG_INT( - global->console.screen.viewports.custom_vp.x, + custom_vp->x, "custom_viewport_x", "Custom Viewport X", 0, @@ -4265,7 +4266,7 @@ static bool setting_append_list_video_options( settings_data_list_current_add_flags(list, list_info, SD_FLAG_ADVANCED); CONFIG_INT( - global->console.screen.viewports.custom_vp.y, + custom_vp->y, "custom_viewport_y", "Custom Viewport Y", 0, @@ -4276,7 +4277,7 @@ static bool setting_append_list_video_options( settings_data_list_current_add_flags(list, list_info, SD_FLAG_ADVANCED); CONFIG_UINT( - global->console.screen.viewports.custom_vp.width, + custom_vp->width, "custom_viewport_width", "Custom Viewport Width", 0, @@ -4287,7 +4288,7 @@ static bool setting_append_list_video_options( settings_data_list_current_add_flags(list, list_info, SD_FLAG_ADVANCED); CONFIG_UINT( - global->console.screen.viewports.custom_vp.height, + custom_vp->height, "custom_viewport_height", "Custom Viewport Height", 0,