Add Stretch to Display Area option (#2961)

This commit is contained in:
raven02 2017-07-08 21:06:11 +08:00 committed by kd-11
parent 41d921808b
commit 2e47c42367
5 changed files with 35 additions and 24 deletions

View File

@ -1002,19 +1002,22 @@ void GLGSRender::flip(int buffer)
sizei csize(m_frame->client_width(), m_frame->client_height());
sizei new_size = csize;
const double aq = (double)buffer_width / buffer_height;
const double rq = (double)new_size.width / new_size.height;
const double q = aq / rq;
if (!g_cfg.video.stretch_to_display_area)
{
const double aq = (double)buffer_width / buffer_height;
const double rq = (double)new_size.width / new_size.height;
const double q = aq / rq;
if (q > 1.0)
{
new_size.height = int(new_size.height / q);
aspect_ratio.y = (csize.height - new_size.height) / 2;
}
else if (q < 1.0)
{
new_size.width = int(new_size.width * q);
aspect_ratio.x = (csize.width - new_size.width) / 2;
if (q > 1.0)
{
new_size.height = int(new_size.height / q);
aspect_ratio.y = (csize.height - new_size.height) / 2;
}
else if (q < 1.0)
{
new_size.width = int(new_size.width * q);
aspect_ratio.x = (csize.width - new_size.width) / 2;
}
}
aspect_ratio.size = new_size;

View File

@ -2013,19 +2013,22 @@ void VKGSRender::flip(int buffer)
sizei csize = { m_frame->client_width(), m_frame->client_height() };
sizei new_size = csize;
const double aq = (double)buffer_width / buffer_height;
const double rq = (double)new_size.width / new_size.height;
const double q = aq / rq;
if (!g_cfg.video.stretch_to_display_area)
{
const double aq = (double)buffer_width / buffer_height;
const double rq = (double)new_size.width / new_size.height;
const double q = aq / rq;
if (q > 1.0)
{
new_size.height = int(new_size.height / q);
aspect_ratio.y = (csize.height - new_size.height) / 2;
}
else if (q < 1.0)
{
new_size.width = int(new_size.width * q);
aspect_ratio.x = (csize.width - new_size.width) / 2;
if (q > 1.0)
{
new_size.height = int(new_size.height / q);
aspect_ratio.y = (csize.height - new_size.height) / 2;
}
else if (q < 1.0)
{
new_size.width = int(new_size.width * q);
aspect_ratio.x = (csize.width - new_size.width) / 2;
}
}
aspect_ratio.size = new_size;

View File

@ -310,6 +310,7 @@ struct cfg_root : cfg::node
cfg::_bool overlay{this, "Debug overlay"};
cfg::_bool gl_legacy_buffers{this, "Use Legacy OpenGL Buffers"};
cfg::_bool use_gpu_texture_scaling{this, "Use GPU texture scaling", true};
cfg::_bool stretch_to_display_area{this, "Stretch To Display Area"};
cfg::_bool force_high_precision_z_buffer{this, "Force High Precision Z buffer"};
cfg::_bool invalidate_surface_cache_every_frame{this, "Invalidate Cache Every Frame", true};
cfg::_bool strict_rendering_mode{this, "Strict Rendering Mode"};

View File

@ -60,6 +60,7 @@ public:
DebugOverlay,
LegacyBuffers,
GPUTextureScaling,
StretchToDisplayArea,
D3D12Adapter,
VulkanAdapter,
ForceHighpZ,
@ -152,6 +153,7 @@ private:
{ DebugOverlay, { "Video", "Debug overlay"}},
{ LegacyBuffers, { "Video", "Use Legacy OpenGL Buffers"}},
{ GPUTextureScaling,{ "Video", "Use GPU texture scaling"}},
{ StretchToDisplayArea, { "Video", "Stretch To Display Area"}},
{ ForceHighpZ, { "Video", "Force High Precision Z buffer"}},
{ AutoInvalidateCache, { "Video", "Invalidate Cache Every Frame"}},
{ StrictRenderingMode, { "Video", "Strict Rendering Mode"}},

View File

@ -235,6 +235,7 @@ graphics_tab::graphics_tab(std::shared_ptr<emu_settings> xSettings, Render_Creat
QCheckBox *logProg = xemu_settings->CreateEnhancedCheckBox(emu_settings::LogShaderPrograms, this);
QCheckBox *vsync = xemu_settings->CreateEnhancedCheckBox(emu_settings::VSync, this);
QCheckBox *gpuTextureScaling = xemu_settings->CreateEnhancedCheckBox(emu_settings::GPUTextureScaling, this);
QCheckBox *stretchToDisplayArea = xemu_settings->CreateEnhancedCheckBox(emu_settings::StretchToDisplayArea, this);
QCheckBox *forceHighpZ = xemu_settings->CreateEnhancedCheckBox(emu_settings::ForceHighpZ, this);
QCheckBox *autoInvalidateCache = xemu_settings->CreateEnhancedCheckBox(emu_settings::AutoInvalidateCache, this);
QCheckBox *scrictModeRendering = xemu_settings->CreateEnhancedCheckBox(emu_settings::StrictRenderingMode, this);
@ -269,6 +270,7 @@ graphics_tab::graphics_tab(std::shared_ptr<emu_settings> xSettings, Render_Creat
vbox22->addWidget(vsync);
vbox22->addWidget(autoInvalidateCache);
vbox22->addWidget(gpuTextureScaling);
vbox22->addWidget(stretchToDisplayArea);
vbox22->addSpacing(20);
hbox2->addLayout(vbox21);