mirror of
https://github.com/libretro/RetroArch
synced 2025-01-29 09:32:52 +00:00
Create video_driver_set_aspect_ratio_value and video_driver_get_aspect_ratio
This commit is contained in:
parent
52e8d582c0
commit
b255b5a325
@ -332,7 +332,7 @@ static bool d3d_initialize(d3d_video_t *d3d, const video_info_t *info)
|
||||
video_driver_get_size(&width, &height);
|
||||
|
||||
d3d_calculate_rect(d3d,
|
||||
width, height, info->force_aspect, global->system.aspect_ratio);
|
||||
width, height, info->force_aspect, video_driver_get_aspect_ratio());
|
||||
|
||||
if (!d3d_init_chain(d3d, info))
|
||||
{
|
||||
@ -540,7 +540,7 @@ static void d3d_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
|
||||
break;
|
||||
}
|
||||
|
||||
global->system.aspect_ratio = aspectratio_lut[aspect_ratio_idx].value;
|
||||
video_driver_set_aspect_ratio_value(aspectratio_lut[aspect_ratio_idx].value);
|
||||
|
||||
if (!d3d)
|
||||
return;
|
||||
@ -1663,7 +1663,7 @@ static bool d3d_frame(void *data, const void *frame,
|
||||
if (d3d->should_resize)
|
||||
{
|
||||
d3d_calculate_rect(d3d, width, width, d3d->video_info.force_aspect,
|
||||
global->system.aspect_ratio);
|
||||
video_driver_get_aspect_ratio());
|
||||
|
||||
d3d->renderchain_driver->set_final_viewport(d3d,
|
||||
d3d->renderchain_data, &d3d->final_viewport);
|
||||
|
@ -1562,7 +1562,7 @@ static void exynos_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
|
||||
break;
|
||||
}
|
||||
|
||||
global->system.aspect_ratio = aspectratio_lut[aspect_ratio_idx].value;
|
||||
video_driver_set_aspect_ratio_value(aspectratio_lut[aspect_ratio_idx].value);
|
||||
vid->aspect_changed = true;
|
||||
}
|
||||
|
||||
|
@ -793,14 +793,14 @@ static void gl_set_viewport(void *data, unsigned viewport_width,
|
||||
{
|
||||
video_viewport_get_scaled_integer(&gl->vp,
|
||||
viewport_width, viewport_height,
|
||||
global->system.aspect_ratio, gl->keep_aspect);
|
||||
video_driver_get_aspect_ratio(), gl->keep_aspect);
|
||||
viewport_width = gl->vp.width;
|
||||
viewport_height = gl->vp.height;
|
||||
}
|
||||
else if (gl->keep_aspect && !force_full)
|
||||
{
|
||||
float delta;
|
||||
float desired_aspect = global->system.aspect_ratio;
|
||||
float desired_aspect = video_driver_get_aspect_ratio();
|
||||
|
||||
#if defined(HAVE_MENU)
|
||||
if (settings->video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
|
||||
@ -3122,7 +3122,7 @@ static void gl_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
|
||||
break;
|
||||
}
|
||||
|
||||
global->system.aspect_ratio = aspectratio_lut[aspect_ratio_idx].value;
|
||||
video_driver_set_aspect_ratio_value(aspectratio_lut[aspect_ratio_idx].value);
|
||||
|
||||
if (!gl)
|
||||
return;
|
||||
|
@ -447,7 +447,8 @@ static void gx_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
|
||||
else if (aspect_ratio_idx == ASPECT_RATIO_CONFIG)
|
||||
video_viewport_set_config();
|
||||
|
||||
global->system.aspect_ratio = aspectratio_lut[aspect_ratio_idx].value;
|
||||
video_driver_set_aspect_ratio_value(
|
||||
aspectratio_lut[aspect_ratio_idx].value);
|
||||
|
||||
if (!gx)
|
||||
return;
|
||||
@ -845,7 +846,7 @@ static void gx_resize(void *data)
|
||||
|
||||
if (gx->keep_aspect && gx_mode.efbHeight >= 240) /* ignore this for custom resolutions */
|
||||
{
|
||||
float desired_aspect = global->system.aspect_ratio;
|
||||
float desired_aspect = video_driver_get_aspect_ratio();
|
||||
if (desired_aspect == 0.0)
|
||||
desired_aspect = 1.0;
|
||||
#ifdef HW_RVL
|
||||
|
@ -703,14 +703,14 @@ static void psp_update_viewport(psp1_video_t* psp)
|
||||
if (settings->video.scale_integer)
|
||||
{
|
||||
video_viewport_get_scaled_integer(&psp->vp, SCEGU_SCR_WIDTH,
|
||||
SCEGU_SCR_HEIGHT, global->system.aspect_ratio, psp->keep_aspect);
|
||||
SCEGU_SCR_HEIGHT, video_driver_get_aspect_ratio(), psp->keep_aspect);
|
||||
width = psp->vp.width;
|
||||
height = psp->vp.height;
|
||||
}
|
||||
else if (psp->keep_aspect)
|
||||
{
|
||||
float delta;
|
||||
float desired_aspect = global->system.aspect_ratio;
|
||||
float desired_aspect = video_driver_get_aspect_ratio();
|
||||
|
||||
#if defined(HAVE_MENU)
|
||||
if (settings->video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
|
||||
@ -818,7 +818,7 @@ static void psp_set_aspect_ratio(void *data, unsigned aspectratio_index)
|
||||
break;
|
||||
}
|
||||
|
||||
global->system.aspect_ratio = aspectratio_lut[aspectratio_index].value;
|
||||
video_driver_set_aspect_ratio_value(aspectratio_lut[aspectratio_index].value);
|
||||
|
||||
psp->keep_aspect = true;
|
||||
psp->should_resize = true;
|
||||
|
@ -274,7 +274,7 @@ static void sdl_refresh_viewport(sdl2_video_t *vid)
|
||||
vid->vp.full_height = win_h;
|
||||
|
||||
if (settings->video.scale_integer)
|
||||
video_viewport_get_scaled_integer(&vid->vp, win_w, win_h, global->system.aspect_ratio,
|
||||
video_viewport_get_scaled_integer(&vid->vp, win_w, win_h, video_driver_get_aspect_ratio(),
|
||||
vid->video.force_aspect);
|
||||
else if (settings->video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
|
||||
{
|
||||
@ -292,7 +292,7 @@ static void sdl_refresh_viewport(sdl2_video_t *vid)
|
||||
{
|
||||
float delta;
|
||||
float device_aspect = (float)win_w / win_h;
|
||||
float desired_aspect = global->system.aspect_ratio;
|
||||
float desired_aspect = video_driver_get_aspect_ratio();
|
||||
|
||||
if (fabsf(device_aspect - desired_aspect) < 0.0001f)
|
||||
{
|
||||
@ -660,7 +660,8 @@ static void sdl2_poke_set_aspect_ratio(void *data, unsigned aspectratio_index)
|
||||
break;
|
||||
}
|
||||
|
||||
global->system.aspect_ratio = aspectratio_lut[aspectratio_index].value;
|
||||
video_driver_set_aspect_ratio_value(
|
||||
aspectratio_lut[aspectratio_index].value);
|
||||
|
||||
vid->video.force_aspect = true;
|
||||
vid->should_resize = true;
|
||||
|
@ -467,7 +467,7 @@ static void sdl_set_aspect_ratio(void *data, unsigned aspectratio_index)
|
||||
break;
|
||||
}
|
||||
|
||||
global->system.aspect_ratio = aspectratio_lut[aspectratio_index].value;
|
||||
video_driver_set_aspect_ratio_value(aspectratio_lut[aspectratio_index].value);
|
||||
}
|
||||
|
||||
static void sdl_apply_state_changes(void *data)
|
||||
|
@ -85,7 +85,6 @@ static void *vg_init(const video_info_t *video, const input_driver_t **input, vo
|
||||
VGfloat clearColor[4] = {0, 0, 0, 1};
|
||||
settings_t *settings = config_get_ptr();
|
||||
driver_t *driver = driver_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
const gfx_ctx_driver_t *ctx = NULL;
|
||||
vg_t *vg = (vg_t*)calloc(1, sizeof(vg_t));
|
||||
|
||||
@ -232,14 +231,12 @@ static void vg_free(void *data)
|
||||
static void vg_calculate_quad(vg_t *vg)
|
||||
{
|
||||
unsigned width, height;
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
video_driver_get_size(&width, &height);
|
||||
|
||||
/* set viewport for aspect ratio, taken from the OpenGL driver. */
|
||||
if (vg->mKeepAspect)
|
||||
{
|
||||
float desired_aspect = global->system.aspect_ratio;
|
||||
float desired_aspect = video_driver_get_aspect_ratio();
|
||||
|
||||
/* If the aspect ratios of screen and desired aspect ratio
|
||||
* are sufficiently equal (floating point stuff),
|
||||
@ -318,7 +315,6 @@ static bool vg_frame(void *data, const void *frame,
|
||||
{
|
||||
unsigned width, height;
|
||||
vg_t *vg = (vg_t*)data;
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
RARCH_PERFORMANCE_INIT(vg_fr);
|
||||
RARCH_PERFORMANCE_START(vg_fr);
|
||||
|
@ -358,13 +358,12 @@ static void calc_out_rect(bool keep_aspect, struct video_viewport *vp,
|
||||
unsigned vp_width, unsigned vp_height)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
vp->full_width = vp_width;
|
||||
vp->full_height = vp_height;
|
||||
|
||||
if (settings->video.scale_integer)
|
||||
video_viewport_get_scaled_integer(vp, vp_width, vp_height, global->system.aspect_ratio, keep_aspect);
|
||||
video_viewport_get_scaled_integer(vp, vp_width, vp_height, video_driver_get_aspect_ratio(), keep_aspect);
|
||||
else if (!keep_aspect)
|
||||
{
|
||||
vp->x = 0; vp->y = 0;
|
||||
@ -373,7 +372,7 @@ static void calc_out_rect(bool keep_aspect, struct video_viewport *vp,
|
||||
}
|
||||
else
|
||||
{
|
||||
float desired_aspect = global->system.aspect_ratio;
|
||||
float desired_aspect = video_driver_get_aspect_ratio();
|
||||
float device_aspect = (float)vp_width / vp_height;
|
||||
|
||||
/* If the aspect ratios of screen and desired aspect ratio
|
||||
|
@ -35,6 +35,7 @@ typedef struct video_driver_state
|
||||
|
||||
unsigned video_width;
|
||||
unsigned video_height;
|
||||
float aspect_ratio;
|
||||
} video_driver_state_t;
|
||||
|
||||
static video_driver_state_t video_state;
|
||||
@ -501,8 +502,8 @@ void init_video(void)
|
||||
(float)custom_vp->width / custom_vp->height : default_aspect;
|
||||
}
|
||||
|
||||
global->system.aspect_ratio =
|
||||
aspectratio_lut[settings->video.aspect_ratio_idx].value;
|
||||
video_driver_set_aspect_ratio_value(
|
||||
aspectratio_lut[settings->video.aspect_ratio_idx].value);
|
||||
|
||||
if (settings->video.fullscreen)
|
||||
{
|
||||
@ -514,8 +515,8 @@ void init_video(void)
|
||||
if (settings->video.force_aspect)
|
||||
{
|
||||
/* Do rounding here to simplify integer scale correctness. */
|
||||
unsigned base_width = roundf(geom->base_height *
|
||||
global->system.aspect_ratio);
|
||||
unsigned base_width =
|
||||
roundf(geom->base_height * video_driver_get_aspect_ratio());
|
||||
width = roundf(base_width * settings->video.scale);
|
||||
}
|
||||
else
|
||||
@ -1087,3 +1088,13 @@ void video_monitor_reset(void)
|
||||
{
|
||||
video_state.frame_time_samples_count = 0;
|
||||
}
|
||||
|
||||
float video_driver_get_aspect_ratio(void)
|
||||
{
|
||||
return video_state.aspect_ratio;
|
||||
}
|
||||
|
||||
void video_driver_set_aspect_ratio_value(float value)
|
||||
{
|
||||
video_state.aspect_ratio = value;
|
||||
}
|
||||
|
@ -348,6 +348,10 @@ void video_driver_set_size_height(unsigned width);
|
||||
|
||||
uint64_t video_driver_get_frame_count(void);
|
||||
|
||||
float video_driver_get_aspect_ratio(void);
|
||||
|
||||
void video_driver_set_aspect_ratio_value(float value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -354,8 +354,8 @@ bool recording_init(void)
|
||||
params.fb_height = next_pow2(vp.height);
|
||||
|
||||
if (settings->video.force_aspect &&
|
||||
(global->system.aspect_ratio > 0.0f))
|
||||
params.aspect_ratio = global->system.aspect_ratio;
|
||||
(video_driver_get_aspect_ratio() > 0.0f))
|
||||
params.aspect_ratio = video_driver_get_aspect_ratio();
|
||||
else
|
||||
params.aspect_ratio = (float)vp.width / vp.height;
|
||||
|
||||
@ -382,8 +382,8 @@ bool recording_init(void)
|
||||
}
|
||||
|
||||
if (settings->video.force_aspect &&
|
||||
(global->system.aspect_ratio > 0.0f))
|
||||
params.aspect_ratio = global->system.aspect_ratio;
|
||||
(video_driver_get_aspect_ratio() > 0.0f))
|
||||
params.aspect_ratio = video_driver_get_aspect_ratio();
|
||||
else
|
||||
params.aspect_ratio = (float)params.out_width / params.out_height;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user