summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authorAdmiral H. Curtiss <pikachu025@gmail.com>2026-05-24 14:58:35 +0200
committerAdmiral H. Curtiss <pikachu025@gmail.com>2026-05-24 19:47:18 +0200
commitba15ddd60214b1e7e2215724a5cc0f5b6fd86b0a (patch)
tree9d05ac1c77ce2b3d2a74a9138df58d489b8b1422 /Source/Core/VideoCommon
parent85ca4a07845daa8b2af39d674928072aa0249793 (diff)
Revert the Presenter logic changes from #14506
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/Present.cpp103
1 files changed, 27 insertions, 76 deletions
diff --git a/Source/Core/VideoCommon/Present.cpp b/Source/Core/VideoCommon/Present.cpp
index 184a826ab5..6fc55fe3e0 100644
--- a/Source/Core/VideoCommon/Present.cpp
+++ b/Source/Core/VideoCommon/Present.cpp
@@ -498,72 +498,33 @@ void Presenter::AdjustRectanglesToFitBounds(MathUtil::Rectangle<int>* target_rec
MathUtil::Rectangle<int>* source_rect, int fb_width,
int fb_height)
{
- const int efb_scale = g_framebuffer_manager->GetEFBScale();
-
- // Crop the content.
- if (g_ActiveConfig.bCropCustom)
+ const int orig_target_width = target_rect->GetWidth();
+ const int orig_target_height = target_rect->GetHeight();
+ const int orig_source_width = source_rect->GetWidth();
+ const int orig_source_height = source_rect->GetHeight();
+ if (target_rect->left < 0)
{
- const int crop_left = g_ActiveConfig.iCropCustomLeft * efb_scale;
- const int crop_right = g_ActiveConfig.iCropCustomRight * efb_scale;
- const int crop_top = g_ActiveConfig.iCropCustomTop * efb_scale;
- const int crop_bottom = g_ActiveConfig.iCropCustomBottom * efb_scale;
-
- const MathUtil::Rectangle<int> original_source_rect = *source_rect;
- source_rect->left = std::min(source_rect->left + crop_left, source_rect->right);
- source_rect->right = std::max(source_rect->right - crop_right, source_rect->left);
- source_rect->top = std::min(source_rect->top + crop_top, source_rect->bottom);
- source_rect->bottom = std::max(source_rect->bottom - crop_bottom, source_rect->top);
-
- const float ratio_diff_width = static_cast<float>(source_rect->GetWidth()) /
- static_cast<float>(original_source_rect.GetWidth());
- const float ratio_diff_height = static_cast<float>(source_rect->GetHeight()) /
- static_cast<float>(original_source_rect.GetHeight());
-
- const int new_width = static_cast<float>(target_rect->GetWidth()) * ratio_diff_width;
- const int new_height = static_cast<float>(target_rect->GetHeight()) * ratio_diff_height;
-
+ const int offset = -target_rect->left;
target_rect->left = 0;
- target_rect->right = new_width;
- target_rect->top = 0;
- target_rect->bottom = new_height;
+ source_rect->left += offset * orig_source_width / orig_target_width;
}
-
- // Center the content.
- const double target_aspect_ratio =
- static_cast<double>(target_rect->GetWidth()) / static_cast<double>(target_rect->GetHeight());
- const double framebuffer_aspect_ratio =
- static_cast<double>(fb_width) / static_cast<double>(fb_height);
- const double target_framebuffer_aspect_ratio = target_aspect_ratio / framebuffer_aspect_ratio;
-
- if (target_framebuffer_aspect_ratio < 1)
+ if (target_rect->right > fb_width)
{
- // Width.
- const int new_width =
- static_cast<double>(fb_width) * static_cast<double>(target_framebuffer_aspect_ratio);
- const int width_diff = fb_width - new_width;
- const int half_width_diff = width_diff / 2;
-
- target_rect->left = half_width_diff;
- target_rect->right = fb_width - half_width_diff;
-
- // Height.
+ const int offset = target_rect->right - fb_width;
+ target_rect->right -= offset;
+ source_rect->right -= offset * orig_source_width / orig_target_width;
+ }
+ if (target_rect->top < 0)
+ {
+ const int offset = -target_rect->top;
target_rect->top = 0;
- target_rect->bottom = fb_height;
+ source_rect->top += offset * orig_source_height / orig_target_height;
}
- else
+ if (target_rect->bottom > fb_height)
{
- // Width.
- target_rect->left = 0;
- target_rect->right = fb_width;
-
- // Height.
- const int new_height =
- static_cast<double>(fb_height) / static_cast<double>(target_framebuffer_aspect_ratio);
- const int height_diff = fb_height - new_height;
- const int half_height_diff = height_diff / 2;
-
- target_rect->top = half_height_diff;
- target_rect->bottom = fb_height - half_height_diff;
+ const int offset = target_rect->bottom - fb_height;
+ target_rect->bottom -= offset;
+ source_rect->bottom -= offset * orig_source_height / orig_target_height;
}
}
@@ -648,7 +609,9 @@ std::tuple<float, float> Presenter::ApplyStandardAspectCrop(float width, float h
if (!g_ActiveConfig.bCropToAspectRatio || aspect_mode == AspectMode::Stretch ||
aspect_mode == AspectMode::Raw)
+ {
return {width, height};
+ }
// Force aspect ratios by cropping the image.
const float current_aspect = width / height;
@@ -727,9 +690,9 @@ void Presenter::UpdateDrawRectangle()
}
// The rendering window size
- const int win_width = m_backbuffer_width;
- const int win_height = m_backbuffer_height;
- const float win_aspect_ratio = static_cast<float>(win_width) / static_cast<float>(win_height);
+ const float win_width = static_cast<float>(m_backbuffer_width);
+ const float win_height = static_cast<float>(m_backbuffer_height);
+ const float win_aspect_ratio = win_width / win_height;
// FIXME: this breaks at very low widget sizes
// Make ControllerInterface aware of the render window region actually being used
@@ -792,13 +755,8 @@ void Presenter::UpdateDrawRectangle()
int_draw_height = m_xfb_rect.GetHeight();
}
- const int half_win_width = win_width / 2;
- const int half_win_height = win_height / 2;
- const int half_draw_width = int_draw_width / 2;
- const int half_draw_height = int_draw_height / 2;
-
- m_target_rectangle.left = half_win_width - half_draw_width;
- m_target_rectangle.top = half_win_height - half_draw_height;
+ m_target_rectangle.left = static_cast<int>(std::round(win_width / 2.0 - int_draw_width / 2.0));
+ m_target_rectangle.top = static_cast<int>(std::round(win_height / 2.0 - int_draw_height / 2.0));
m_target_rectangle.right = m_target_rectangle.left + int_draw_width;
m_target_rectangle.bottom = m_target_rectangle.top + int_draw_height;
}
@@ -856,13 +814,6 @@ std::tuple<int, int> Presenter::CalculateOutputDimensions(int width, int height,
height = static_cast<int>(std::ceil(scaled_height));
}
- if (g_ActiveConfig.bCropCustom)
- {
- width = std::max(width - (g_ActiveConfig.iCropCustomLeft + g_ActiveConfig.iCropCustomRight), 0);
- height =
- std::max(height - (g_ActiveConfig.iCropCustomTop + g_ActiveConfig.iCropCustomBottom), 0);
- }
-
return std::make_tuple(width, height);
}