mirror of
https://github.com/libretro/RetroArch
synced 2025-01-29 09:32:52 +00:00
Add SET_VIEWPORT_CONFIG
This commit is contained in:
parent
806c124eae
commit
892d99b3a6
@ -490,25 +490,29 @@ static bool d3d_has_windowed(void *data)
|
||||
static void d3d_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
|
||||
{
|
||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||
enum rarch_display_ctl_state cmd = RARCH_DISPLAY_CTL_NONE;
|
||||
|
||||
switch (aspect_ratio_idx)
|
||||
{
|
||||
case ASPECT_RATIO_SQUARE:
|
||||
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL, NULL);
|
||||
cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL;
|
||||
break;
|
||||
|
||||
case ASPECT_RATIO_CORE:
|
||||
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE, NULL);
|
||||
cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE;
|
||||
break;
|
||||
|
||||
case ASPECT_RATIO_CONFIG:
|
||||
video_viewport_set_config();
|
||||
cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CONFIG;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (cmd != RARCH_DISPLAY_CTL_NONE)
|
||||
video_driver_ctl(cmd, NULL);
|
||||
|
||||
video_driver_set_aspect_ratio_value(aspectratio_lut[aspect_ratio_idx].value);
|
||||
|
||||
if (!d3d)
|
||||
|
@ -769,29 +769,33 @@ static void ctr_set_filtering(void* data, unsigned index, bool smooth)
|
||||
ctr->smooth = smooth;
|
||||
}
|
||||
|
||||
static void ctr_set_aspect_ratio(void* data, unsigned aspectratio_index)
|
||||
static void ctr_set_aspect_ratio(void* data, unsigned aspect_ratio_idx)
|
||||
{
|
||||
ctr_video_t *ctr = (ctr_video_t*)data;
|
||||
enum rarch_display_ctl_state cmd = RARCH_DISPLAY_CTL_NONE;
|
||||
|
||||
switch (aspectratio_index)
|
||||
switch (aspect_ratio_idx)
|
||||
{
|
||||
case ASPECT_RATIO_SQUARE:
|
||||
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL, NULL);
|
||||
cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL;
|
||||
break;
|
||||
|
||||
case ASPECT_RATIO_CORE:
|
||||
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE, NULL);
|
||||
cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE;
|
||||
break;
|
||||
|
||||
case ASPECT_RATIO_CONFIG:
|
||||
video_viewport_set_config();
|
||||
cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CONFIG;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
video_driver_set_aspect_ratio_value(aspectratio_lut[aspectratio_index].value);
|
||||
if (cmd != RARCH_DISPLAY_CTL_NONE)
|
||||
video_driver_ctl(cmd, NULL);
|
||||
|
||||
video_driver_set_aspect_ratio_value(aspectratio_lut[aspect_ratio_idx].value);
|
||||
|
||||
ctr->keep_aspect = true;
|
||||
ctr->should_resize = true;
|
||||
|
@ -1543,25 +1543,29 @@ static void exynos_gfx_viewport_info(void *data, struct video_viewport *vp)
|
||||
static void exynos_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
|
||||
{
|
||||
struct exynos_video *vid = (struct exynos_video*)data;
|
||||
enum rarch_display_ctl_state cmd = RARCH_DISPLAY_CTL_NONE;
|
||||
|
||||
switch (aspect_ratio_idx)
|
||||
{
|
||||
case ASPECT_RATIO_SQUARE:
|
||||
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL, NULL);
|
||||
cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL;
|
||||
break;
|
||||
|
||||
case ASPECT_RATIO_CORE:
|
||||
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE, NULL);
|
||||
cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE;
|
||||
break;
|
||||
|
||||
case ASPECT_RATIO_CONFIG:
|
||||
video_viewport_set_config();
|
||||
cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CONFIG;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (cmd != RARCH_DISPLAY_CTL_NONE)
|
||||
video_driver_ctl(cmd, NULL);
|
||||
|
||||
video_driver_set_aspect_ratio_value(aspectratio_lut[aspect_ratio_idx].value);
|
||||
vid->aspect_changed = true;
|
||||
}
|
||||
|
@ -3265,25 +3265,29 @@ static retro_proc_address_t gl_get_proc_address(void *data, const char *sym)
|
||||
static void gl_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
|
||||
{
|
||||
gl_t *gl = (gl_t*)data;
|
||||
enum rarch_display_ctl_state cmd = RARCH_DISPLAY_CTL_NONE;
|
||||
|
||||
switch (aspect_ratio_idx)
|
||||
{
|
||||
case ASPECT_RATIO_SQUARE:
|
||||
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL, NULL);
|
||||
cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL;
|
||||
break;
|
||||
|
||||
case ASPECT_RATIO_CORE:
|
||||
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE, NULL);
|
||||
cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE;
|
||||
break;
|
||||
|
||||
case ASPECT_RATIO_CONFIG:
|
||||
video_viewport_set_config();
|
||||
cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CONFIG;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (cmd != RARCH_DISPLAY_CTL_NONE)
|
||||
video_driver_ctl(cmd, NULL);
|
||||
|
||||
video_driver_set_aspect_ratio_value(aspectratio_lut[aspect_ratio_idx].value);
|
||||
|
||||
if (!gl)
|
||||
|
@ -446,22 +446,30 @@ static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines,
|
||||
static void gx_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
|
||||
{
|
||||
gx_video_t *gx = (gx_video_t*)data;
|
||||
enum rarch_display_ctl_state cmd = RARCH_DISPLAY_CTL_NONE;
|
||||
|
||||
switch (aspect_ratio_idx)
|
||||
{
|
||||
case ASPECT_RATIO_SQUARE:
|
||||
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL, NULL);
|
||||
cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL;
|
||||
break;
|
||||
|
||||
case ASPECT_RATIO_CORE:
|
||||
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE, NULL);
|
||||
cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE;
|
||||
break;
|
||||
|
||||
case ASPECT_RATIO_CONFIG:
|
||||
video_viewport_set_config();
|
||||
cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CONFIG;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
video_driver_set_aspect_ratio_value(
|
||||
aspectratio_lut[aspect_ratio_idx].value);
|
||||
if (cmd != RARCH_DISPLAY_CTL_NONE)
|
||||
video_driver_ctl(cmd, NULL);
|
||||
|
||||
video_driver_set_aspect_ratio_value(aspectratio_lut[aspect_ratio_idx].value);
|
||||
|
||||
if (!gx)
|
||||
return;
|
||||
|
@ -789,29 +789,33 @@ static void psp_set_filtering(void *data, unsigned index, bool smooth)
|
||||
psp->tex_filter = smooth? GU_LINEAR : GU_NEAREST;
|
||||
}
|
||||
|
||||
static void psp_set_aspect_ratio(void *data, unsigned aspectratio_index)
|
||||
static void psp_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
|
||||
{
|
||||
psp1_video_t *psp = (psp1_video_t*)data;
|
||||
enum rarch_display_ctl_state cmd = RARCH_DISPLAY_CTL_NONE;
|
||||
|
||||
switch (aspectratio_index)
|
||||
switch (aspect_ratio_idx)
|
||||
{
|
||||
case ASPECT_RATIO_SQUARE:
|
||||
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL, NULL);
|
||||
cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL;
|
||||
break;
|
||||
|
||||
case ASPECT_RATIO_CORE:
|
||||
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE, NULL);
|
||||
cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE;
|
||||
break;
|
||||
|
||||
case ASPECT_RATIO_CONFIG:
|
||||
video_viewport_set_config();
|
||||
cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CONFIG;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
video_driver_set_aspect_ratio_value(aspectratio_lut[aspectratio_index].value);
|
||||
if (cmd != RARCH_DISPLAY_CTL_NONE)
|
||||
video_driver_ctl(cmd, NULL);
|
||||
|
||||
video_driver_set_aspect_ratio_value(aspectratio_lut[aspect_ratio_idx].value);
|
||||
|
||||
psp->keep_aspect = true;
|
||||
psp->should_resize = true;
|
||||
|
@ -652,30 +652,33 @@ static void sdl2_poke_set_filtering(void *data, unsigned index, bool smooth)
|
||||
sdl_tex_zero(&vid->frame);
|
||||
}
|
||||
|
||||
static void sdl2_poke_set_aspect_ratio(void *data, unsigned aspectratio_index)
|
||||
static void sdl2_poke_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
|
||||
{
|
||||
sdl2_video_t *vid = (sdl2_video_t*)data;
|
||||
enum rarch_display_ctl_state cmd = RARCH_DISPLAY_CTL_NONE;
|
||||
|
||||
switch (aspectratio_index)
|
||||
switch (aspect_ratio_idx)
|
||||
{
|
||||
case ASPECT_RATIO_SQUARE:
|
||||
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL, NULL);
|
||||
cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL;
|
||||
break;
|
||||
|
||||
case ASPECT_RATIO_CORE:
|
||||
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE, NULL);
|
||||
cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE;
|
||||
break;
|
||||
|
||||
case ASPECT_RATIO_CONFIG:
|
||||
video_viewport_set_config();
|
||||
cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CONFIG;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
video_driver_set_aspect_ratio_value(
|
||||
aspectratio_lut[aspectratio_index].value);
|
||||
if (cmd != RARCH_DISPLAY_CTL_NONE)
|
||||
video_driver_ctl(cmd, NULL);
|
||||
|
||||
video_driver_set_aspect_ratio_value(aspectratio_lut[aspect_ratio_idx].value);
|
||||
|
||||
vid->video.force_aspect = true;
|
||||
vid->should_resize = true;
|
||||
|
@ -440,26 +440,31 @@ 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 aspectratio_index)
|
||||
static void sdl_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
|
||||
{
|
||||
switch (aspectratio_index)
|
||||
enum rarch_display_ctl_state cmd = RARCH_DISPLAY_CTL_NONE;
|
||||
|
||||
switch (aspect_ratio_idx)
|
||||
{
|
||||
case ASPECT_RATIO_SQUARE:
|
||||
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL, NULL);
|
||||
cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL;
|
||||
break;
|
||||
|
||||
case ASPECT_RATIO_CORE:
|
||||
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE, NULL);
|
||||
cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE;
|
||||
break;
|
||||
|
||||
case ASPECT_RATIO_CONFIG:
|
||||
video_viewport_set_config();
|
||||
cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CONFIG;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (cmd != RARCH_DISPLAY_CTL_NONE)
|
||||
video_driver_ctl(cmd, NULL);
|
||||
|
||||
video_driver_set_aspect_ratio_value(aspectratio_lut[aspectratio_index].value);
|
||||
}
|
||||
|
||||
|
@ -493,29 +493,33 @@ static void vita_set_filtering(void *data, unsigned index, bool smooth)
|
||||
}
|
||||
}
|
||||
|
||||
static void vita_set_aspect_ratio(void *data, unsigned aspectratio_index)
|
||||
static void vita_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
|
||||
{
|
||||
vita_video_t *vita = (vita_video_t*)data;
|
||||
enum rarch_display_ctl_state cmd = RARCH_DISPLAY_CTL_NONE;
|
||||
|
||||
switch (aspectratio_index)
|
||||
switch (aspect_ratio_idx)
|
||||
{
|
||||
case ASPECT_RATIO_SQUARE:
|
||||
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL, NULL);
|
||||
cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL;
|
||||
break;
|
||||
|
||||
case ASPECT_RATIO_CORE:
|
||||
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE, NULL);
|
||||
cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE;
|
||||
break;
|
||||
|
||||
case ASPECT_RATIO_CONFIG:
|
||||
video_viewport_set_config();
|
||||
cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CONFIG;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
video_driver_set_aspect_ratio_value(aspectratio_lut[aspectratio_index].value);
|
||||
if (cmd != RARCH_DISPLAY_CTL_NONE)
|
||||
video_driver_ctl(cmd, NULL);
|
||||
|
||||
video_driver_set_aspect_ratio_value(aspectratio_lut[aspect_ratio_idx].value);
|
||||
|
||||
vita->keep_aspect = true;
|
||||
vita->should_resize = true;
|
||||
|
@ -539,7 +539,7 @@ static bool init_video(void)
|
||||
/* Update core-dependent aspect ratio values. */
|
||||
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL, NULL);
|
||||
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE, NULL);
|
||||
video_viewport_set_config();
|
||||
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_CONFIG, NULL);
|
||||
|
||||
/* Update CUSTOM viewport. */
|
||||
custom_vp = video_viewport_get_custom();
|
||||
@ -1282,6 +1282,46 @@ static void video_viewport_set_square_pixel(unsigned width, unsigned height)
|
||||
aspectratio_lut[ASPECT_RATIO_SQUARE].value = (float)aspect_x / aspect_y;
|
||||
}
|
||||
|
||||
/**
|
||||
* video_viewport_set_config:
|
||||
*
|
||||
* Sets viewport to config aspect ratio.
|
||||
**/
|
||||
static bool video_viewport_set_config(void)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
|
||||
|
||||
if (settings->video.aspect_ratio < 0.0f)
|
||||
{
|
||||
struct retro_game_geometry *geom = &av_info->geometry;
|
||||
|
||||
if (!geom)
|
||||
return false;
|
||||
|
||||
if (geom->aspect_ratio > 0.0f && settings->video.aspect_ratio_auto)
|
||||
aspectratio_lut[ASPECT_RATIO_CONFIG].value = geom->aspect_ratio;
|
||||
else
|
||||
{
|
||||
unsigned base_width = geom->base_width;
|
||||
unsigned base_height = geom->base_height;
|
||||
|
||||
/* Get around division by zero errors */
|
||||
if (base_width == 0)
|
||||
base_width = 1;
|
||||
if (base_height == 0)
|
||||
base_height = 1;
|
||||
aspectratio_lut[ASPECT_RATIO_CONFIG].value =
|
||||
(float)base_width / base_height; /* 1:1 PAR. */
|
||||
}
|
||||
}
|
||||
else
|
||||
aspectratio_lut[ASPECT_RATIO_CONFIG].value =
|
||||
settings->video.aspect_ratio;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool video_driver_ctl(enum rarch_display_ctl_state state, void *data)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
@ -1291,6 +1331,8 @@ bool video_driver_ctl(enum rarch_display_ctl_state state, void *data)
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case RARCH_DISPLAY_CTL_SET_VIEWPORT_CONFIG:
|
||||
return video_viewport_set_config();
|
||||
case RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL:
|
||||
{
|
||||
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
|
||||
@ -1489,43 +1531,6 @@ bool video_driver_ctl(enum rarch_display_ctl_state state, void *data)
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* video_viewport_set_config:
|
||||
*
|
||||
* Sets viewport to config aspect ratio.
|
||||
**/
|
||||
void video_viewport_set_config(void)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
|
||||
|
||||
if (settings->video.aspect_ratio < 0.0f)
|
||||
{
|
||||
struct retro_game_geometry *geom = &av_info->geometry;
|
||||
|
||||
if (!geom)
|
||||
return;
|
||||
|
||||
if (geom->aspect_ratio > 0.0f && settings->video.aspect_ratio_auto)
|
||||
aspectratio_lut[ASPECT_RATIO_CONFIG].value = geom->aspect_ratio;
|
||||
else
|
||||
{
|
||||
unsigned base_width = geom->base_width;
|
||||
unsigned base_height = geom->base_height;
|
||||
|
||||
/* Get around division by zero errors */
|
||||
if (base_width == 0)
|
||||
base_width = 1;
|
||||
if (base_height == 0)
|
||||
base_height = 1;
|
||||
aspectratio_lut[ASPECT_RATIO_CONFIG].value =
|
||||
(float)base_width / base_height; /* 1:1 PAR. */
|
||||
}
|
||||
}
|
||||
else
|
||||
aspectratio_lut[ASPECT_RATIO_CONFIG].value =
|
||||
settings->video.aspect_ratio;
|
||||
}
|
||||
|
||||
/**
|
||||
* video_viewport_get_scaled_integer:
|
||||
|
@ -295,6 +295,8 @@ enum rarch_display_ctl_state
|
||||
RARCH_DISPLAY_CTL_SET_ASPECT_RATIO,
|
||||
/* Sets viewport to aspect ratio set by core. */
|
||||
RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE,
|
||||
/* Sets viewport to config aspect ratio. */
|
||||
RARCH_DISPLAY_CTL_SET_VIEWPORT_CONFIG,
|
||||
/* Sets viewport to square pixel aspect ratio based on width/height. */
|
||||
RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL,
|
||||
RARCH_DISPLAY_CTL_RESET_CUSTOM_VIEWPORT,
|
||||
@ -434,13 +436,6 @@ void video_driver_cached_frame_get(const void **data, unsigned *width,
|
||||
|
||||
void video_driver_menu_settings(void *data, void *subgroup_data, const char *parent_group);
|
||||
|
||||
/**
|
||||
* video_viewport_set_config:
|
||||
*
|
||||
* Sets viewport to config aspect ratio.
|
||||
**/
|
||||
void video_viewport_set_config(void);
|
||||
|
||||
/**
|
||||
* video_viewport_get_scaled_integer:
|
||||
* @vp : Viewport handle
|
||||
|
Loading…
x
Reference in New Issue
Block a user