mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-26 17:50:56 +00:00
Custom aspect ratio safeguards (#17168)
Some checks are pending
CI 3DS / build (push) Waiting to run
CI Android / build (push) Waiting to run
CI DOS/DJGPP / build (push) Waiting to run
CI Emscripten / build (push) Waiting to run
CI GameCube / build (push) Waiting to run
CI Linux (i686) / build (push) Waiting to run
CI Windows (MSVC) / msvc (Debug, x64, 2019) (push) Waiting to run
CI Windows (MSVC) / msvc (Debug, x64, 2022) (push) Waiting to run
CI Windows (MSVC) / msvc (Release, x64, 2019) (push) Waiting to run
CI Windows (MSVC) / msvc (Release, x64, 2022) (push) Waiting to run
CI Windows (MSVC) / msvc (Release, x64, UWP) (push) Waiting to run
CI Windows (MSVC) / msvc (ReleaseAngle, x64, UWP) (push) Waiting to run
CI macOS / build (push) Waiting to run
CI Miyoo ARM32 / build (push) Waiting to run
CI PS2 / build (push) Waiting to run
CI PS4/ORBIS / build (push) Waiting to run
CI PSP / build (push) Waiting to run
CI PSVita / build (push) Waiting to run
CI RS90 Odbeta MIPS32 / build (push) Waiting to run
CI RetroFW MIPS32 / build (push) Waiting to run
CI Switch/libnx / build (push) Waiting to run
CI Wii / build (push) Waiting to run
CI WiiU / build (push) Waiting to run
CI Windows i686 (MXE) / build (push) Waiting to run
CI Windows x64 (MXE) / build (push) Waiting to run
RetroArch CI / linux-c89 (push) Waiting to run
CI webOS / build (push) Waiting to run
Some checks are pending
CI 3DS / build (push) Waiting to run
CI Android / build (push) Waiting to run
CI DOS/DJGPP / build (push) Waiting to run
CI Emscripten / build (push) Waiting to run
CI GameCube / build (push) Waiting to run
CI Linux (i686) / build (push) Waiting to run
CI Windows (MSVC) / msvc (Debug, x64, 2019) (push) Waiting to run
CI Windows (MSVC) / msvc (Debug, x64, 2022) (push) Waiting to run
CI Windows (MSVC) / msvc (Release, x64, 2019) (push) Waiting to run
CI Windows (MSVC) / msvc (Release, x64, 2022) (push) Waiting to run
CI Windows (MSVC) / msvc (Release, x64, UWP) (push) Waiting to run
CI Windows (MSVC) / msvc (ReleaseAngle, x64, UWP) (push) Waiting to run
CI macOS / build (push) Waiting to run
CI Miyoo ARM32 / build (push) Waiting to run
CI PS2 / build (push) Waiting to run
CI PS4/ORBIS / build (push) Waiting to run
CI PSP / build (push) Waiting to run
CI PSVita / build (push) Waiting to run
CI RS90 Odbeta MIPS32 / build (push) Waiting to run
CI RetroFW MIPS32 / build (push) Waiting to run
CI Switch/libnx / build (push) Waiting to run
CI Wii / build (push) Waiting to run
CI WiiU / build (push) Waiting to run
CI Windows i686 (MXE) / build (push) Waiting to run
CI Windows x64 (MXE) / build (push) Waiting to run
RetroArch CI / linux-c89 (push) Waiting to run
CI webOS / build (push) Waiting to run
This commit is contained in:
parent
c27075d9d6
commit
767be489d9
@ -2081,10 +2081,12 @@ void video_viewport_get_scaled_aspect2(struct video_viewport *vp, unsigned viewp
|
||||
video_viewport_t *custom_vp = &settings->video_viewport_custom;
|
||||
int padding_x = 0;
|
||||
int padding_y = 0;
|
||||
|
||||
x = custom_vp->x;
|
||||
y = custom_vp->y;
|
||||
|
||||
if (!ydown)
|
||||
y = vp->full_height - (y + custom_vp->height);
|
||||
y = vp->full_height - (y + custom_vp->height);
|
||||
padding_x += (viewport_width - custom_vp->width);
|
||||
if (padding_x < 0)
|
||||
padding_x *= 2;
|
||||
@ -2372,8 +2374,8 @@ void video_viewport_get_scaled_integer(struct video_viewport *vp,
|
||||
}
|
||||
#endif
|
||||
|
||||
content_width = (content_width == 4) ? video_st->av_info.geometry.base_width : content_width;
|
||||
content_height = (content_height == 4) ? video_st->av_info.geometry.base_height : content_height;
|
||||
content_width = (content_width <= 4) ? video_st->av_info.geometry.base_width : content_width;
|
||||
content_height = (content_height <= 4) ? video_st->av_info.geometry.base_height : content_height;
|
||||
|
||||
if (!ydown)
|
||||
viewport_bias_y = 1.0 - viewport_bias_y;
|
||||
@ -2409,6 +2411,7 @@ void video_viewport_get_scaled_integer(struct video_viewport *vp,
|
||||
{
|
||||
x = custom_vp->x;
|
||||
y = custom_vp->y;
|
||||
|
||||
if (!ydown)
|
||||
y = vp->height - (y + custom_vp->height);
|
||||
padding_x = width - custom_vp->width;
|
||||
|
@ -4958,8 +4958,10 @@ static void setting_get_string_representation_uint_custom_viewport_width(rarch_s
|
||||
return;
|
||||
|
||||
geom = (struct retro_game_geometry*)&av_info->geometry;
|
||||
_len = snprintf(s, len, "%u",
|
||||
*setting->value.target.unsigned_integer);
|
||||
_len = snprintf(s, len, "%u", *setting->value.target.unsigned_integer);
|
||||
|
||||
if (!geom->base_width || !geom->base_height)
|
||||
return;
|
||||
|
||||
if (!(rotation % 2) && (*setting->value.target.unsigned_integer % geom->base_width == 0))
|
||||
snprintf(s + _len, len - _len, " (%ux)",
|
||||
@ -4981,8 +4983,10 @@ static void setting_get_string_representation_uint_custom_viewport_height(rarch_
|
||||
return;
|
||||
|
||||
geom = (struct retro_game_geometry*)&av_info->geometry;
|
||||
_len = snprintf(s, len, "%u",
|
||||
*setting->value.target.unsigned_integer);
|
||||
_len = snprintf(s, len, "%u", *setting->value.target.unsigned_integer);
|
||||
|
||||
if (!geom->base_width || !geom->base_height)
|
||||
return;
|
||||
|
||||
if (!(rotation % 2) && (*setting->value.target.unsigned_integer % geom->base_height == 0))
|
||||
snprintf(s + _len, len - _len, " (%ux)",
|
||||
@ -5836,11 +5840,17 @@ static int setting_uint_action_left_custom_viewport_width(
|
||||
{
|
||||
if (custom->width > geom->base_height)
|
||||
custom->width -= geom->base_height;
|
||||
|
||||
if (custom->width < geom->base_height)
|
||||
custom->width = geom->base_height;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (custom->width > geom->base_width)
|
||||
custom->width -= geom->base_width;
|
||||
|
||||
if (custom->width < geom->base_width)
|
||||
custom->width = geom->base_width;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -5877,11 +5887,17 @@ static int setting_uint_action_left_custom_viewport_height(
|
||||
{
|
||||
if (custom->height > geom->base_width)
|
||||
custom->height -= geom->base_width;
|
||||
|
||||
if (custom->height < geom->base_width)
|
||||
custom->height = geom->base_width;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (custom->height > geom->base_height)
|
||||
custom->height -= geom->base_height;
|
||||
|
||||
if (custom->height < geom->base_height)
|
||||
custom->height = geom->base_height;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -8517,25 +8533,35 @@ static void general_write_handler(rarch_setting_t *setting)
|
||||
|
||||
if (*setting->value.target.boolean)
|
||||
{
|
||||
unsigned int rotation = retroarch_get_rotation();
|
||||
struct retro_game_geometry *geom = (struct retro_game_geometry*)
|
||||
&av_info->geometry;
|
||||
unsigned rotation = retroarch_get_rotation();
|
||||
unsigned base_width = 0;
|
||||
unsigned base_height = 0;
|
||||
struct retro_game_geometry *geom = (struct retro_game_geometry*)&av_info->geometry;
|
||||
|
||||
custom_vp->x = 0;
|
||||
custom_vp->y = 0;
|
||||
custom_vp->x = 0;
|
||||
custom_vp->y = 0;
|
||||
|
||||
base_width = (geom->base_width) ? geom->base_width : video_st->frame_cache_width;
|
||||
base_height = (geom->base_height) ? geom->base_height : video_st->frame_cache_height;
|
||||
|
||||
if (base_width <= 4 || base_height <= 4)
|
||||
{
|
||||
base_width = (rotation % 2) ? 240 : 320;
|
||||
base_height = (rotation % 2) ? 320 : 240;
|
||||
}
|
||||
|
||||
if (rotation % 2)
|
||||
{
|
||||
custom_vp->width = ((custom_vp->width + geom->base_height - 1) / geom->base_height) * geom->base_height;
|
||||
custom_vp->height = ((custom_vp->height + geom->base_width - 1) / geom->base_width) * geom->base_width;
|
||||
custom_vp->width = ((custom_vp->width + base_height - 1) / base_height) * base_height;
|
||||
custom_vp->height = ((custom_vp->height + base_width - 1) / base_width) * base_width;
|
||||
}
|
||||
else
|
||||
{
|
||||
custom_vp->width = ((custom_vp->width + geom->base_width - 1) / geom->base_width) * geom->base_width;
|
||||
custom_vp->height = ((custom_vp->height + geom->base_height - 1) / geom->base_height) * geom->base_height;
|
||||
custom_vp->width = ((custom_vp->width + base_width - 1) / base_width) * base_width;
|
||||
custom_vp->height = ((custom_vp->height + base_height - 1) / base_height) * base_height;
|
||||
}
|
||||
aspectratio_lut[ASPECT_RATIO_CUSTOM].value =
|
||||
(float)custom_vp->width / custom_vp->height;
|
||||
|
||||
aspectratio_lut[ASPECT_RATIO_CUSTOM].value = (float)custom_vp->width / custom_vp->height;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -8845,9 +8871,10 @@ static void general_write_handler(rarch_setting_t *setting)
|
||||
|
||||
if (sys_info)
|
||||
{
|
||||
unsigned int rotation = retroarch_get_rotation();
|
||||
struct retro_game_geometry *geom = (struct retro_game_geometry*)
|
||||
&av_info->geometry;
|
||||
unsigned rotation = retroarch_get_rotation();
|
||||
unsigned base_width = 0;
|
||||
unsigned base_height = 0;
|
||||
struct retro_game_geometry *geom = (struct retro_game_geometry*)&av_info->geometry;
|
||||
|
||||
video_driver_set_rotation(
|
||||
(*setting->value.target.unsigned_integer +
|
||||
@ -8858,18 +8885,28 @@ static void general_write_handler(rarch_setting_t *setting)
|
||||
custom_vp->x = 0;
|
||||
custom_vp->y = 0;
|
||||
|
||||
base_width = (geom->base_width) ? geom->base_width : video_st->frame_cache_width;
|
||||
base_height = (geom->base_height) ? geom->base_height : video_st->frame_cache_height;
|
||||
|
||||
if (base_width <= 4 || base_height <= 4)
|
||||
{
|
||||
base_width = (rotation % 2) ? 240 : 320;
|
||||
base_height = (rotation % 2) ? 320 : 240;
|
||||
}
|
||||
|
||||
/* Round down when rotation is "horizontal", round up when rotation is "vertical"
|
||||
to avoid expanding viewport each time user rotates */
|
||||
if (rotation % 2)
|
||||
{
|
||||
custom_vp->width = MAX(1, (custom_vp->width / geom->base_height)) * geom->base_height;
|
||||
custom_vp->height = MAX(1, (custom_vp->height / geom->base_width )) * geom->base_width;
|
||||
custom_vp->width = MAX(1, (custom_vp->width / base_height)) * base_height;
|
||||
custom_vp->height = MAX(1, (custom_vp->height / base_width )) * base_width;
|
||||
}
|
||||
else
|
||||
{
|
||||
custom_vp->width = ((custom_vp->width + geom->base_width - 1) / geom->base_width) * geom->base_width;
|
||||
custom_vp->height = ((custom_vp->height + geom->base_height - 1) / geom->base_height) * geom->base_height;
|
||||
custom_vp->width = ((custom_vp->width + base_width - 1) / base_width) * base_width;
|
||||
custom_vp->height = ((custom_vp->height + base_height - 1) / base_height) * base_height;
|
||||
}
|
||||
|
||||
aspectratio_lut[ASPECT_RATIO_CUSTOM].value = (float)custom_vp->width / custom_vp->height;
|
||||
|
||||
/* Update Aspect Ratio (only useful for 1:1 PAR) */
|
||||
|
Loading…
Reference in New Issue
Block a user