summaryrefslogtreecommitdiffstats
path: root/src/core/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/frontend')
-rw-r--r--src/core/frontend/framebuffer_layout.cpp22
-rw-r--r--src/core/frontend/framebuffer_layout.h13
2 files changed, 14 insertions, 21 deletions
diff --git a/src/core/frontend/framebuffer_layout.cpp b/src/core/frontend/framebuffer_layout.cpp
index 0832463d6..26a5b12aa 100644
--- a/src/core/frontend/framebuffer_layout.cpp
+++ b/src/core/frontend/framebuffer_layout.cpp
@@ -25,7 +25,12 @@ FramebufferLayout DefaultFrameLayout(u32 width, u32 height) {
ASSERT(height > 0);
// The drawing code needs at least somewhat valid values for both screens
// so just calculate them both even if the other isn't showing.
- FramebufferLayout res{width, height, false, {}};
+ FramebufferLayout res{
+ .width = width,
+ .height = height,
+ .screen = {},
+ .is_srgb = false,
+ };
const float window_aspect_ratio = static_cast<float>(height) / static_cast<float>(width);
const float emulation_aspect_ratio = EmulationAspectRatio(
@@ -44,16 +49,13 @@ FramebufferLayout DefaultFrameLayout(u32 width, u32 height) {
return res;
}
-FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale) {
- u32 width, height;
+FramebufferLayout FrameLayoutFromResolutionScale(f32 res_scale) {
+ const bool is_docked = Settings::values.use_docked_mode.GetValue();
+ const u32 screen_width = is_docked ? ScreenDocked::Width : ScreenUndocked::Width;
+ const u32 screen_height = is_docked ? ScreenDocked::Height : ScreenUndocked::Height;
- if (Settings::values.use_docked_mode.GetValue()) {
- width = ScreenDocked::Width * res_scale;
- height = ScreenDocked::Height * res_scale;
- } else {
- width = ScreenUndocked::Width * res_scale;
- height = ScreenUndocked::Height * res_scale;
- }
+ const u32 width = static_cast<u32>(static_cast<f32>(screen_width) * res_scale);
+ const u32 height = static_cast<u32>(static_cast<f32>(screen_height) * res_scale);
return DefaultFrameLayout(width, height);
}
diff --git a/src/core/frontend/framebuffer_layout.h b/src/core/frontend/framebuffer_layout.h
index e2e3bbbb3..8e341e4e2 100644
--- a/src/core/frontend/framebuffer_layout.h
+++ b/src/core/frontend/framebuffer_layout.h
@@ -35,17 +35,8 @@ enum class AspectRatio {
struct FramebufferLayout {
u32 width{ScreenUndocked::Width};
u32 height{ScreenUndocked::Height};
- bool is_srgb{};
-
Common::Rectangle<u32> screen;
-
- /**
- * Returns the ration of pixel size of the screen, compared to the native size of the undocked
- * Switch screen.
- */
- float GetScalingRatio() const {
- return static_cast<float>(screen.GetWidth()) / ScreenUndocked::Width;
- }
+ bool is_srgb{};
};
/**
@@ -60,7 +51,7 @@ FramebufferLayout DefaultFrameLayout(u32 width, u32 height);
* Convenience method to get frame layout by resolution scale
* @param res_scale resolution scale factor
*/
-FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale);
+FramebufferLayout FrameLayoutFromResolutionScale(f32 res_scale);
/**
* Convenience method to determine emulation aspect ratio