diff --git a/gfx/video_defines.h b/gfx/video_defines.h index 2a1dd62a39..33f94d584b 100644 --- a/gfx/video_defines.h +++ b/gfx/video_defines.h @@ -55,6 +55,7 @@ enum aspect_ratio ASPECT_RATIO_SQUARE, ASPECT_RATIO_CORE, ASPECT_RATIO_CUSTOM, + ASPECT_RATIO_FULL, ASPECT_RATIO_END }; @@ -116,7 +117,7 @@ enum text_alignment #define COLOR_ABGR(r, g, b, a) (((unsigned)(a) << 24) | ((b) << 16) | ((g) << 8) | ((r) << 0)) #endif -#define LAST_ASPECT_RATIO ASPECT_RATIO_CUSTOM +#define LAST_ASPECT_RATIO ASPECT_RATIO_FULL /* ABGR color format defines */ diff --git a/retroarch.c b/retroarch.c index fd9d55ec53..15ed1f993c 100644 --- a/retroarch.c +++ b/retroarch.c @@ -31379,6 +31379,21 @@ void video_driver_set_viewport_core(void) (float)geom->base_width / geom->base_height; } +void video_driver_set_viewport_full() +{ + unsigned width = 0; + unsigned height = 0; + + video_driver_get_size(&width, &height); + + if (width == 0 || height == 0) + { + return; + } + + aspectratio_lut[ASPECT_RATIO_FULL].value = (float)width / (float)height; +} + void video_driver_reset_custom_viewport(void) { struct rarch_state *p_rarch = &rarch_st; @@ -31473,6 +31488,10 @@ void video_driver_set_aspect_ratio(void) settings->bools.video_aspect_ratio_auto); break; + case ASPECT_RATIO_FULL: + video_driver_set_viewport_full(); + break; + default: break; } @@ -38007,6 +38026,34 @@ static enum runloop_state runloop_check_state( } #endif + /* + * If the Aspect Ratio is FULL then update the aspect ratio to the + * current video driver aspect ratio (The full window) + * + * TODO/FIXME + * Should possibly be refactored to have last width & driver width & height + * only be done once when we are using an overlay OR using aspect ratio + * full + */ + if (settings->uints.video_aspect_ratio_idx == ASPECT_RATIO_FULL) + { + static unsigned last_width = 0; + static unsigned last_height = 0; + unsigned video_driver_width = p_rarch->video_driver_width; + unsigned video_driver_height = p_rarch->video_driver_height; + + /* Check whether video aspect has changed */ + if ((video_driver_width != last_width) || + (video_driver_height != last_height)) + { + /* Update set aspect ratio so the full matches the current video width & height */ + command_event(CMD_EVENT_VIDEO_SET_ASPECT_RATIO, NULL); + + last_width = video_driver_width; + last_height = video_driver_height; + } + } + /* Check quit key */ { bool trig_quit_key, quit_press_twice; diff --git a/retroarch.h b/retroarch.h index f76cb34182..53575b7ab4 100644 --- a/retroarch.h +++ b/retroarch.h @@ -1567,6 +1567,8 @@ bool video_driver_supports_read_frame_raw(void); void video_driver_set_viewport_core(void); +void video_driver_set_viewport_full(void); + void video_driver_reset_custom_viewport(void); void video_driver_set_rgba(void); diff --git a/retroarch_data.h b/retroarch_data.h index e9713cf831..802f21e0d0 100644 --- a/retroarch_data.h +++ b/retroarch_data.h @@ -2373,7 +2373,8 @@ struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END] = { { 0.0f, "Config" }, { 1.0f, "Square pixel" }, { 1.0f, "Core provided" }, - { 0.0f, "Custom" } + { 0.0f, "Custom" }, + { 1.3333f, "Full" } }; static gfx_api_gpu_map gpu_map[] = { diff --git a/ui/drivers/qt/qt_options.cpp b/ui/drivers/qt/qt_options.cpp index 6fbf3326d9..5da7a0fdec 100644 --- a/ui/drivers/qt/qt_options.cpp +++ b/ui/drivers/qt/qt_options.cpp @@ -1352,6 +1352,7 @@ AspectRatioGroup::AspectRatioGroup(const QString &title, QWidget *parent) : QHBoxLayout *custom = new QHBoxLayout; QVBoxLayout *customRadio = new QVBoxLayout; QHBoxLayout *config = new QHBoxLayout; + QHBoxLayout *full = new QHBoxLayout; QHBoxLayout *aspectL = new QHBoxLayout; FormLayout *leftAspectForm = new FormLayout; FormLayout *rightAspectForm = new FormLayout; @@ -1382,6 +1383,8 @@ AspectRatioGroup::AspectRatioGroup(const QString &title, QWidget *parent) : config->setStretch(1, 1); config->setSizeConstraint(QLayout::SetMinimumSize); + full->addWidget(new UIntRadioButton(MENU_ENUM_LABEL_VIDEO_ASPECT_RATIO_INDEX, ASPECT_RATIO_FULL)); + leftAspect->addRow(new UIntRadioButton(MENU_ENUM_LABEL_VIDEO_ASPECT_RATIO_INDEX, ASPECT_RATIO_CORE)); leftAspect->addRow(preset); @@ -1394,6 +1397,7 @@ AspectRatioGroup::AspectRatioGroup(const QString &title, QWidget *parent) : aspectL->addLayout(rightAspect); addRow(aspectL); + addRow(full); addRow(custom); connect(m_radioButton, SIGNAL(clicked(bool)), this, SLOT(onAspectRadioClicked(bool)));