diff --git a/src/core/host_display.cpp b/src/core/host_display.cpp index 682f82535..fd22ebfac 100644 --- a/src/core/host_display.cpp +++ b/src/core/host_display.cpp @@ -59,10 +59,12 @@ void HostDisplay::ClearSoftwareCursor() void HostDisplay::CalculateDrawRect(s32 window_width, s32 window_height, s32* out_left, s32* out_top, s32* out_width, s32* out_height, s32* out_left_padding, s32* out_top_padding, float* out_scale, - float* out_y_scale) const + float* out_y_scale, bool apply_aspect_ratio) const { const float y_scale = - (static_cast(m_display_width) / static_cast(m_display_height)) / m_display_aspect_ratio; + apply_aspect_ratio ? + ((static_cast(m_display_width) / static_cast(m_display_height)) / m_display_aspect_ratio) : + 1.0f; const float display_width = static_cast(m_display_width); const float display_height = static_cast(m_display_height) * y_scale; const float active_left = static_cast(m_display_active_left); @@ -119,11 +121,12 @@ void HostDisplay::CalculateDrawRect(s32 window_width, s32 window_height, s32* ou *out_scale = scale; } -std::tuple HostDisplay::CalculateDrawRect(s32 window_width, s32 window_height, s32 top_margin) const +std::tuple HostDisplay::CalculateDrawRect(s32 window_width, s32 window_height, s32 top_margin, + bool apply_aspect_ratio /* = true */) const { s32 left, top, width, height, left_padding, top_padding; CalculateDrawRect(window_width, window_height - top_margin, &left, &top, &width, &height, &left_padding, &top_padding, - nullptr, nullptr); + nullptr, nullptr, apply_aspect_ratio); return std::make_tuple(left + left_padding, top + top_padding + top_margin, width, height); } diff --git a/src/core/host_display.h b/src/core/host_display.h index 80fe35df8..95fb6c5c3 100644 --- a/src/core/host_display.h +++ b/src/core/host_display.h @@ -134,7 +134,8 @@ public: void ClearSoftwareCursor(); /// Helper function for computing the draw rectangle in a larger window. - std::tuple CalculateDrawRect(s32 window_width, s32 window_height, s32 top_margin) const; + std::tuple CalculateDrawRect(s32 window_width, s32 window_height, s32 top_margin, + bool apply_aspect_ratio = true) const; /// Helper function for converting window coordinates to display coordinates. std::tuple ConvertWindowCoordinatesToDisplayCoordinates(s32 window_x, s32 window_y, s32 window_width, @@ -157,7 +158,7 @@ protected: void CalculateDrawRect(s32 window_width, s32 window_height, s32* out_left, s32* out_top, s32* out_width, s32* out_height, s32* out_left_padding, s32* out_top_padding, float* out_scale, - float* out_y_scale) const; + float* out_y_scale, bool apply_aspect_ratio = true) const; std::tuple CalculateSoftwareCursorDrawRect() const; std::tuple CalculateSoftwareCursorDrawRect(s32 cursor_x, s32 cursor_y) const; diff --git a/src/duckstation-libretro/libretro_d3d11_host_display.cpp b/src/duckstation-libretro/libretro_d3d11_host_display.cpp index eff191cf1..b80b403c1 100644 --- a/src/duckstation-libretro/libretro_d3d11_host_display.cpp +++ b/src/duckstation-libretro/libretro_d3d11_host_display.cpp @@ -86,7 +86,7 @@ bool LibretroD3D11HostDisplay::Render() if (HasDisplayTexture()) { - const auto [left, top, width, height] = CalculateDrawRect(display_width, display_height, 0); + const auto [left, top, width, height] = CalculateDrawRect(display_width, display_height, 0, false); RenderDisplay(left, top, width, height, m_display_texture_handle, m_display_texture_width, m_display_texture_height, m_display_texture_view_x, m_display_texture_view_y, m_display_texture_view_width, m_display_texture_view_height, m_display_linear_filtering); diff --git a/src/duckstation-libretro/libretro_opengl_host_display.cpp b/src/duckstation-libretro/libretro_opengl_host_display.cpp index fbc70670d..97b9565ba 100644 --- a/src/duckstation-libretro/libretro_opengl_host_display.cpp +++ b/src/duckstation-libretro/libretro_opengl_host_display.cpp @@ -129,7 +129,7 @@ bool LibretroOpenGLHostDisplay::Render() if (HasDisplayTexture()) { - const auto [left, top, width, height] = CalculateDrawRect(display_width, display_height, 0); + const auto [left, top, width, height] = CalculateDrawRect(display_width, display_height, 0, false); RenderDisplay(left, top, width, height, m_display_texture_handle, m_display_texture_width, m_display_texture_height, m_display_texture_view_x, m_display_texture_view_y, m_display_texture_view_width, m_display_texture_view_height, m_display_linear_filtering); diff --git a/src/duckstation-libretro/libretro_vulkan_host_display.cpp b/src/duckstation-libretro/libretro_vulkan_host_display.cpp index 03324805f..1d1810e88 100644 --- a/src/duckstation-libretro/libretro_vulkan_host_display.cpp +++ b/src/duckstation-libretro/libretro_vulkan_host_display.cpp @@ -187,7 +187,7 @@ bool LibretroVulkanHostDisplay::Render() if (HasDisplayTexture()) { - const auto [left, top, width, height] = CalculateDrawRect(display_width, display_height, 0); + const auto [left, top, width, height] = CalculateDrawRect(display_width, display_height, 0, false); RenderDisplay(left, top, width, height, m_display_texture_handle, m_display_texture_width, m_display_texture_height, m_display_texture_view_x, m_display_texture_view_y, m_display_texture_view_width, m_display_texture_view_height, m_display_linear_filtering);