mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
RenderBase: Let the Auto Adjust Window Size option request the final image size rather than the raw framebuffer size.
This commit is contained in:
parent
e1fa6c374f
commit
b2c40bf4c4
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user