summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/frontend/framebuffer_layout.cpp32
-rw-r--r--src/core/frontend/framebuffer_layout.h12
2 files changed, 26 insertions, 18 deletions
diff --git a/src/core/frontend/framebuffer_layout.cpp b/src/core/frontend/framebuffer_layout.cpp
index d8821f8fd..1b4f0255e 100644
--- a/src/core/frontend/framebuffer_layout.cpp
+++ b/src/core/frontend/framebuffer_layout.cpp
@@ -27,22 +27,9 @@ FramebufferLayout DefaultFrameLayout(u32 width, u32 height) {
27 // so just calculate them both even if the other isn't showing. 27 // so just calculate them both even if the other isn't showing.
28 FramebufferLayout res{width, height}; 28 FramebufferLayout res{width, height};
29 29
30 const auto window_aspect_ratio = static_cast<float>(height) / width; 30 const float window_aspect_ratio = static_cast<float>(height) / width;
31 float emulation_aspect_ratio; 31 float emulation_aspect_ratio = EmulationAspectRatio(
32 32 static_cast<Aspect>(Settings::values.aspect_ratio), window_aspect_ratio);
33 switch (static_cast<Aspect>(Settings::values.aspect_ratio)) {
34 case Aspect::AspectDefault:
35 emulation_aspect_ratio = static_cast<float>(ScreenUndocked::Height) / ScreenUndocked::Width;
36 break;
37 case Aspect::Aspect21by9:
38 emulation_aspect_ratio = 9.f / 21;
39 break;
40 case Aspect::AspectStretch:
41 emulation_aspect_ratio = window_aspect_ratio;
42 break;
43 default:
44 emulation_aspect_ratio = static_cast<float>(ScreenUndocked::Height) / ScreenUndocked::Width;
45 }
46 33
47 const Common::Rectangle<u32> screen_window_area{0, 0, width, height}; 34 const Common::Rectangle<u32> screen_window_area{0, 0, width, height};
48 Common::Rectangle<u32> screen = MaxRectangle(screen_window_area, emulation_aspect_ratio); 35 Common::Rectangle<u32> screen = MaxRectangle(screen_window_area, emulation_aspect_ratio);
@@ -71,4 +58,17 @@ FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale) {
71 return DefaultFrameLayout(width, height); 58 return DefaultFrameLayout(width, height);
72} 59}
73 60
61float EmulationAspectRatio(Aspect aspect, float window_aspect_ratio) {
62 switch (aspect) {
63 case Aspect::Default:
64 return static_cast<float>(ScreenUndocked::Height) / ScreenUndocked::Width;
65 case Aspect::Aspect21by9:
66 return 9.0f / 21.0f;
67 case Aspect::StretchToWindow:
68 return window_aspect_ratio;
69 default:
70 return static_cast<float>(ScreenUndocked::Height) / ScreenUndocked::Width;
71 }
72}
73
74} // namespace Layout 74} // namespace Layout
diff --git a/src/core/frontend/framebuffer_layout.h b/src/core/frontend/framebuffer_layout.h
index 948c140ac..7f6fbe468 100644
--- a/src/core/frontend/framebuffer_layout.h
+++ b/src/core/frontend/framebuffer_layout.h
@@ -19,9 +19,9 @@ enum ScreenDocked : u32 {
19}; 19};
20 20
21enum class Aspect { 21enum class Aspect {
22 AspectDefault, 22 Default,
23 Aspect21by9, 23 Aspect21by9,
24 AspectStretch, 24 StretchToWindow,
25}; 25};
26 26
27/// Describes the layout of the window framebuffer 27/// Describes the layout of the window framebuffer
@@ -54,4 +54,12 @@ FramebufferLayout DefaultFrameLayout(u32 width, u32 height);
54 */ 54 */
55FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale); 55FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale);
56 56
57/**
58 * Convenience method to determine emulation aspect ratio
59 * @param aspect Represents the index of aspect ratio in Settings::values.aspect_ratio
60 * @param window_aspect_ratio Current window aspect ratio
61 * @return Emulation render window aspect ratio
62 */
63float EmulationAspectRatio(Aspect aspect, float window_aspect_ratio);
64
57} // namespace Layout 65} // namespace Layout