Get rid of global dependency for video_viewport_get_custom

This commit is contained in:
twinaphex 2015-05-20 23:13:39 +02:00
parent e04dff82b5
commit 5558fdd085
3 changed files with 22 additions and 19 deletions

View File

@ -1139,10 +1139,12 @@ static bool config_load_file(const char *path, bool set_defaults)
char *save, tmp_str[PATH_MAX_LENGTH];
char tmp_append_path[PATH_MAX_LENGTH]; /* Don't destroy append_config_path. */
const char *extra_path;
int vp_width = 0, vp_height = 0, vp_x = 0, vp_y = 0;
unsigned msg_color = 0;
config_file_t *conf = NULL;
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
video_viewport_t *custom_vp = (video_viewport_t*)video_viewport_get_custom();
if (path)
{
@ -1286,14 +1288,19 @@ static bool config_load_file(const char *path, bool set_defaults)
#endif
CONFIG_GET_INT_BASE(conf, settings, state_slot, "state_slot");
CONFIG_GET_INT_BASE(conf, global, console.screen.viewports.custom_vp.x,
"custom_viewport_x");
CONFIG_GET_INT_BASE(conf, global, console.screen.viewports.custom_vp.y,
"custom_viewport_y");
CONFIG_GET_INT_BASE(conf, global, console.screen.viewports.custom_vp.width,
"custom_viewport_width");
CONFIG_GET_INT_BASE(conf, global, console.screen.viewports.custom_vp.height,
"custom_viewport_height");
config_get_int(conf, "custom_viewport_width", &vp_width);
config_get_int(conf, "custom_viewport_height", &vp_height);
config_get_int(conf, "custom_viewport_x", &vp_x);
config_get_int(conf, "custom_viewport_y", &vp_y);
if (custom_vp)
{
custom_vp->width = vp_width;
custom_vp->height = vp_height;
custom_vp->x = vp_x;
custom_vp->y = vp_y;
}
if (config_get_hex(conf, "video_message_color", &msg_color))
{
@ -2229,7 +2236,8 @@ 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();
const video_viewport_t *custom_vp = (const video_viewport_t*)video_viewport_get_custom();
const video_viewport_t *custom_vp = (const video_viewport_t*)
video_viewport_get_custom();
if (!conf)
conf = config_file_new(NULL);
@ -2478,6 +2486,8 @@ bool config_save_file(const char *path)
custom_vp->x);
config_set_int(conf, "custom_viewport_y",
custom_vp->y);
config_set_float(conf, "video_font_size", settings->video.font_size);
config_set_bool(conf, "block_sram_overwrite",

View File

@ -17,6 +17,8 @@
#include "video_viewport.h"
#include "../general.h"
static video_viewport_t video_viewport_custom;
struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END] = {
{ "4:3", 1.3333f },
{ "16:9", 1.7778f },
@ -229,10 +231,7 @@ struct retro_system_av_info *video_viewport_get_system_av_info(void)
struct video_viewport *video_viewport_get_custom(void)
{
global_t *global = global_get_ptr();
if (!global)
return NULL;
return &global->console.screen.viewports.custom_vp;
return &video_viewport_custom;
}
void video_viewport_reset_custom(void)

View File

@ -289,12 +289,6 @@ typedef struct global
bool check;
} resolutions;
struct
{
video_viewport_t custom_vp;
} viewports;
unsigned gamma_correction;
unsigned char flicker_filter_index;
unsigned char soft_filter_index;