diff options
Diffstat (limited to 'src/core/frontend/framebuffer_layout.cpp')
| -rw-r--r-- | src/core/frontend/framebuffer_layout.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/core/frontend/framebuffer_layout.cpp b/src/core/frontend/framebuffer_layout.cpp index a1357179f..d6d2cf3f0 100644 --- a/src/core/frontend/framebuffer_layout.cpp +++ b/src/core/frontend/framebuffer_layout.cpp | |||
| @@ -20,7 +20,7 @@ static Common::Rectangle<T> MaxRectangle(Common::Rectangle<T> window_area, | |||
| 20 | static_cast<T>(std::round(scale * screen_aspect_ratio))}; | 20 | static_cast<T>(std::round(scale * screen_aspect_ratio))}; |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | FramebufferLayout DefaultFrameLayout(unsigned width, unsigned height) { | 23 | FramebufferLayout DefaultFrameLayout(u32 width, u32 height) { |
| 24 | ASSERT(width > 0); | 24 | ASSERT(width > 0); |
| 25 | ASSERT(height > 0); | 25 | ASSERT(height > 0); |
| 26 | // The drawing code needs at least somewhat valid values for both screens | 26 | // The drawing code needs at least somewhat valid values for both screens |
| @@ -29,22 +29,23 @@ FramebufferLayout DefaultFrameLayout(unsigned width, unsigned height) { | |||
| 29 | 29 | ||
| 30 | const float emulation_aspect_ratio{static_cast<float>(ScreenUndocked::Height) / | 30 | const float emulation_aspect_ratio{static_cast<float>(ScreenUndocked::Height) / |
| 31 | ScreenUndocked::Width}; | 31 | ScreenUndocked::Width}; |
| 32 | Common::Rectangle<unsigned> screen_window_area{0, 0, width, height}; | 32 | const auto window_aspect_ratio = static_cast<float>(height) / width; |
| 33 | Common::Rectangle<unsigned> screen = MaxRectangle(screen_window_area, emulation_aspect_ratio); | ||
| 34 | 33 | ||
| 35 | float window_aspect_ratio = static_cast<float>(height) / width; | 34 | const Common::Rectangle<u32> screen_window_area{0, 0, width, height}; |
| 35 | Common::Rectangle<u32> screen = MaxRectangle(screen_window_area, emulation_aspect_ratio); | ||
| 36 | 36 | ||
| 37 | if (window_aspect_ratio < emulation_aspect_ratio) { | 37 | if (window_aspect_ratio < emulation_aspect_ratio) { |
| 38 | screen = screen.TranslateX((screen_window_area.GetWidth() - screen.GetWidth()) / 2); | 38 | screen = screen.TranslateX((screen_window_area.GetWidth() - screen.GetWidth()) / 2); |
| 39 | } else { | 39 | } else { |
| 40 | screen = screen.TranslateY((height - screen.GetHeight()) / 2); | 40 | screen = screen.TranslateY((height - screen.GetHeight()) / 2); |
| 41 | } | 41 | } |
| 42 | |||
| 42 | res.screen = screen; | 43 | res.screen = screen; |
| 43 | return res; | 44 | return res; |
| 44 | } | 45 | } |
| 45 | 46 | ||
| 46 | FramebufferLayout FrameLayoutFromResolutionScale(u16 res_scale) { | 47 | FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale) { |
| 47 | int width, height; | 48 | u32 width, height; |
| 48 | 49 | ||
| 49 | if (Settings::values.use_docked_mode) { | 50 | if (Settings::values.use_docked_mode) { |
| 50 | width = ScreenDocked::WidthDocked * res_scale; | 51 | width = ScreenDocked::WidthDocked * res_scale; |