libretro: Fix display aspect ratio
This commit is contained in:
parent
343e3ba3b7
commit
c76bb5eb6a
|
@ -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<float>(m_display_width) / static_cast<float>(m_display_height)) / m_display_aspect_ratio;
|
||||
apply_aspect_ratio ?
|
||||
((static_cast<float>(m_display_width) / static_cast<float>(m_display_height)) / m_display_aspect_ratio) :
|
||||
1.0f;
|
||||
const float display_width = static_cast<float>(m_display_width);
|
||||
const float display_height = static_cast<float>(m_display_height) * y_scale;
|
||||
const float active_left = static_cast<float>(m_display_active_left);
|
||||
|
@ -119,11 +121,12 @@ void HostDisplay::CalculateDrawRect(s32 window_width, s32 window_height, s32* ou
|
|||
*out_scale = scale;
|
||||
}
|
||||
|
||||
std::tuple<s32, s32, s32, s32> HostDisplay::CalculateDrawRect(s32 window_width, s32 window_height, s32 top_margin) const
|
||||
std::tuple<s32, s32, s32, s32> 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -134,7 +134,8 @@ public:
|
|||
void ClearSoftwareCursor();
|
||||
|
||||
/// Helper function for computing the draw rectangle in a larger window.
|
||||
std::tuple<s32, s32, s32, s32> CalculateDrawRect(s32 window_width, s32 window_height, s32 top_margin) const;
|
||||
std::tuple<s32, s32, s32, s32> 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<s32, s32> 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<s32, s32, s32, s32> CalculateSoftwareCursorDrawRect() const;
|
||||
std::tuple<s32, s32, s32, s32> CalculateSoftwareCursorDrawRect(s32 cursor_x, s32 cursor_y) const;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue