summaryrefslogtreecommitdiffstats
path: root/src/core/frontend/framebuffer_layout.cpp
diff options
context:
space:
mode:
authorThaMighty90 <30285364+ThaMighty90@users.noreply.github.com>2017-08-25 23:53:07 +0200
committerbunnei <bunneidev@gmail.com>2017-08-25 23:53:07 +0200
commit3cdf854e44e7ff088fa0cbdcfa2bcc6e41822b2c (patch)
treefea4d815243451086ec4da459f3a310b02019437 /src/core/frontend/framebuffer_layout.cpp
parentMerge pull request #2839 from Subv/global_kernel_lock (diff)
downloadyuzu-3cdf854e44e7ff088fa0cbdcfa2bcc6e41822b2c.tar
yuzu-3cdf854e44e7ff088fa0cbdcfa2bcc6e41822b2c.tar.gz
yuzu-3cdf854e44e7ff088fa0cbdcfa2bcc6e41822b2c.tar.bz2
yuzu-3cdf854e44e7ff088fa0cbdcfa2bcc6e41822b2c.tar.lz
yuzu-3cdf854e44e7ff088fa0cbdcfa2bcc6e41822b2c.tar.xz
yuzu-3cdf854e44e7ff088fa0cbdcfa2bcc6e41822b2c.tar.zst
yuzu-3cdf854e44e7ff088fa0cbdcfa2bcc6e41822b2c.zip
Diffstat (limited to 'src/core/frontend/framebuffer_layout.cpp')
-rw-r--r--src/core/frontend/framebuffer_layout.cpp36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/core/frontend/framebuffer_layout.cpp b/src/core/frontend/framebuffer_layout.cpp
index d2d02f9ff..e9f778fcb 100644
--- a/src/core/frontend/framebuffer_layout.cpp
+++ b/src/core/frontend/framebuffer_layout.cpp
@@ -141,6 +141,40 @@ FramebufferLayout LargeFrameLayout(unsigned width, unsigned height, bool swapped
return res;
}
+FramebufferLayout SideFrameLayout(unsigned width, unsigned height, bool swapped) {
+ ASSERT(width > 0);
+ ASSERT(height > 0);
+
+ FramebufferLayout res{width, height, true, true, {}, {}};
+ // Aspect ratio of both screens side by side
+ const float emulation_aspect_ratio = static_cast<float>(Core::kScreenTopHeight) /
+ (Core::kScreenTopWidth + Core::kScreenBottomWidth);
+ float window_aspect_ratio = static_cast<float>(height) / width;
+ MathUtil::Rectangle<unsigned> screen_window_area{0, 0, width, height};
+ // Find largest Rectangle that can fit in the window size with the given aspect ratio
+ MathUtil::Rectangle<unsigned> screen_rect =
+ maxRectangle(screen_window_area, emulation_aspect_ratio);
+ // Find sizes of top and bottom screen
+ MathUtil::Rectangle<unsigned> top_screen = maxRectangle(screen_rect, TOP_SCREEN_ASPECT_RATIO);
+ MathUtil::Rectangle<unsigned> bot_screen = maxRectangle(screen_rect, BOT_SCREEN_ASPECT_RATIO);
+
+ if (window_aspect_ratio < emulation_aspect_ratio) {
+ // Apply borders to the left and right sides of the window.
+ u32 shift_horizontal = (screen_window_area.GetWidth() - screen_rect.GetWidth()) / 2;
+ top_screen = top_screen.TranslateX(shift_horizontal);
+ bot_screen = bot_screen.TranslateX(shift_horizontal);
+ } else {
+ // Window is narrower than the emulation content => apply borders to the top and bottom
+ u32 shift_vertical = (screen_window_area.GetHeight() - screen_rect.GetHeight()) / 2;
+ top_screen = top_screen.TranslateY(shift_vertical);
+ bot_screen = bot_screen.TranslateY(shift_vertical);
+ }
+ // Move the top screen to the right if we are swapped.
+ res.top_screen = swapped ? top_screen.TranslateX(bot_screen.GetWidth()) : top_screen;
+ res.bottom_screen = swapped ? bot_screen : bot_screen.TranslateX(top_screen.GetWidth());
+ return res;
+}
+
FramebufferLayout CustomFrameLayout(unsigned width, unsigned height) {
ASSERT(width > 0);
ASSERT(height > 0);
@@ -158,4 +192,4 @@ FramebufferLayout CustomFrameLayout(unsigned width, unsigned height) {
res.bottom_screen = bot_screen;
return res;
}
-}
+} // namespace Layout