diff options
| author | Admiral H. Curtiss <pikachu025@gmail.com> | 2017-01-23 23:13:54 +0100 |
|---|---|---|
| committer | Admiral H. Curtiss <pikachu025@gmail.com> | 2017-01-28 11:40:53 +0100 |
| commit | b2c40bf4c4deb9798549c12236ffe57e38bc6bfd (patch) | |
| tree | f9f03b6251761e17913ebe0ec7bf4a470af0dfd6 /Source/Core/VideoCommon/RenderBase.cpp | |
| parent | e1fa6c374fbf928e921e4c7343c39adab9377fd3 (diff) | |
RenderBase: Let the Auto Adjust Window Size option request the final image size rather than the raw framebuffer size.
Diffstat (limited to 'Source/Core/VideoCommon/RenderBase.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/RenderBase.cpp | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index b41b892f99..cf9c23f7b1 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -586,7 +586,12 @@ void Renderer::UpdateDrawRectangle() float Ratio = CalculateDrawAspectRatio(s_backbuffer_width, s_backbuffer_height); if (g_ActiveConfig.iAspectRatio != ASPECT_STRETCH) { - if (Ratio > 1.0f) + if (Ratio >= 0.995f && Ratio <= 1.005f) + { + // If we're very close already, don't scale. + Ratio = 1.0f; + } + else if (Ratio > 1.0f) { // Scale down and center in the X direction. FloatGLWidth /= Ratio; @@ -648,6 +653,38 @@ void Renderer::SetWindowSize(int width, int height) // Scale the window size by the EFB scale. CalculateTargetScale(width, height, &width, &height); + float scaled_width, scaled_height; + std::tie(scaled_width, scaled_height) = ScaleToDisplayAspectRatio(width, height); + + if (g_ActiveConfig.bCrop) + { + // Force 4:3 or 16:9 by cropping the image. + float current_aspect = scaled_width / scaled_height; + float expected_aspect = + (g_ActiveConfig.iAspectRatio == ASPECT_ANALOG_WIDE || + (g_ActiveConfig.iAspectRatio != ASPECT_ANALOG && Core::g_aspect_wide)) ? + (16.0f / 9.0f) : + (4.0f / 3.0f); + if (current_aspect > expected_aspect) + { + // keep height, crop width + scaled_width = scaled_height * expected_aspect; + } + else + { + // keep width, crop height + scaled_height = scaled_width / expected_aspect; + } + } + + width = static_cast<int>(std::ceil(scaled_width)); + height = static_cast<int>(std::ceil(scaled_height)); + + // UpdateDrawRectangle() makes sure that the rendered image is divisible by four for video + // encoders, so do that here too to match it + width -= width % 4; + height -= height % 4; + Host_RequestRenderWindowSize(width, height); } |
