Merge pull request #12616 from HyperspaceMadness/Aspect_Ratio_Full

Added Aspect Ratio Full
This commit is contained in:
Autechre 2021-07-08 11:07:45 +02:00 committed by GitHub
commit ea7e9aaa61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 57 additions and 2 deletions

View File

@ -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 */

View File

@ -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;

View File

@ -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);

View File

@ -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[] = {

View File

@ -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)));