Merge pull request #9734 from Aethyrion/rotation_fixing

Rotation fixing
This commit is contained in:
Twinaphex 2019-11-17 22:53:12 +01:00 committed by GitHub
commit ddd9fbf6ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 112 additions and 25 deletions

View File

@ -935,8 +935,14 @@ static void gl2_renderchain_recompute_pass_sizes(
break;
case RARCH_SCALE_VIEWPORT:
fbo_rect->img_width = fbo_rect->max_img_width =
if (gl->rotation % 180 == 90)
{
fbo_rect->img_width = fbo_rect->max_img_width =
fbo_scale->scale_x * vp_height;
} else {
fbo_rect->img_width = fbo_rect->max_img_width =
fbo_scale->scale_x * vp_width;
}
break;
}
@ -953,8 +959,14 @@ static void gl2_renderchain_recompute_pass_sizes(
break;
case RARCH_SCALE_VIEWPORT:
if (gl->rotation % 180 == 90)
{
fbo_rect->img_height = fbo_rect->max_img_height =
fbo_scale->scale_y * vp_width;
} else {
fbo_rect->img_height = fbo_rect->max_img_height =
fbo_scale->scale_y * vp_height;
}
break;
}

View File

@ -23,6 +23,7 @@
#endif
#include <libretro.h>
#include <retroarch.h>
#include <lists/file_list.h>
#include <file/file_path.h>
#include <string/stdstring.h>
@ -4254,10 +4255,14 @@ static void setting_get_string_representation_uint_custom_viewport_width(rarch_s
av_info = video_viewport_get_system_av_info();
geom = (struct retro_game_geometry*)&av_info->geometry;
if (*setting->value.target.unsigned_integer%geom->base_width == 0)
if (!(get_rotation() % 2) && (*setting->value.target.unsigned_integer%geom->base_width == 0))
snprintf(s, len, "%u (%ux)",
*setting->value.target.unsigned_integer,
*setting->value.target.unsigned_integer / geom->base_width);
else if ((get_rotation() % 2) && (*setting->value.target.unsigned_integer%geom->base_height == 0))
snprintf(s, len, "%u (%ux)",
*setting->value.target.unsigned_integer,
*setting->value.target.unsigned_integer / geom->base_height);
else
snprintf(s, len, "%u",
*setting->value.target.unsigned_integer);
@ -4274,10 +4279,14 @@ static void setting_get_string_representation_uint_custom_viewport_height(rarch_
av_info = video_viewport_get_system_av_info();
geom = (struct retro_game_geometry*)&av_info->geometry;
if (*setting->value.target.unsigned_integer%geom->base_height == 0)
if (!(get_rotation() % 2) && (*setting->value.target.unsigned_integer%geom->base_height == 0))
snprintf(s, len, "%u (%ux)",
*setting->value.target.unsigned_integer,
*setting->value.target.unsigned_integer / geom->base_height);
else if ((get_rotation() % 2) && (*setting->value.target.unsigned_integer%geom->base_width == 0))
snprintf(s, len, "%u (%ux)",
*setting->value.target.unsigned_integer,
*setting->value.target.unsigned_integer / geom->base_width);
else
snprintf(s, len, "%u",
*setting->value.target.unsigned_integer);
@ -4681,12 +4690,16 @@ static int setting_uint_action_left_custom_viewport_width(
if (custom->width <= 1)
custom->width = 1;
else if (settings->bools.video_scale_integer)
{
else if (settings->bools.video_scale_integer) {
if (get_rotation() % 2)
{
if (custom->width > geom->base_height)
custom->width -= geom->base_height;
} else {
if (custom->width > geom->base_width)
custom->width -= geom->base_width;
}
else
} else
custom->width -= 1;
aspectratio_lut[ASPECT_RATIO_CUSTOM].value =
@ -4714,9 +4727,15 @@ static int setting_uint_action_left_custom_viewport_height(
custom->height = 1;
else if (settings->bools.video_scale_integer)
{
if (get_rotation() % 2)
{
if (custom->height > geom->base_width)
custom->height -= geom->base_width;
} else {
if (custom->height > geom->base_height)
custom->height -= geom->base_height;
}
}
else
custom->height -= 1;
@ -4912,9 +4931,13 @@ static int setting_uint_action_right_custom_viewport_width(
video_driver_get_viewport_info(&vp);
if (settings->bools.video_scale_integer)
if (settings->bools.video_scale_integer) {
if (get_rotation() % 2){
custom->width += geom->base_height;
} else {
custom->width += geom->base_width;
else
}
} else
custom->width += 1;
aspectratio_lut[ASPECT_RATIO_CUSTOM].value =
@ -4938,9 +4961,13 @@ static int setting_uint_action_right_custom_viewport_height(
video_driver_get_viewport_info(&vp);
if (settings->bools.video_scale_integer)
if (settings->bools.video_scale_integer){
if (get_rotation() % 2){
custom->height += geom->base_width;
} else {
custom->height += geom->base_height;
else
}
} else
custom->height += 1;
aspectratio_lut[ASPECT_RATIO_CUSTOM].value =
@ -5868,10 +5895,14 @@ static int setting_action_start_custom_viewport_width(rarch_setting_t *setting)
video_driver_get_viewport_info(&vp);
if (settings->bools.video_scale_integer)
if (settings->bools.video_scale_integer){
if (get_rotation() % 2){
custom->width = ((custom->width + geom->base_height - 1) /
geom->base_height) * geom->base_height;
} else
custom->width = ((custom->width + geom->base_width - 1) /
geom->base_width) * geom->base_width;
else
} else
custom->width = vp.full_width - custom->x;
aspectratio_lut[ASPECT_RATIO_CUSTOM].value =
@ -5893,11 +5924,14 @@ static int setting_action_start_custom_viewport_height(rarch_setting_t *setting)
return -1;
video_driver_get_viewport_info(&vp);
if (settings->bools.video_scale_integer)
if (settings->bools.video_scale_integer){
if (get_rotation() % 2){
custom->height = ((custom->height + geom->base_width - 1) /
geom->base_width) * geom->base_width;
} else
custom->height = ((custom->height + geom->base_height - 1) /
geom->base_height) * geom->base_height;
else
} else
custom->height = vp.full_height - custom->y;
aspectratio_lut[ASPECT_RATIO_CUSTOM].value =
@ -6277,8 +6311,13 @@ void general_write_handler(rarch_setting_t *setting)
{
custom->x = 0;
custom->y = 0;
if (get_rotation() %2){
custom->width = ((custom->width + geom->base_height - 1) / geom->base_height) * geom->base_height;
custom->height = ((custom->height + geom->base_width - 1) / geom->base_width) * geom->base_width;
} else {
custom->width = ((custom->width + geom->base_width - 1) / geom->base_width) * geom->base_width;
custom->height = ((custom->height + geom->base_height - 1) / geom->base_height) * geom->base_height;
}
aspectratio_lut[ASPECT_RATIO_CUSTOM].value =
(float)custom->width / custom->height;
}
@ -6395,11 +6434,36 @@ void general_write_handler(rarch_setting_t *setting)
case MENU_ENUM_LABEL_VIDEO_ROTATION:
{
rarch_system_info_t *system = runloop_get_system_info();
video_viewport_t vp;
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
video_viewport_t *custom = video_viewport_get_custom();
struct retro_game_geometry *geom = (struct retro_game_geometry*)
&av_info->geometry;
if (system)
if (system){
video_driver_set_rotation(
(*setting->value.target.unsigned_integer +
system->rotation) % 4);
/* Update Custom Aspect Ratio values */
video_driver_get_viewport_info(&vp);
custom->x = 0;
custom->y = 0;
/* Round down when rotation is "horizontal", round up when rotation is "vertical"
to avoid expanding viewport each time user rotates */
if (get_rotation() %2){
custom->width = MAX(1,(custom->width / geom->base_height)) * geom->base_height;
custom->height = MAX(1,(custom->height/ geom->base_width )) * geom->base_width;
} else {
custom->width = ((custom->width + geom->base_width - 1) / geom->base_width) * geom->base_width;
custom->height = ((custom->height + geom->base_height - 1) / geom->base_height) * geom->base_height;
}
aspectratio_lut[ASPECT_RATIO_CUSTOM].value =
(float)custom->width / custom->height;
/* Update Aspect Ratio (only useful for 1:1 PAR) */
video_driver_set_aspect_ratio();
}
}
break;
case MENU_ENUM_LABEL_SCREEN_ORIENTATION:

View File

@ -20000,8 +20000,13 @@ static void video_driver_set_viewport_square_pixel(void)
highest = i;
}
aspect_x = width / highest;
aspect_y = height / highest;
if (get_rotation() % 2) {
aspect_x = height / highest;
aspect_y = width / highest;
} else {
aspect_x = width / highest;
aspect_y = height / highest;
}
snprintf(aspectratio_lut[ASPECT_RATIO_SQUARE].name,
sizeof(aspectratio_lut[ASPECT_RATIO_SQUARE].name),
@ -20016,7 +20021,6 @@ static bool video_driver_init_internal(bool *video_is_threaded)
unsigned max_dim, scale, width, height;
video_viewport_t *custom_vp = NULL;
input_driver_t *tmp = NULL;
rarch_system_info_t *system = NULL;
static uint16_t dummy_pixels[32] = {0};
settings_t *settings = configuration_settings;
struct retro_game_geometry *geom = &video_driver_av_info.geometry;
@ -20176,10 +20180,7 @@ static bool video_driver_init_internal(bool *video_is_threaded)
video_driver_get_viewport_info(custom_vp);
}
system = &runloop_system;
video_driver_set_rotation(
(settings->uints.video_rotation + system->rotation) % 4);
video_driver_set_rotation(get_rotation() % 4);
current_video->suppress_screensaver(video_driver_data,
settings->bools.ui_suspend_screensaver_enable);
@ -21088,8 +21089,12 @@ void video_viewport_get_scaled_integer(struct video_viewport *vp,
unsigned base_width;
/* Use system reported sizes as these define the
* geometry for the "normal" case. */
unsigned base_height =
video_driver_av_info.geometry.base_height;
unsigned base_height;
if (get_rotation() % 2)
base_height = video_driver_av_info.geometry.base_width;
else
base_height = video_driver_av_info.geometry.base_height;
if (base_height == 0)
base_height = 1;
@ -28793,3 +28798,7 @@ static void core_free_retro_game_info(struct retro_game_info *dest)
dest->data = NULL;
dest->meta = NULL;
}
unsigned int get_rotation(){
return configuration_settings->uints.video_rotation + runloop_system.rotation;
}

View File

@ -2020,6 +2020,8 @@ bool menu_driver_is_toggled(void);
bool menu_widgets_ready(void);
unsigned int get_rotation(void);
RETRO_END_DECLS
#endif