summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/citra/emu_window/emu_window_sdl2.cpp5
-rw-r--r--src/citra_qt/bootmanager.cpp4
-rw-r--r--src/core/3ds.h21
-rw-r--r--src/core/CMakeLists.txt2
-rw-r--r--src/core/frontend/emu_window.cpp48
-rw-r--r--src/core/frontend/emu_window.h6
-rw-r--r--src/core/frontend/framebuffer_layout.cpp170
-rw-r--r--src/core/frontend/framebuffer_layout.h66
8 files changed, 43 insertions, 279 deletions
diff --git a/src/citra/emu_window/emu_window_sdl2.cpp b/src/citra/emu_window/emu_window_sdl2.cpp
index 25643715a..e65b04e4b 100644
--- a/src/citra/emu_window/emu_window_sdl2.cpp
+++ b/src/citra/emu_window/emu_window_sdl2.cpp
@@ -12,7 +12,6 @@
12#include "common/logging/log.h" 12#include "common/logging/log.h"
13#include "common/scm_rev.h" 13#include "common/scm_rev.h"
14#include "common/string_util.h" 14#include "common/string_util.h"
15#include "core/3ds.h"
16#include "core/settings.h" 15#include "core/settings.h"
17#include "input_common/keyboard.h" 16#include "input_common/keyboard.h"
18#include "input_common/main.h" 17#include "input_common/main.h"
@@ -79,13 +78,13 @@ EmuWindow_SDL2::EmuWindow_SDL2() {
79 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); 78 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
80 SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0); 79 SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0);
81 80
82 std::string window_title = Common::StringFromFormat("Citra %s| %s-%s ", Common::g_build_name, 81 std::string window_title = Common::StringFromFormat("yuzu %s| %s-%s ", Common::g_build_name,
83 Common::g_scm_branch, Common::g_scm_desc); 82 Common::g_scm_branch, Common::g_scm_desc);
84 render_window = 83 render_window =
85 SDL_CreateWindow(window_title.c_str(), 84 SDL_CreateWindow(window_title.c_str(),
86 SDL_WINDOWPOS_UNDEFINED, // x position 85 SDL_WINDOWPOS_UNDEFINED, // x position
87 SDL_WINDOWPOS_UNDEFINED, // y position 86 SDL_WINDOWPOS_UNDEFINED, // y position
88 Core::kScreenTopWidth, Core::kScreenTopHeight + Core::kScreenBottomHeight, 87 Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height,
89 SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); 88 SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
90 89
91 if (render_window == nullptr) { 90 if (render_window == nullptr) {
diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp
index 7107bfc60..eb542ad4e 100644
--- a/src/citra_qt/bootmanager.cpp
+++ b/src/citra_qt/bootmanager.cpp
@@ -12,8 +12,8 @@
12#include "common/microprofile.h" 12#include "common/microprofile.h"
13#include "common/scm_rev.h" 13#include "common/scm_rev.h"
14#include "common/string_util.h" 14#include "common/string_util.h"
15#include "core/3ds.h"
16#include "core/core.h" 15#include "core/core.h"
16#include "core/frontend/framebuffer_layout.h"
17#include "core/settings.h" 17#include "core/settings.h"
18#include "input_common/keyboard.h" 18#include "input_common/keyboard.h"
19#include "input_common/main.h" 19#include "input_common/main.h"
@@ -271,7 +271,7 @@ void GRenderWindow::InitRenderTarget() {
271 child = new GGLWidgetInternal(fmt, this); 271 child = new GGLWidgetInternal(fmt, this);
272 QBoxLayout* layout = new QHBoxLayout(this); 272 QBoxLayout* layout = new QHBoxLayout(this);
273 273
274 resize(Core::kScreenTopWidth, Core::kScreenTopHeight + Core::kScreenBottomHeight); 274 resize(Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height);
275 layout->addWidget(child); 275 layout->addWidget(child);
276 layout->setMargin(0); 276 layout->setMargin(0);
277 setLayout(layout); 277 setLayout(layout);
diff --git a/src/core/3ds.h b/src/core/3ds.h
deleted file mode 100644
index 8715e27db..000000000
--- a/src/core/3ds.h
+++ /dev/null
@@ -1,21 +0,0 @@
1// Copyright 2017 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7namespace Core {
8
9// 3DS Video Constants
10// -------------------
11
12// NOTE: The LCDs actually rotate the image 90 degrees when displaying. Because of that the
13// framebuffers in video memory are stored in column-major order and rendered sideways, causing
14// the widths and heights of the framebuffers read by the LCD to be switched compared to the
15// heights and widths of the screens listed here.
16constexpr int kScreenTopWidth = 400; ///< 3DS top screen width
17constexpr int kScreenTopHeight = 240; ///< 3DS top screen height
18constexpr int kScreenBottomWidth = 320; ///< 3DS bottom screen width
19constexpr int kScreenBottomHeight = 240; ///< 3DS bottom screen height
20
21} // namespace Core
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index c836c0196..9a9aa3539 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -10,7 +10,6 @@ set(SRCS
10 file_sys/savedata_archive.cpp 10 file_sys/savedata_archive.cpp
11 file_sys/title_metadata.cpp 11 file_sys/title_metadata.cpp
12 frontend/emu_window.cpp 12 frontend/emu_window.cpp
13 frontend/framebuffer_layout.cpp
14 gdbstub/gdbstub.cpp 13 gdbstub/gdbstub.cpp
15 hle/config_mem.cpp 14 hle/config_mem.cpp
16 hle/kernel/address_arbiter.cpp 15 hle/kernel/address_arbiter.cpp
@@ -77,7 +76,6 @@ set(SRCS
77 ) 76 )
78 77
79set(HEADERS 78set(HEADERS
80 3ds.h
81 arm/arm_interface.h 79 arm/arm_interface.h
82 arm/dynarmic/arm_dynarmic.h 80 arm/dynarmic/arm_dynarmic.h
83 arm/unicorn/arm_unicorn.h 81 arm/unicorn/arm_unicorn.h
diff --git a/src/core/frontend/emu_window.cpp b/src/core/frontend/emu_window.cpp
index e67394177..2d776c693 100644
--- a/src/core/frontend/emu_window.cpp
+++ b/src/core/frontend/emu_window.cpp
@@ -41,7 +41,8 @@ private:
41 41
42EmuWindow::EmuWindow() { 42EmuWindow::EmuWindow() {
43 // TODO: Find a better place to set this. 43 // TODO: Find a better place to set this.
44 config.min_client_area_size = std::make_pair(400u, 480u); 44 config.min_client_area_size =
45 std::make_pair(Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height);
45 active_config = config; 46 active_config = config;
46 touch_state = std::make_shared<TouchState>(); 47 touch_state = std::make_shared<TouchState>();
47 Input::RegisterFactory<Input::TouchDevice>("emu_window", touch_state); 48 Input::RegisterFactory<Input::TouchDevice>("emu_window", touch_state);
@@ -60,17 +61,16 @@ EmuWindow::~EmuWindow() {
60 */ 61 */
61static bool IsWithinTouchscreen(const Layout::FramebufferLayout& layout, unsigned framebuffer_x, 62static bool IsWithinTouchscreen(const Layout::FramebufferLayout& layout, unsigned framebuffer_x,
62 unsigned framebuffer_y) { 63 unsigned framebuffer_y) {
63 return ( 64 return (framebuffer_y >= layout.screen.top && framebuffer_y < layout.screen.bottom &&
64 framebuffer_y >= layout.bottom_screen.top && framebuffer_y < layout.bottom_screen.bottom && 65 framebuffer_x >= layout.screen.left && framebuffer_x < layout.screen.right);
65 framebuffer_x >= layout.bottom_screen.left && framebuffer_x < layout.bottom_screen.right);
66} 66}
67 67
68std::tuple<unsigned, unsigned> EmuWindow::ClipToTouchScreen(unsigned new_x, unsigned new_y) { 68std::tuple<unsigned, unsigned> EmuWindow::ClipToTouchScreen(unsigned new_x, unsigned new_y) {
69 new_x = std::max(new_x, framebuffer_layout.bottom_screen.left); 69 new_x = std::max(new_x, framebuffer_layout.screen.left);
70 new_x = std::min(new_x, framebuffer_layout.bottom_screen.right - 1); 70 new_x = std::min(new_x, framebuffer_layout.screen.right - 1);
71 71
72 new_y = std::max(new_y, framebuffer_layout.bottom_screen.top); 72 new_y = std::max(new_y, framebuffer_layout.screen.top);
73 new_y = std::min(new_y, framebuffer_layout.bottom_screen.bottom - 1); 73 new_y = std::min(new_y, framebuffer_layout.screen.bottom - 1);
74 74
75 return std::make_tuple(new_x, new_y); 75 return std::make_tuple(new_x, new_y);
76} 76}
@@ -80,12 +80,10 @@ void EmuWindow::TouchPressed(unsigned framebuffer_x, unsigned framebuffer_y) {
80 return; 80 return;
81 81
82 std::lock_guard<std::mutex> guard(touch_state->mutex); 82 std::lock_guard<std::mutex> guard(touch_state->mutex);
83 touch_state->touch_x = 83 touch_state->touch_x = static_cast<float>(framebuffer_x - framebuffer_layout.screen.left) /
84 static_cast<float>(framebuffer_x - framebuffer_layout.bottom_screen.left) / 84 (framebuffer_layout.screen.right - framebuffer_layout.screen.left);
85 (framebuffer_layout.bottom_screen.right - framebuffer_layout.bottom_screen.left); 85 touch_state->touch_y = static_cast<float>(framebuffer_y - framebuffer_layout.screen.top) /
86 touch_state->touch_y = 86 (framebuffer_layout.screen.bottom - framebuffer_layout.screen.top);
87 static_cast<float>(framebuffer_y - framebuffer_layout.bottom_screen.top) /
88 (framebuffer_layout.bottom_screen.bottom - framebuffer_layout.bottom_screen.top);
89 87
90 touch_state->touch_pressed = true; 88 touch_state->touch_pressed = true;
91} 89}
@@ -108,25 +106,5 @@ void EmuWindow::TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y) {
108} 106}
109 107
110void EmuWindow::UpdateCurrentFramebufferLayout(unsigned width, unsigned height) { 108void EmuWindow::UpdateCurrentFramebufferLayout(unsigned width, unsigned height) {
111 Layout::FramebufferLayout layout; 109 NotifyFramebufferLayoutChanged(Layout::DefaultFrameLayout(width, height));
112 if (Settings::values.custom_layout == true) {
113 layout = Layout::CustomFrameLayout(width, height);
114 } else {
115 switch (Settings::values.layout_option) {
116 case Settings::LayoutOption::SingleScreen:
117 layout = Layout::SingleFrameLayout(width, height, Settings::values.swap_screen);
118 break;
119 case Settings::LayoutOption::LargeScreen:
120 layout = Layout::LargeFrameLayout(width, height, Settings::values.swap_screen);
121 break;
122 case Settings::LayoutOption::SideScreen:
123 layout = Layout::SideFrameLayout(width, height, Settings::values.swap_screen);
124 break;
125 case Settings::LayoutOption::Default:
126 default:
127 layout = Layout::DefaultFrameLayout(width, height, Settings::values.swap_screen);
128 break;
129 }
130 }
131 NotifyFramebufferLayoutChanged(layout);
132} 110}
diff --git a/src/core/frontend/emu_window.h b/src/core/frontend/emu_window.h
index c10dee51b..e8c29adfb 100644
--- a/src/core/frontend/emu_window.h
+++ b/src/core/frontend/emu_window.h
@@ -87,9 +87,9 @@ public:
87 } 87 }
88 88
89 /** 89 /**
90 * Gets the framebuffer layout (width, height, and screen regions) 90 * Gets the framebuffer layout (width, height, and screen regions)
91 * @note This method is thread-safe 91 * @note This method is thread-safe
92 */ 92 */
93 const Layout::FramebufferLayout& GetFramebufferLayout() const { 93 const Layout::FramebufferLayout& GetFramebufferLayout() const {
94 return framebuffer_layout; 94 return framebuffer_layout;
95 } 95 }
diff --git a/src/core/frontend/framebuffer_layout.cpp b/src/core/frontend/framebuffer_layout.cpp
index e9f778fcb..8551858d1 100644
--- a/src/core/frontend/framebuffer_layout.cpp
+++ b/src/core/frontend/framebuffer_layout.cpp
@@ -1,25 +1,12 @@
1// Copyright 2016 Citra Emulator Project 1// Copyright 2018 Yuzu Emulator Team
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <cmath>
6
7#include "common/assert.h" 5#include "common/assert.h"
8#include "core/3ds.h"
9#include "core/frontend/framebuffer_layout.h" 6#include "core/frontend/framebuffer_layout.h"
10#include "core/settings.h"
11 7
12namespace Layout { 8namespace Layout {
13 9
14static const float TOP_SCREEN_ASPECT_RATIO =
15 static_cast<float>(Core::kScreenTopHeight) / Core::kScreenTopWidth;
16static const float BOT_SCREEN_ASPECT_RATIO =
17 static_cast<float>(Core::kScreenBottomHeight) / Core::kScreenBottomWidth;
18
19float FramebufferLayout::GetScalingRatio() const {
20 return static_cast<float>(top_screen.GetWidth()) / Core::kScreenTopWidth;
21}
22
23// Finds the largest size subrectangle contained in window area that is confined to the aspect ratio 10// Finds the largest size subrectangle contained in window area that is confined to the aspect ratio
24template <class T> 11template <class T>
25static MathUtil::Rectangle<T> maxRectangle(MathUtil::Rectangle<T> window_area, 12static MathUtil::Rectangle<T> maxRectangle(MathUtil::Rectangle<T> window_area,
@@ -30,166 +17,27 @@ static MathUtil::Rectangle<T> maxRectangle(MathUtil::Rectangle<T> window_area,
30 static_cast<T>(std::round(scale * screen_aspect_ratio))}; 17 static_cast<T>(std::round(scale * screen_aspect_ratio))};
31} 18}
32 19
33FramebufferLayout DefaultFrameLayout(unsigned width, unsigned height, bool swapped) { 20FramebufferLayout DefaultFrameLayout(unsigned width, unsigned height) {
34 ASSERT(width > 0);
35 ASSERT(height > 0);
36
37 FramebufferLayout res{width, height, true, true, {}, {}};
38 // Default layout gives equal screen sizes to the top and bottom screen
39 MathUtil::Rectangle<unsigned> screen_window_area{0, 0, width, height / 2};
40 MathUtil::Rectangle<unsigned> top_screen =
41 maxRectangle(screen_window_area, TOP_SCREEN_ASPECT_RATIO);
42 MathUtil::Rectangle<unsigned> bot_screen =
43 maxRectangle(screen_window_area, BOT_SCREEN_ASPECT_RATIO);
44
45 float window_aspect_ratio = static_cast<float>(height) / width;
46 // both screens height are taken into account by multiplying by 2
47 float emulation_aspect_ratio = TOP_SCREEN_ASPECT_RATIO * 2;
48
49 if (window_aspect_ratio < emulation_aspect_ratio) {
50 // Apply borders to the left and right sides of the window.
51 top_screen =
52 top_screen.TranslateX((screen_window_area.GetWidth() - top_screen.GetWidth()) / 2);
53 bot_screen =
54 bot_screen.TranslateX((screen_window_area.GetWidth() - bot_screen.GetWidth()) / 2);
55 } else {
56 // Window is narrower than the emulation content => apply borders to the top and bottom
57 // Recalculate the bottom screen to account for the width difference between top and bottom
58 screen_window_area = {0, 0, width, top_screen.GetHeight()};
59 bot_screen = maxRectangle(screen_window_area, BOT_SCREEN_ASPECT_RATIO);
60 bot_screen = bot_screen.TranslateX((top_screen.GetWidth() - bot_screen.GetWidth()) / 2);
61 if (swapped) {
62 bot_screen = bot_screen.TranslateY(height / 2 - bot_screen.GetHeight());
63 } else {
64 top_screen = top_screen.TranslateY(height / 2 - top_screen.GetHeight());
65 }
66 }
67 // Move the top screen to the bottom if we are swapped.
68 res.top_screen = swapped ? top_screen.TranslateY(height / 2) : top_screen;
69 res.bottom_screen = swapped ? bot_screen : bot_screen.TranslateY(height / 2);
70 return res;
71}
72
73FramebufferLayout SingleFrameLayout(unsigned width, unsigned height, bool swapped) {
74 ASSERT(width > 0); 21 ASSERT(width > 0);
75 ASSERT(height > 0); 22 ASSERT(height > 0);
76 // The drawing code needs at least somewhat valid values for both screens 23 // The drawing code needs at least somewhat valid values for both screens
77 // so just calculate them both even if the other isn't showing. 24 // so just calculate them both even if the other isn't showing.
78 FramebufferLayout res{width, height, !swapped, swapped, {}, {}}; 25 FramebufferLayout res{width, height};
79
80 MathUtil::Rectangle<unsigned> screen_window_area{0, 0, width, height};
81 MathUtil::Rectangle<unsigned> top_screen =
82 maxRectangle(screen_window_area, TOP_SCREEN_ASPECT_RATIO);
83 MathUtil::Rectangle<unsigned> bot_screen =
84 maxRectangle(screen_window_area, BOT_SCREEN_ASPECT_RATIO);
85
86 float window_aspect_ratio = static_cast<float>(height) / width;
87 float emulation_aspect_ratio = (swapped) ? BOT_SCREEN_ASPECT_RATIO : TOP_SCREEN_ASPECT_RATIO;
88
89 if (window_aspect_ratio < emulation_aspect_ratio) {
90 top_screen =
91 top_screen.TranslateX((screen_window_area.GetWidth() - top_screen.GetWidth()) / 2);
92 bot_screen =
93 bot_screen.TranslateX((screen_window_area.GetWidth() - bot_screen.GetWidth()) / 2);
94 } else {
95 top_screen = top_screen.TranslateY((height - top_screen.GetHeight()) / 2);
96 bot_screen = bot_screen.TranslateY((height - bot_screen.GetHeight()) / 2);
97 }
98 res.top_screen = top_screen;
99 res.bottom_screen = bot_screen;
100 return res;
101}
102
103FramebufferLayout LargeFrameLayout(unsigned width, unsigned height, bool swapped) {
104 ASSERT(width > 0);
105 ASSERT(height > 0);
106
107 FramebufferLayout res{width, height, true, true, {}, {}};
108 // Split the window into two parts. Give 4x width to the main screen and 1x width to the small
109 // To do that, find the total emulation box and maximize that based on window size
110 float window_aspect_ratio = static_cast<float>(height) / width;
111 float emulation_aspect_ratio =
112 swapped
113 ? Core::kScreenBottomHeight * 4 /
114 (Core::kScreenBottomWidth * 4.0f + Core::kScreenTopWidth)
115 : Core::kScreenTopHeight * 4 /
116 (Core::kScreenTopWidth * 4.0f + Core::kScreenBottomWidth);
117 float large_screen_aspect_ratio = swapped ? BOT_SCREEN_ASPECT_RATIO : TOP_SCREEN_ASPECT_RATIO;
118 float small_screen_aspect_ratio = swapped ? TOP_SCREEN_ASPECT_RATIO : BOT_SCREEN_ASPECT_RATIO;
119 26
27 const float emulation_aspect_ratio{static_cast<float>(ScreenUndocked::Height) /
28 ScreenUndocked::Width};
120 MathUtil::Rectangle<unsigned> screen_window_area{0, 0, width, height}; 29 MathUtil::Rectangle<unsigned> screen_window_area{0, 0, width, height};
121 MathUtil::Rectangle<unsigned> total_rect = 30 MathUtil::Rectangle<unsigned> screen = maxRectangle(screen_window_area, emulation_aspect_ratio);
122 maxRectangle(screen_window_area, emulation_aspect_ratio);
123 MathUtil::Rectangle<unsigned> large_screen =
124 maxRectangle(total_rect, large_screen_aspect_ratio);
125 MathUtil::Rectangle<unsigned> fourth_size_rect = total_rect.Scale(.25f);
126 MathUtil::Rectangle<unsigned> small_screen =
127 maxRectangle(fourth_size_rect, small_screen_aspect_ratio);
128
129 if (window_aspect_ratio < emulation_aspect_ratio) {
130 large_screen =
131 large_screen.TranslateX((screen_window_area.GetWidth() - total_rect.GetWidth()) / 2);
132 } else {
133 large_screen = large_screen.TranslateY((height - total_rect.GetHeight()) / 2);
134 }
135 // Shift the small screen to the bottom right corner
136 small_screen =
137 small_screen.TranslateX(large_screen.right)
138 .TranslateY(large_screen.GetHeight() + large_screen.top - small_screen.GetHeight());
139 res.top_screen = swapped ? small_screen : large_screen;
140 res.bottom_screen = swapped ? large_screen : small_screen;
141 return res;
142}
143
144FramebufferLayout SideFrameLayout(unsigned width, unsigned height, bool swapped) {
145 ASSERT(width > 0);
146 ASSERT(height > 0);
147 31
148 FramebufferLayout res{width, height, true, true, {}, {}};
149 // Aspect ratio of both screens side by side
150 const float emulation_aspect_ratio = static_cast<float>(Core::kScreenTopHeight) /
151 (Core::kScreenTopWidth + Core::kScreenBottomWidth);
152 float window_aspect_ratio = static_cast<float>(height) / width; 32 float window_aspect_ratio = static_cast<float>(height) / width;
153 MathUtil::Rectangle<unsigned> screen_window_area{0, 0, width, height};
154 // Find largest Rectangle that can fit in the window size with the given aspect ratio
155 MathUtil::Rectangle<unsigned> screen_rect =
156 maxRectangle(screen_window_area, emulation_aspect_ratio);
157 // Find sizes of top and bottom screen
158 MathUtil::Rectangle<unsigned> top_screen = maxRectangle(screen_rect, TOP_SCREEN_ASPECT_RATIO);
159 MathUtil::Rectangle<unsigned> bot_screen = maxRectangle(screen_rect, BOT_SCREEN_ASPECT_RATIO);
160 33
161 if (window_aspect_ratio < emulation_aspect_ratio) { 34 if (window_aspect_ratio < emulation_aspect_ratio) {
162 // Apply borders to the left and right sides of the window. 35 screen = screen.TranslateX((screen_window_area.GetWidth() - screen.GetWidth()) / 2);
163 u32 shift_horizontal = (screen_window_area.GetWidth() - screen_rect.GetWidth()) / 2;
164 top_screen = top_screen.TranslateX(shift_horizontal);
165 bot_screen = bot_screen.TranslateX(shift_horizontal);
166 } else { 36 } else {
167 // Window is narrower than the emulation content => apply borders to the top and bottom 37 screen = screen.TranslateY((height - screen.GetHeight()) / 2);
168 u32 shift_vertical = (screen_window_area.GetHeight() - screen_rect.GetHeight()) / 2;
169 top_screen = top_screen.TranslateY(shift_vertical);
170 bot_screen = bot_screen.TranslateY(shift_vertical);
171 } 38 }
172 // Move the top screen to the right if we are swapped. 39 res.screen = screen;
173 res.top_screen = swapped ? top_screen.TranslateX(bot_screen.GetWidth()) : top_screen;
174 res.bottom_screen = swapped ? bot_screen : bot_screen.TranslateX(top_screen.GetWidth());
175 return res; 40 return res;
176} 41}
177 42
178FramebufferLayout CustomFrameLayout(unsigned width, unsigned height) {
179 ASSERT(width > 0);
180 ASSERT(height > 0);
181
182 FramebufferLayout res{width, height, true, true, {}, {}};
183
184 MathUtil::Rectangle<unsigned> top_screen{
185 Settings::values.custom_top_left, Settings::values.custom_top_top,
186 Settings::values.custom_top_right, Settings::values.custom_top_bottom};
187 MathUtil::Rectangle<unsigned> bot_screen{
188 Settings::values.custom_bottom_left, Settings::values.custom_bottom_top,
189 Settings::values.custom_bottom_right, Settings::values.custom_bottom_bottom};
190
191 res.top_screen = top_screen;
192 res.bottom_screen = bot_screen;
193 return res;
194}
195} // namespace Layout 43} // namespace Layout
diff --git a/src/core/frontend/framebuffer_layout.h b/src/core/frontend/framebuffer_layout.h
index 4983cf103..b06999e1b 100644
--- a/src/core/frontend/framebuffer_layout.h
+++ b/src/core/frontend/framebuffer_layout.h
@@ -1,4 +1,4 @@
1// Copyright 2016 Citra Emulator Project 1// Copyright 2018 Yuzu Emulator Team
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
@@ -8,68 +8,30 @@
8 8
9namespace Layout { 9namespace Layout {
10 10
11/// Describes the layout of the window framebuffer (size and top/bottom screen positions) 11enum ScreenUndocked : unsigned { Width = 1280, Height = 720 };
12
13/// Describes the layout of the window framebuffer
12struct FramebufferLayout { 14struct FramebufferLayout {
13 unsigned width; 15 unsigned width{ScreenUndocked::Width};
14 unsigned height; 16 unsigned height{ScreenUndocked::Height};
15 bool top_screen_enabled; 17
16 bool bottom_screen_enabled; 18 MathUtil::Rectangle<unsigned> screen;
17 MathUtil::Rectangle<unsigned> top_screen;
18 MathUtil::Rectangle<unsigned> bottom_screen;
19 19
20 /** 20 /**
21 * Returns the ration of pixel size of the top screen, compared to the native size of the 3DS 21 * Returns the ration of pixel size of the screen, compared to the native size of the undocked
22 * screen. 22 * Switch screen.
23 */ 23 */
24 float GetScalingRatio() const; 24 float GetScalingRatio() const {
25 return static_cast<float>(screen.GetWidth()) / ScreenUndocked::Width;
26 }
25}; 27};
26 28
27/** 29/**
28 * Factory method for constructing a default FramebufferLayout 30 * Factory method for constructing a default FramebufferLayout
29 * @param width Window framebuffer width in pixels 31 * @param width Window framebuffer width in pixels
30 * @param height Window framebuffer height in pixels 32 * @param height Window framebuffer height in pixels
31 * @param is_swapped if true, the bottom screen will be displayed above the top screen
32 * @return Newly created FramebufferLayout object with default screen regions initialized
33 */
34FramebufferLayout DefaultFrameLayout(unsigned width, unsigned height, bool is_swapped);
35
36/**
37 * Factory method for constructing a FramebufferLayout with only the top or bottom screen
38 * @param width Window framebuffer width in pixels
39 * @param height Window framebuffer height in pixels
40 * @param is_swapped if true, the bottom screen will be displayed (and the top won't be displayed)
41 * @return Newly created FramebufferLayout object with default screen regions initialized
42 */
43FramebufferLayout SingleFrameLayout(unsigned width, unsigned height, bool is_swapped);
44
45/**
46 * Factory method for constructing a Frame with the a 4x size Top screen with a 1x size bottom
47 * screen on the right
48 * This is useful in particular because it matches well with a 1920x1080 resolution monitor
49 * @param width Window framebuffer width in pixels
50 * @param height Window framebuffer height in pixels
51 * @param is_swapped if true, the bottom screen will be the large display
52 * @return Newly created FramebufferLayout object with default screen regions initialized
53 */
54FramebufferLayout LargeFrameLayout(unsigned width, unsigned height, bool is_swapped);
55
56/**
57* Factory method for constructing a Frame with the Top screen and bottom
58* screen side by side
59* This is useful for devices with small screens, like the GPDWin
60* @param width Window framebuffer width in pixels
61* @param height Window framebuffer height in pixels
62* @param is_swapped if true, the bottom screen will be the left display
63* @return Newly created FramebufferLayout object with default screen regions initialized
64*/
65FramebufferLayout SideFrameLayout(unsigned width, unsigned height, bool is_swapped);
66
67/**
68 * Factory method for constructing a custom FramebufferLayout
69 * @param width Window framebuffer width in pixels
70 * @param height Window framebuffer height in pixels
71 * @return Newly created FramebufferLayout object with default screen regions initialized 33 * @return Newly created FramebufferLayout object with default screen regions initialized
72 */ 34 */
73FramebufferLayout CustomFrameLayout(unsigned width, unsigned height); 35FramebufferLayout DefaultFrameLayout(unsigned width, unsigned height);
74 36
75} // namespace Layout 37} // namespace Layout