Refactor aspect_ratio member.

Mutate in g_extern.system.aspect_ratio to avoid
getting wrong aspect ratio on reentrancy.
This commit is contained in:
Themaister 2013-03-17 22:05:15 +01:00
parent aa24755956
commit 51b5a2df5c
9 changed files with 22 additions and 19 deletions

View File

@ -787,14 +787,16 @@ void init_video_input(void)
if (g_extern.filter.active)
scale = g_extern.filter.scale;
if (g_settings.video.aspect_ratio < 0.0f)
g_extern.system.aspect_ratio = g_settings.video.aspect_ratio;
if (g_extern.system.aspect_ratio < 0.0f)
{
if (geom->aspect_ratio > 0.0f && g_settings.video.aspect_ratio_auto)
g_settings.video.aspect_ratio = geom->aspect_ratio;
g_extern.system.aspect_ratio = geom->aspect_ratio;
else
g_settings.video.aspect_ratio = (float)geom->base_width / geom->base_height; // 1:1 PAR.
g_extern.system.aspect_ratio = (float)geom->base_width / geom->base_height; // 1:1 PAR.
RARCH_LOG("Adjusting aspect ratio to %.2f\n", g_settings.video.aspect_ratio);
RARCH_LOG("Adjusting aspect ratio to %.2f\n", g_extern.system.aspect_ratio);
}
unsigned width;
@ -808,7 +810,7 @@ void init_video_input(void)
{
if (g_settings.video.force_aspect)
{
width = roundf(geom->base_height * g_settings.video.xscale * g_settings.video.aspect_ratio);
width = roundf(geom->base_height * g_settings.video.xscale * g_extern.system.aspect_ratio);
height = roundf(geom->base_height * g_settings.video.yscale);
}
else

View File

@ -374,6 +374,7 @@ struct global
{
struct retro_system_info info;
struct retro_system_av_info av_info;
float aspect_ratio;
char *environment;
char *environment_split;

View File

@ -193,7 +193,7 @@ void D3DVideo::init(const video_info_t &info)
}
}
calculate_rect(screen_width, screen_height, info.force_aspect, g_settings.video.aspect_ratio);
calculate_rect(screen_width, screen_height, info.force_aspect, g_extern.system.aspect_ratio);
#ifdef HAVE_CG
if (!init_cg())

View File

@ -711,11 +711,11 @@ void gl_set_viewport(void *data, unsigned width, unsigned height, bool force_ful
if (g_settings.video.scale_integer && !force_full)
{
gfx_scale_integer(&gl->vp, width, height, g_settings.video.aspect_ratio, gl->keep_aspect);
gfx_scale_integer(&gl->vp, width, height, g_extern.system.aspect_ratio, gl->keep_aspect);
}
else if (gl->keep_aspect && !force_full)
{
float desired_aspect = g_settings.video.aspect_ratio;
float desired_aspect = g_extern.system.aspect_ratio;
float delta;
#ifdef HAVE_RGUI
@ -2293,7 +2293,7 @@ static void gl_set_aspect_ratio(void *data, unsigned aspectratio_index)
else if (g_settings.video.aspect_ratio_idx == ASPECT_RATIO_CORE)
gfx_set_core_viewport();
g_settings.video.aspect_ratio = aspectratio_lut[g_settings.video.aspect_ratio_idx].value;
g_extern.system.aspect_ratio = aspectratio_lut[g_settings.video.aspect_ratio_idx].value;
g_settings.video.force_aspect = false;
gl->keep_aspect = true;

View File

@ -279,7 +279,7 @@ static void vg_calculate_quad(vg_t *vg)
// set viewport for aspect ratio, taken from the OpenGL driver
if (vg->mKeepAspect)
{
float desired_aspect = g_settings.video.aspect_ratio;
float desired_aspect = g_extern.system.aspect_ratio;
// If the aspect ratios of screen and desired aspect ratio are sufficiently equal (floating point stuff),
// assume they are actually equal.

View File

@ -538,7 +538,7 @@ static void calc_out_rect(bool keep_aspect, struct rarch_viewport *vp, unsigned
if (g_settings.video.scale_integer)
{
gfx_scale_integer(vp, vp_width, vp_height, g_settings.video.aspect_ratio, keep_aspect);
gfx_scale_integer(vp, vp_width, vp_height, g_extern.system.aspect_ratio, keep_aspect);
}
else if (!keep_aspect)
{
@ -548,7 +548,7 @@ static void calc_out_rect(bool keep_aspect, struct rarch_viewport *vp, unsigned
}
else
{
float desired_aspect = g_settings.video.aspect_ratio;
float desired_aspect = g_extern.system.aspect_ratio;
float device_aspect = (float)vp_width / vp_height;
// If the aspect ratios of screen and desired aspect ratio are sufficiently equal (floating point stuff),

View File

@ -279,7 +279,7 @@ static void gx_set_aspect_ratio(void *data, unsigned aspectratio_idx)
else if(g_settings.video.aspect_ratio_idx == ASPECT_RATIO_CORE)
gfx_set_core_viewport();
g_settings.video.aspect_ratio = aspectratio_lut[g_settings.video.aspect_ratio_idx].value;
g_extern.system.aspect_ratio = aspectratio_lut[g_settings.video.aspect_ratio_idx].value;
g_settings.video.force_aspect = false;
gx->keep_aspect = true;
gx->should_resize = true;
@ -700,7 +700,7 @@ static void gx_resize(void *data)
if (gx->keep_aspect && gx_mode.efbHeight >= 480) // ingore this for custom resolutions
{
float desired_aspect = g_settings.video.aspect_ratio;
float desired_aspect = g_extern.system.aspect_ratio;
if (desired_aspect == 0.0)
desired_aspect = 1.0;
#ifdef HW_RVL

View File

@ -1326,8 +1326,8 @@ static void init_recording(void)
params.fb_width = next_pow2(vp.width);
params.fb_height = next_pow2(vp.height);
if (g_settings.video.force_aspect && (g_settings.video.aspect_ratio > 0.0f))
params.aspect_ratio = g_settings.video.aspect_ratio;
if (g_settings.video.force_aspect && (g_extern.system.aspect_ratio > 0.0f))
params.aspect_ratio = g_extern.system.aspect_ratio;
else
params.aspect_ratio = (float)vp.width / vp.height;
@ -1354,8 +1354,8 @@ static void init_recording(void)
params.out_height = g_extern.record_height;
}
if (g_settings.video.force_aspect && (g_settings.video.aspect_ratio > 0.0f))
params.aspect_ratio = g_settings.video.aspect_ratio;
if (g_settings.video.force_aspect && (g_extern.system.aspect_ratio > 0.0f))
params.aspect_ratio = g_extern.system.aspect_ratio;
else
params.aspect_ratio = (float)params.out_width / params.out_height;

View File

@ -1196,7 +1196,7 @@ bool config_save_file(const char *path)
config_set_bool(conf, "rewind_enable", g_settings.rewind_enable);
config_set_int(conf, "rewind_granularity", g_settings.rewind_granularity);
config_set_string(conf, "video_cg_shader", g_settings.video.cg_shader_path);
config_set_float(conf, "video_aspect_ratio", g_settings.video.aspect_ratio);
config_set_float(conf, "video_aspect_ratio", g_extern.system.aspect_ratio);
#ifdef HAVE_FBO
config_set_float(conf, "video_fbo_scale_x", g_settings.video.fbo.scale_x);
config_set_float(conf, "video_fbo_scale_y", g_settings.video.fbo.scale_y);