diff options
Diffstat (limited to '')
| -rw-r--r-- | src/citra/config.cpp | 4 | ||||
| -rw-r--r-- | src/citra/default_ini.h | 10 | ||||
| -rw-r--r-- | src/citra/emu_window/emu_window_sdl2.cpp | 5 | ||||
| -rw-r--r-- | src/citra_qt/bootmanager.cpp | 4 | ||||
| -rw-r--r-- | src/citra_qt/config.cpp | 10 | ||||
| -rw-r--r-- | src/citra_qt/configure_dialog.cpp | 1 | ||||
| -rw-r--r-- | src/citra_qt/configure_graphics.cpp | 4 | ||||
| -rw-r--r-- | src/citra_qt/configure_graphics.ui | 115 | ||||
| -rw-r--r-- | src/common/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/common/emu_window.cpp | 68 | ||||
| -rw-r--r-- | src/common/emu_window.h | 30 | ||||
| -rw-r--r-- | src/common/framebuffer_layout.cpp | 312 | ||||
| -rw-r--r-- | src/common/framebuffer_layout.h | 43 | ||||
| -rw-r--r-- | src/core/settings.cpp | 7 | ||||
| -rw-r--r-- | src/core/settings.h | 11 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.cpp | 18 |
16 files changed, 517 insertions, 127 deletions
diff --git a/src/citra/config.cpp b/src/citra/config.cpp index 05eabfa3d..305e3ba53 100644 --- a/src/citra/config.cpp +++ b/src/citra/config.cpp | |||
| @@ -72,6 +72,10 @@ void Config::ReadValues() { | |||
| 72 | Settings::values.bg_green = (float)sdl2_config->GetReal("Renderer", "bg_green", 1.0); | 72 | Settings::values.bg_green = (float)sdl2_config->GetReal("Renderer", "bg_green", 1.0); |
| 73 | Settings::values.bg_blue = (float)sdl2_config->GetReal("Renderer", "bg_blue", 1.0); | 73 | Settings::values.bg_blue = (float)sdl2_config->GetReal("Renderer", "bg_blue", 1.0); |
| 74 | 74 | ||
| 75 | // Layout | ||
| 76 | Settings::values.layout_option = static_cast<Settings::LayoutOption>(sdl2_config->GetInteger("Layout", "layout_option", 0)); | ||
| 77 | Settings::values.swap_screen = sdl2_config->GetBoolean("Layout", "swap_screen", false); | ||
| 78 | |||
| 75 | // Audio | 79 | // Audio |
| 76 | Settings::values.sink_id = sdl2_config->Get("Audio", "output_engine", "auto"); | 80 | Settings::values.sink_id = sdl2_config->Get("Audio", "output_engine", "auto"); |
| 77 | Settings::values.enable_audio_stretching = | 81 | Settings::values.enable_audio_stretching = |
diff --git a/src/citra/default_ini.h b/src/citra/default_ini.h index 0b49e0230..b22627a2f 100644 --- a/src/citra/default_ini.h +++ b/src/citra/default_ini.h | |||
| @@ -63,6 +63,16 @@ use_scaled_resolution = | |||
| 63 | # 0 (default): Off, 1: On | 63 | # 0 (default): Off, 1: On |
| 64 | use_vsync = | 64 | use_vsync = |
| 65 | 65 | ||
| 66 | [Layout] | ||
| 67 | # Layout for the screen inside the render window. | ||
| 68 | # 0 (default): Default Top Bottom Screen, 1: Single Screen Only, 2: Large Screen Small Screen | ||
| 69 | layout_option = | ||
| 70 | |||
| 71 | # Swaps the prominent screen with the other screen. | ||
| 72 | # For example, if Single Screen is chosen, setting this to 1 will display the bottom screen instead of the top screen. | ||
| 73 | # 0 (default): Top Screen is prominent, 1: Bottom Screen is prominent | ||
| 74 | swap_screen = | ||
| 75 | |||
| 66 | # The clear color for the renderer. What shows up on the sides of the bottom screen. | 76 | # The clear color for the renderer. What shows up on the sides of the bottom screen. |
| 67 | # Must be in range of 0.0-1.0. Defaults to 1.0 for all. | 77 | # Must be in range of 0.0-1.0. Defaults to 1.0 for all. |
| 68 | bg_red = | 78 | bg_red = |
diff --git a/src/citra/emu_window/emu_window_sdl2.cpp b/src/citra/emu_window/emu_window_sdl2.cpp index 7df054208..8abe48984 100644 --- a/src/citra/emu_window/emu_window_sdl2.cpp +++ b/src/citra/emu_window/emu_window_sdl2.cpp | |||
| @@ -46,11 +46,8 @@ bool EmuWindow_SDL2::IsOpen() const { | |||
| 46 | 46 | ||
| 47 | void EmuWindow_SDL2::OnResize() { | 47 | void EmuWindow_SDL2::OnResize() { |
| 48 | int width, height; | 48 | int width, height; |
| 49 | |||
| 50 | SDL_GetWindowSize(render_window, &width, &height); | 49 | SDL_GetWindowSize(render_window, &width, &height); |
| 51 | 50 | UpdateCurrentFramebufferLayout(width, height); | |
| 52 | NotifyFramebufferLayoutChanged( | ||
| 53 | EmuWindow::FramebufferLayout::DefaultScreenLayout(width, height)); | ||
| 54 | } | 51 | } |
| 55 | 52 | ||
| 56 | EmuWindow_SDL2::EmuWindow_SDL2() { | 53 | EmuWindow_SDL2::EmuWindow_SDL2() { |
diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index 0abae86c3..7699ca8d0 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp | |||
| @@ -161,9 +161,7 @@ void GRenderWindow::OnFramebufferSizeChanged() { | |||
| 161 | qreal pixelRatio = windowPixelRatio(); | 161 | qreal pixelRatio = windowPixelRatio(); |
| 162 | unsigned width = child->QPaintDevice::width() * pixelRatio; | 162 | unsigned width = child->QPaintDevice::width() * pixelRatio; |
| 163 | unsigned height = child->QPaintDevice::height() * pixelRatio; | 163 | unsigned height = child->QPaintDevice::height() * pixelRatio; |
| 164 | 164 | UpdateCurrentFramebufferLayout(width, height); | |
| 165 | NotifyFramebufferLayoutChanged( | ||
| 166 | EmuWindow::FramebufferLayout::DefaultScreenLayout(width, height)); | ||
| 167 | } | 165 | } |
| 168 | 166 | ||
| 169 | void GRenderWindow::BackupGeometry() { | 167 | void GRenderWindow::BackupGeometry() { |
diff --git a/src/citra_qt/config.cpp b/src/citra_qt/config.cpp index 0b46ca6bb..f4f1a354d 100644 --- a/src/citra_qt/config.cpp +++ b/src/citra_qt/config.cpp | |||
| @@ -54,6 +54,11 @@ void Config::ReadValues() { | |||
| 54 | Settings::values.bg_blue = qt_config->value("bg_blue", 1.0).toFloat(); | 54 | Settings::values.bg_blue = qt_config->value("bg_blue", 1.0).toFloat(); |
| 55 | qt_config->endGroup(); | 55 | qt_config->endGroup(); |
| 56 | 56 | ||
| 57 | qt_config->beginGroup("Layout"); | ||
| 58 | Settings::values.layout_option = static_cast<Settings::LayoutOption>(qt_config->value("layout_option").toInt()); | ||
| 59 | Settings::values.swap_screen = qt_config->value("swap_screen", false).toBool(); | ||
| 60 | qt_config->endGroup(); | ||
| 61 | |||
| 57 | qt_config->beginGroup("Audio"); | 62 | qt_config->beginGroup("Audio"); |
| 58 | Settings::values.sink_id = qt_config->value("output_engine", "auto").toString().toStdString(); | 63 | Settings::values.sink_id = qt_config->value("output_engine", "auto").toString().toStdString(); |
| 59 | Settings::values.enable_audio_stretching = | 64 | Settings::values.enable_audio_stretching = |
| @@ -155,6 +160,11 @@ void Config::SaveValues() { | |||
| 155 | qt_config->setValue("bg_blue", (double)Settings::values.bg_blue); | 160 | qt_config->setValue("bg_blue", (double)Settings::values.bg_blue); |
| 156 | qt_config->endGroup(); | 161 | qt_config->endGroup(); |
| 157 | 162 | ||
| 163 | qt_config->beginGroup("Layout"); | ||
| 164 | qt_config->setValue("layout_option", static_cast<int>(Settings::values.layout_option)); | ||
| 165 | qt_config->setValue("swap_screen", Settings::values.swap_screen); | ||
| 166 | qt_config->endGroup(); | ||
| 167 | |||
| 158 | qt_config->beginGroup("Audio"); | 168 | qt_config->beginGroup("Audio"); |
| 159 | qt_config->setValue("output_engine", QString::fromStdString(Settings::values.sink_id)); | 169 | qt_config->setValue("output_engine", QString::fromStdString(Settings::values.sink_id)); |
| 160 | qt_config->setValue("enable_audio_stretching", Settings::values.enable_audio_stretching); | 170 | qt_config->setValue("enable_audio_stretching", Settings::values.enable_audio_stretching); |
diff --git a/src/citra_qt/configure_dialog.cpp b/src/citra_qt/configure_dialog.cpp index 446ad04a1..525a7cc4e 100644 --- a/src/citra_qt/configure_dialog.cpp +++ b/src/citra_qt/configure_dialog.cpp | |||
| @@ -23,4 +23,5 @@ void ConfigureDialog::applyConfiguration() { | |||
| 23 | ui->graphicsTab->applyConfiguration(); | 23 | ui->graphicsTab->applyConfiguration(); |
| 24 | ui->audioTab->applyConfiguration(); | 24 | ui->audioTab->applyConfiguration(); |
| 25 | ui->debugTab->applyConfiguration(); | 25 | ui->debugTab->applyConfiguration(); |
| 26 | Settings::Apply(); | ||
| 26 | } | 27 | } |
diff --git a/src/citra_qt/configure_graphics.cpp b/src/citra_qt/configure_graphics.cpp index 19c1f75c2..c6c28197e 100644 --- a/src/citra_qt/configure_graphics.cpp +++ b/src/citra_qt/configure_graphics.cpp | |||
| @@ -23,6 +23,8 @@ void ConfigureGraphics::setConfiguration() { | |||
| 23 | ui->toggle_shader_jit->setChecked(Settings::values.use_shader_jit); | 23 | ui->toggle_shader_jit->setChecked(Settings::values.use_shader_jit); |
| 24 | ui->toggle_scaled_resolution->setChecked(Settings::values.use_scaled_resolution); | 24 | ui->toggle_scaled_resolution->setChecked(Settings::values.use_scaled_resolution); |
| 25 | ui->toggle_vsync->setChecked(Settings::values.use_vsync); | 25 | ui->toggle_vsync->setChecked(Settings::values.use_vsync); |
| 26 | ui->layout_combobox->setCurrentIndex(static_cast<int>(Settings::values.layout_option)); | ||
| 27 | ui->swap_screen->setChecked(Settings::values.swap_screen); | ||
| 26 | } | 28 | } |
| 27 | 29 | ||
| 28 | void ConfigureGraphics::applyConfiguration() { | 30 | void ConfigureGraphics::applyConfiguration() { |
| @@ -30,5 +32,7 @@ void ConfigureGraphics::applyConfiguration() { | |||
| 30 | Settings::values.use_shader_jit = ui->toggle_shader_jit->isChecked(); | 32 | Settings::values.use_shader_jit = ui->toggle_shader_jit->isChecked(); |
| 31 | Settings::values.use_scaled_resolution = ui->toggle_scaled_resolution->isChecked(); | 33 | Settings::values.use_scaled_resolution = ui->toggle_scaled_resolution->isChecked(); |
| 32 | Settings::values.use_vsync = ui->toggle_vsync->isChecked(); | 34 | Settings::values.use_vsync = ui->toggle_vsync->isChecked(); |
| 35 | Settings::values.layout_option = static_cast<Settings::LayoutOption>(ui->layout_combobox->currentIndex()); | ||
| 36 | Settings::values.swap_screen = ui->swap_screen->isChecked(); | ||
| 33 | Settings::Apply(); | 37 | Settings::Apply(); |
| 34 | } | 38 | } |
diff --git a/src/citra_qt/configure_graphics.ui b/src/citra_qt/configure_graphics.ui index da6e19ce1..af16a4292 100644 --- a/src/citra_qt/configure_graphics.ui +++ b/src/citra_qt/configure_graphics.ui | |||
| @@ -22,38 +22,88 @@ | |||
| 22 | <string>Graphics</string> | 22 | <string>Graphics</string> |
| 23 | </property> | 23 | </property> |
| 24 | <layout class="QVBoxLayout" name="verticalLayout_2"> | 24 | <layout class="QVBoxLayout" name="verticalLayout_2"> |
| 25 | <item> | 25 | <item> |
| 26 | <widget class="QCheckBox" name="toggle_hw_renderer"> | 26 | <widget class="QCheckBox" name="toggle_hw_renderer"> |
| 27 | <property name="text"> | 27 | <property name="text"> |
| 28 | <string>Enable hardware renderer</string> | 28 | <string>Enable hardware renderer</string> |
| 29 | </property> | 29 | </property> |
| 30 | </widget> | ||
| 31 | </item> | ||
| 32 | <item> | ||
| 33 | <widget class="QCheckBox" name="toggle_shader_jit"> | ||
| 34 | <property name="text"> | ||
| 35 | <string>Enable shader JIT</string> | ||
| 36 | </property> | ||
| 37 | </widget> | ||
| 38 | </item> | ||
| 39 | <item> | ||
| 40 | <widget class="QCheckBox" name="toggle_scaled_resolution"> | ||
| 41 | <property name="text"> | ||
| 42 | <string>Enable scaled resolution</string> | ||
| 43 | </property> | ||
| 44 | </widget> | ||
| 45 | </item> | ||
| 46 | <item> | ||
| 47 | <widget class="QCheckBox" name="toggle_vsync"> | ||
| 48 | <property name="text"> | ||
| 49 | <string>Enable V-Sync</string> | ||
| 50 | </property> | ||
| 51 | </widget> | ||
| 52 | </item> | ||
| 53 | </layout> | ||
| 54 | </widget> | ||
| 55 | </item> | ||
| 56 | </layout> | ||
| 57 | </item> | ||
| 58 | <item> | ||
| 59 | <widget class="QGroupBox" name="groupBox2"> | ||
| 60 | <property name="title"> | ||
| 61 | <string>Layout</string> | ||
| 62 | </property> | ||
| 63 | <layout class="QHBoxLayout" name="horizontalLayout_3"> | ||
| 64 | <item> | ||
| 65 | <layout class="QVBoxLayout" name="verticalLayout_2"> | ||
| 66 | <item> | ||
| 67 | <layout class="QHBoxLayout" name="horizontalLayout_3"> | ||
| 68 | <item> | ||
| 69 | <widget class="QLabel" name="label1"> | ||
| 70 | <property name="text"> | ||
| 71 | <string>Screen Layout:</string> | ||
| 72 | </property> | ||
| 30 | </widget> | 73 | </widget> |
| 31 | </item> | 74 | </item> |
| 32 | <item> | 75 | <item> |
| 33 | <widget class="QCheckBox" name="toggle_shader_jit"> | 76 | <widget class="QComboBox" name="layout_combobox"> |
| 77 | <item> | ||
| 34 | <property name="text"> | 78 | <property name="text"> |
| 35 | <string>Enable shader JIT</string> | 79 | <string notr="true">Default</string> |
| 36 | </property> | 80 | </property> |
| 37 | </widget> | 81 | </item> |
| 38 | </item> | 82 | <item> |
| 39 | <item> | ||
| 40 | <widget class="QCheckBox" name="toggle_scaled_resolution"> | ||
| 41 | <property name="text"> | 83 | <property name="text"> |
| 42 | <string>Enable scaled resolution</string> | 84 | <string notr="true">Single Screen</string> |
| 43 | </property> | 85 | </property> |
| 44 | </widget> | 86 | </item> |
| 45 | </item> | 87 | <item> |
| 46 | <item> | ||
| 47 | <widget class="QCheckBox" name="toggle_vsync"> | ||
| 48 | <property name="text"> | 88 | <property name="text"> |
| 49 | <string>Enable V-Sync</string> | 89 | <string notr="true">Large Screen</string> |
| 50 | </property> | 90 | </property> |
| 91 | </item> | ||
| 51 | </widget> | 92 | </widget> |
| 52 | </item> | 93 | </item> |
| 94 | </layout> | ||
| 95 | </item> | ||
| 96 | <item> | ||
| 97 | <widget class="QCheckBox" name="swap_screen"> | ||
| 98 | <property name="text"> | ||
| 99 | <string>Swap Screens</string> | ||
| 100 | </property> | ||
| 101 | </widget> | ||
| 102 | </item> | ||
| 53 | </layout> | 103 | </layout> |
| 54 | </widget> | 104 | </item> |
| 55 | </item> | 105 | </layout> |
| 56 | </layout> | 106 | </widget> |
| 57 | </item> | 107 | </item> |
| 58 | <item> | 108 | <item> |
| 59 | <spacer name="verticalSpacer"> | 109 | <spacer name="verticalSpacer"> |
| @@ -71,22 +121,5 @@ | |||
| 71 | </layout> | 121 | </layout> |
| 72 | </widget> | 122 | </widget> |
| 73 | <resources/> | 123 | <resources/> |
| 74 | <connections> | 124 | <connections/> |
| 75 | <connection> | ||
| 76 | <sender>toggle_gdbstub</sender> | ||
| 77 | <signal>toggled(bool)</signal> | ||
| 78 | <receiver>gdbport_spinbox</receiver> | ||
| 79 | <slot>setEnabled(bool)</slot> | ||
| 80 | <hints> | ||
| 81 | <hint type="sourcelabel"> | ||
| 82 | <x>84</x> | ||
| 83 | <y>157</y> | ||
| 84 | </hint> | ||
| 85 | <hint type="destinationlabel"> | ||
| 86 | <x>342</x> | ||
| 87 | <y>158</y> | ||
| 88 | </hint> | ||
| 89 | </hints> | ||
| 90 | </connection> | ||
| 91 | </connections> | ||
| 92 | </ui> | 125 | </ui> |
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index aa6eee2a3..74a271f08 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt | |||
| @@ -5,6 +5,7 @@ set(SRCS | |||
| 5 | break_points.cpp | 5 | break_points.cpp |
| 6 | emu_window.cpp | 6 | emu_window.cpp |
| 7 | file_util.cpp | 7 | file_util.cpp |
| 8 | framebuffer_layout.cpp | ||
| 8 | hash.cpp | 9 | hash.cpp |
| 9 | key_map.cpp | 10 | key_map.cpp |
| 10 | logging/filter.cpp | 11 | logging/filter.cpp |
| @@ -35,6 +36,7 @@ set(HEADERS | |||
| 35 | common_types.h | 36 | common_types.h |
| 36 | emu_window.h | 37 | emu_window.h |
| 37 | file_util.h | 38 | file_util.h |
| 39 | framebuffer_layout.h | ||
| 38 | hash.h | 40 | hash.h |
| 39 | key_map.h | 41 | key_map.h |
| 40 | linear_disk_cache.h | 42 | linear_disk_cache.h |
diff --git a/src/common/emu_window.cpp b/src/common/emu_window.cpp index 122f1c212..e3a9e08e6 100644 --- a/src/common/emu_window.cpp +++ b/src/common/emu_window.cpp | |||
| @@ -40,7 +40,7 @@ void EmuWindow::CirclePadUpdated(float x, float y) { | |||
| 40 | * @param framebuffer_y Framebuffer y-coordinate to check | 40 | * @param framebuffer_y Framebuffer y-coordinate to check |
| 41 | * @return True if the coordinates are within the touchpad, otherwise false | 41 | * @return True if the coordinates are within the touchpad, otherwise false |
| 42 | */ | 42 | */ |
| 43 | static bool IsWithinTouchscreen(const EmuWindow::FramebufferLayout& layout, unsigned framebuffer_x, | 43 | static bool IsWithinTouchscreen(const Layout::FramebufferLayout& layout, unsigned framebuffer_x, |
| 44 | unsigned framebuffer_y) { | 44 | unsigned framebuffer_y) { |
| 45 | return ( | 45 | return ( |
| 46 | framebuffer_y >= layout.bottom_screen.top && framebuffer_y < layout.bottom_screen.bottom && | 46 | framebuffer_y >= layout.bottom_screen.top && framebuffer_y < layout.bottom_screen.bottom && |
| @@ -89,57 +89,19 @@ void EmuWindow::TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y) { | |||
| 89 | TouchPressed(framebuffer_x, framebuffer_y); | 89 | TouchPressed(framebuffer_x, framebuffer_y); |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | EmuWindow::FramebufferLayout EmuWindow::FramebufferLayout::DefaultScreenLayout(unsigned width, | 92 | void EmuWindow::UpdateCurrentFramebufferLayout(unsigned width, unsigned height) { |
| 93 | unsigned height) { | 93 | Layout::FramebufferLayout layout; |
| 94 | // When hiding the widget, the function receives a size of 0 | 94 | switch (Settings::values.layout_option) { |
| 95 | if (width == 0) | 95 | case Settings::LayoutOption::SingleScreen: |
| 96 | width = 1; | 96 | layout = Layout::SingleFrameLayout(width, height, Settings::values.swap_screen); |
| 97 | if (height == 0) | 97 | break; |
| 98 | height = 1; | 98 | case Settings::LayoutOption::LargeScreen: |
| 99 | 99 | layout = Layout::LargeFrameLayout(width, height, Settings::values.swap_screen); | |
| 100 | EmuWindow::FramebufferLayout res = {width, height, {}, {}}; | 100 | break; |
| 101 | 101 | case Settings::LayoutOption::Default: | |
| 102 | float window_aspect_ratio = static_cast<float>(height) / width; | 102 | default: |
| 103 | float emulation_aspect_ratio = | 103 | layout = Layout::DefaultFrameLayout(width, height, Settings::values.swap_screen); |
| 104 | static_cast<float>(VideoCore::kScreenTopHeight * 2) / VideoCore::kScreenTopWidth; | 104 | break; |
| 105 | |||
| 106 | if (window_aspect_ratio > emulation_aspect_ratio) { | ||
| 107 | // Window is narrower than the emulation content => apply borders to the top and bottom | ||
| 108 | int viewport_height = static_cast<int>(std::round(emulation_aspect_ratio * width)); | ||
| 109 | |||
| 110 | res.top_screen.left = 0; | ||
| 111 | res.top_screen.right = res.top_screen.left + width; | ||
| 112 | res.top_screen.top = (height - viewport_height) / 2; | ||
| 113 | res.top_screen.bottom = res.top_screen.top + viewport_height / 2; | ||
| 114 | |||
| 115 | int bottom_width = static_cast<int>( | ||
| 116 | (static_cast<float>(VideoCore::kScreenBottomWidth) / VideoCore::kScreenTopWidth) * | ||
| 117 | (res.top_screen.right - res.top_screen.left)); | ||
| 118 | int bottom_border = ((res.top_screen.right - res.top_screen.left) - bottom_width) / 2; | ||
| 119 | |||
| 120 | res.bottom_screen.left = bottom_border; | ||
| 121 | res.bottom_screen.right = res.bottom_screen.left + bottom_width; | ||
| 122 | res.bottom_screen.top = res.top_screen.bottom; | ||
| 123 | res.bottom_screen.bottom = res.bottom_screen.top + viewport_height / 2; | ||
| 124 | } else { | ||
| 125 | // Otherwise, apply borders to the left and right sides of the window. | ||
| 126 | int viewport_width = static_cast<int>(std::round(height / emulation_aspect_ratio)); | ||
| 127 | |||
| 128 | res.top_screen.left = (width - viewport_width) / 2; | ||
| 129 | res.top_screen.right = res.top_screen.left + viewport_width; | ||
| 130 | res.top_screen.top = 0; | ||
| 131 | res.top_screen.bottom = res.top_screen.top + height / 2; | ||
| 132 | |||
| 133 | int bottom_width = static_cast<int>( | ||
| 134 | (static_cast<float>(VideoCore::kScreenBottomWidth) / VideoCore::kScreenTopWidth) * | ||
| 135 | (res.top_screen.right - res.top_screen.left)); | ||
| 136 | int bottom_border = ((res.top_screen.right - res.top_screen.left) - bottom_width) / 2; | ||
| 137 | |||
| 138 | res.bottom_screen.left = res.top_screen.left + bottom_border; | ||
| 139 | res.bottom_screen.right = res.bottom_screen.left + bottom_width; | ||
| 140 | res.bottom_screen.top = res.top_screen.bottom; | ||
| 141 | res.bottom_screen.bottom = res.bottom_screen.top + height / 2; | ||
| 142 | } | 105 | } |
| 143 | 106 | NotifyFramebufferLayoutChanged(layout); | |
| 144 | return res; | ||
| 145 | } | 107 | } |
diff --git a/src/common/emu_window.h b/src/common/emu_window.h index 67df63e06..6fac572f5 100644 --- a/src/common/emu_window.h +++ b/src/common/emu_window.h | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include <tuple> | 7 | #include <tuple> |
| 8 | #include <utility> | 8 | #include <utility> |
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "common/framebuffer_layout.h" | ||
| 10 | #include "common/math_util.h" | 11 | #include "common/math_util.h" |
| 11 | #include "core/hle/service/hid/hid.h" | 12 | #include "core/hle/service/hid/hid.h" |
| 12 | 13 | ||
| @@ -38,23 +39,6 @@ public: | |||
| 38 | std::pair<unsigned, unsigned> min_client_area_size; | 39 | std::pair<unsigned, unsigned> min_client_area_size; |
| 39 | }; | 40 | }; |
| 40 | 41 | ||
| 41 | /// Describes the layout of the window framebuffer (size and top/bottom screen positions) | ||
| 42 | struct FramebufferLayout { | ||
| 43 | |||
| 44 | /** | ||
| 45 | * Factory method for constructing a default FramebufferLayout | ||
| 46 | * @param width Window framebuffer width in pixels | ||
| 47 | * @param height Window framebuffer height in pixels | ||
| 48 | * @return Newly created FramebufferLayout object with default screen regions initialized | ||
| 49 | */ | ||
| 50 | static FramebufferLayout DefaultScreenLayout(unsigned width, unsigned height); | ||
| 51 | |||
| 52 | unsigned width; | ||
| 53 | unsigned height; | ||
| 54 | MathUtil::Rectangle<unsigned> top_screen; | ||
| 55 | MathUtil::Rectangle<unsigned> bottom_screen; | ||
| 56 | }; | ||
| 57 | |||
| 58 | /// Swap buffers to display the next frame | 42 | /// Swap buffers to display the next frame |
| 59 | virtual void SwapBuffers() = 0; | 43 | virtual void SwapBuffers() = 0; |
| 60 | 44 | ||
| @@ -211,10 +195,16 @@ public: | |||
| 211 | * Gets the framebuffer layout (width, height, and screen regions) | 195 | * Gets the framebuffer layout (width, height, and screen regions) |
| 212 | * @note This method is thread-safe | 196 | * @note This method is thread-safe |
| 213 | */ | 197 | */ |
| 214 | const FramebufferLayout& GetFramebufferLayout() const { | 198 | const Layout::FramebufferLayout& GetFramebufferLayout() const { |
| 215 | return framebuffer_layout; | 199 | return framebuffer_layout; |
| 216 | } | 200 | } |
| 217 | 201 | ||
| 202 | /** | ||
| 203 | * Convenience method to update the VideoCore EmuWindow | ||
| 204 | * Read from the current settings to determine which layout to use. | ||
| 205 | */ | ||
| 206 | void UpdateCurrentFramebufferLayout(unsigned width, unsigned height); | ||
| 207 | |||
| 218 | protected: | 208 | protected: |
| 219 | EmuWindow() { | 209 | EmuWindow() { |
| 220 | // TODO: Find a better place to set this. | 210 | // TODO: Find a better place to set this. |
| @@ -250,7 +240,7 @@ protected: | |||
| 250 | * Update framebuffer layout with the given parameter. | 240 | * Update framebuffer layout with the given parameter. |
| 251 | * @note EmuWindow implementations will usually use this in window resize event handlers. | 241 | * @note EmuWindow implementations will usually use this in window resize event handlers. |
| 252 | */ | 242 | */ |
| 253 | void NotifyFramebufferLayoutChanged(const FramebufferLayout& layout) { | 243 | void NotifyFramebufferLayoutChanged(const Layout::FramebufferLayout& layout) { |
| 254 | framebuffer_layout = layout; | 244 | framebuffer_layout = layout; |
| 255 | } | 245 | } |
| 256 | 246 | ||
| @@ -274,7 +264,7 @@ private: | |||
| 274 | // By default, ignore this request and do nothing. | 264 | // By default, ignore this request and do nothing. |
| 275 | } | 265 | } |
| 276 | 266 | ||
| 277 | FramebufferLayout framebuffer_layout; ///< Current framebuffer layout | 267 | Layout::FramebufferLayout framebuffer_layout; ///< Current framebuffer layout |
| 278 | 268 | ||
| 279 | unsigned client_area_width; ///< Current client width, should be set by window impl. | 269 | unsigned client_area_width; ///< Current client width, should be set by window impl. |
| 280 | unsigned client_area_height; ///< Current client height, should be set by window impl. | 270 | unsigned client_area_height; ///< Current client height, should be set by window impl. |
diff --git a/src/common/framebuffer_layout.cpp b/src/common/framebuffer_layout.cpp new file mode 100644 index 000000000..a0e75090d --- /dev/null +++ b/src/common/framebuffer_layout.cpp | |||
| @@ -0,0 +1,312 @@ | |||
| 1 | // Copyright 2016 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <cmath> | ||
| 6 | |||
| 7 | #include "common/assert.h" | ||
| 8 | #include "common/framebuffer_layout.h" | ||
| 9 | #include "video_core/video_core.h" | ||
| 10 | |||
| 11 | namespace Layout { | ||
| 12 | static FramebufferLayout DefaultFrameLayout(unsigned width, unsigned height) { | ||
| 13 | |||
| 14 | ASSERT(width > 0); | ||
| 15 | ASSERT(height > 0); | ||
| 16 | |||
| 17 | FramebufferLayout res {width, height, true, true, {}, {}}; | ||
| 18 | |||
| 19 | float window_aspect_ratio = static_cast<float>(height) / width; | ||
| 20 | float emulation_aspect_ratio = static_cast<float>(VideoCore::kScreenTopHeight * 2) / | ||
| 21 | VideoCore::kScreenTopWidth; | ||
| 22 | |||
| 23 | if (window_aspect_ratio > emulation_aspect_ratio) { | ||
| 24 | // Window is narrower than the emulation content => apply borders to the top and bottom | ||
| 25 | int viewport_height = static_cast<int>(std::round(emulation_aspect_ratio * width)); | ||
| 26 | |||
| 27 | res.top_screen.left = 0; | ||
| 28 | res.top_screen.right = res.top_screen.left + width; | ||
| 29 | res.top_screen.top = (height - viewport_height) / 2; | ||
| 30 | res.top_screen.bottom = res.top_screen.top + viewport_height / 2; | ||
| 31 | |||
| 32 | int bottom_width = static_cast<int>((static_cast<float>(VideoCore::kScreenBottomWidth) / | ||
| 33 | VideoCore::kScreenTopWidth) * (res.top_screen.right - res.top_screen.left)); | ||
| 34 | int bottom_border = ((res.top_screen.right - res.top_screen.left) - bottom_width) / 2; | ||
| 35 | |||
| 36 | res.bottom_screen.left = bottom_border; | ||
| 37 | res.bottom_screen.right = res.bottom_screen.left + bottom_width; | ||
| 38 | res.bottom_screen.top = res.top_screen.bottom; | ||
| 39 | res.bottom_screen.bottom = res.bottom_screen.top + viewport_height / 2; | ||
| 40 | } else { | ||
| 41 | // Otherwise, apply borders to the left and right sides of the window. | ||
| 42 | int viewport_width = static_cast<int>(std::round(height / emulation_aspect_ratio)); | ||
| 43 | |||
| 44 | res.top_screen.left = (width - viewport_width) / 2; | ||
| 45 | res.top_screen.right = res.top_screen.left + viewport_width; | ||
| 46 | res.top_screen.top = 0; | ||
| 47 | res.top_screen.bottom = res.top_screen.top + height / 2; | ||
| 48 | |||
| 49 | int bottom_width = static_cast<int>((static_cast<float>(VideoCore::kScreenBottomWidth) / | ||
| 50 | VideoCore::kScreenTopWidth) * (res.top_screen.right - res.top_screen.left)); | ||
| 51 | int bottom_border = ((res.top_screen.right - res.top_screen.left) - bottom_width) / 2; | ||
| 52 | |||
| 53 | res.bottom_screen.left = res.top_screen.left + bottom_border; | ||
| 54 | res.bottom_screen.right = res.bottom_screen.left + bottom_width; | ||
| 55 | res.bottom_screen.top = res.top_screen.bottom; | ||
| 56 | res.bottom_screen.bottom = res.bottom_screen.top + height / 2; | ||
| 57 | } | ||
| 58 | |||
| 59 | return res; | ||
| 60 | } | ||
| 61 | |||
| 62 | static FramebufferLayout DefaultFrameLayout_Swapped(unsigned width, unsigned height) { | ||
| 63 | |||
| 64 | ASSERT(width > 0); | ||
| 65 | ASSERT(height > 0); | ||
| 66 | |||
| 67 | FramebufferLayout res {width, height, true, true, {}, {}}; | ||
| 68 | |||
| 69 | float window_aspect_ratio = static_cast<float>(height) / width; | ||
| 70 | float emulation_aspect_ratio = static_cast<float>(VideoCore::kScreenTopHeight * 2) / | ||
| 71 | VideoCore::kScreenTopWidth; | ||
| 72 | |||
| 73 | if (window_aspect_ratio > emulation_aspect_ratio) { | ||
| 74 | // Window is narrower than the emulation content => apply borders to the top and bottom | ||
| 75 | int viewport_height = static_cast<int>(std::round(emulation_aspect_ratio * width)); | ||
| 76 | |||
| 77 | res.top_screen.left = 0; | ||
| 78 | res.top_screen.right = res.top_screen.left + width; | ||
| 79 | |||
| 80 | int bottom_width = static_cast<int>((static_cast<float>(VideoCore::kScreenBottomWidth) / | ||
| 81 | VideoCore::kScreenTopWidth) * (res.top_screen.right - res.top_screen.left)); | ||
| 82 | int bottom_border = ((res.top_screen.right - res.top_screen.left) - bottom_width) / 2; | ||
| 83 | |||
| 84 | res.bottom_screen.left = bottom_border; | ||
| 85 | res.bottom_screen.right = res.bottom_screen.left + bottom_width; | ||
| 86 | res.bottom_screen.top = (height - viewport_height) / 2; | ||
| 87 | res.bottom_screen.bottom = res.bottom_screen.top + viewport_height / 2; | ||
| 88 | |||
| 89 | res.top_screen.top = res.bottom_screen.bottom; | ||
| 90 | res.top_screen.bottom = res.top_screen.top + viewport_height / 2; | ||
| 91 | } else { | ||
| 92 | // Otherwise, apply borders to the left and right sides of the window. | ||
| 93 | int viewport_width = static_cast<int>(std::round(height / emulation_aspect_ratio)); | ||
| 94 | res.top_screen.left = (width - viewport_width) / 2; | ||
| 95 | res.top_screen.right = res.top_screen.left + viewport_width; | ||
| 96 | |||
| 97 | int bottom_width = static_cast<int>((static_cast<float>(VideoCore::kScreenBottomWidth) / | ||
| 98 | VideoCore::kScreenTopWidth) * (res.top_screen.right - res.top_screen.left)); | ||
| 99 | int bottom_border = ((res.top_screen.right - res.top_screen.left) - bottom_width) / 2; | ||
| 100 | |||
| 101 | res.bottom_screen.left = res.top_screen.left + bottom_border; | ||
| 102 | res.bottom_screen.right = res.bottom_screen.left + bottom_width; | ||
| 103 | res.bottom_screen.top = 0; | ||
| 104 | res.bottom_screen.bottom = res.bottom_screen.top + height / 2; | ||
| 105 | |||
| 106 | res.top_screen.top = res.bottom_screen.bottom; | ||
| 107 | res.top_screen.bottom = res.top_screen.top + height / 2; | ||
| 108 | } | ||
| 109 | |||
| 110 | return res; | ||
| 111 | } | ||
| 112 | |||
| 113 | static FramebufferLayout SingleFrameLayout(unsigned width, unsigned height) { | ||
| 114 | |||
| 115 | ASSERT(width > 0); | ||
| 116 | ASSERT(height > 0); | ||
| 117 | |||
| 118 | FramebufferLayout res {width, height, true, false, {}, {}}; | ||
| 119 | |||
| 120 | float window_aspect_ratio = static_cast<float>(height) / width; | ||
| 121 | float emulation_aspect_ratio = static_cast<float>(VideoCore::kScreenTopHeight) / | ||
| 122 | VideoCore::kScreenTopWidth; | ||
| 123 | |||
| 124 | if (window_aspect_ratio > emulation_aspect_ratio) { | ||
| 125 | // Window is narrower than the emulation content => apply borders to the top and bottom | ||
| 126 | int viewport_height = static_cast<int>(std::round(emulation_aspect_ratio * width)); | ||
| 127 | |||
| 128 | res.top_screen.left = 0; | ||
| 129 | res.top_screen.right = res.top_screen.left + width; | ||
| 130 | res.top_screen.top = (height - viewport_height) / 2; | ||
| 131 | res.top_screen.bottom = res.top_screen.top + viewport_height; | ||
| 132 | |||
| 133 | res.bottom_screen.left = 0; | ||
| 134 | res.bottom_screen.right = VideoCore::kScreenBottomWidth; | ||
| 135 | res.bottom_screen.top = 0; | ||
| 136 | res.bottom_screen.bottom = VideoCore::kScreenBottomHeight; | ||
| 137 | } else { | ||
| 138 | // Otherwise, apply borders to the left and right sides of the window. | ||
| 139 | int viewport_width = static_cast<int>(std::round(height / emulation_aspect_ratio)); | ||
| 140 | |||
| 141 | res.top_screen.left = (width - viewport_width) / 2; | ||
| 142 | res.top_screen.right = res.top_screen.left + viewport_width; | ||
| 143 | res.top_screen.top = 0; | ||
| 144 | res.top_screen.bottom = res.top_screen.top + height; | ||
| 145 | |||
| 146 | // The Rasterizer still depends on these fields to maintain the right aspect ratio | ||
| 147 | res.bottom_screen.left = 0; | ||
| 148 | res.bottom_screen.right = VideoCore::kScreenBottomWidth; | ||
| 149 | res.bottom_screen.top = 0; | ||
| 150 | res.bottom_screen.bottom = VideoCore::kScreenBottomHeight; | ||
| 151 | } | ||
| 152 | |||
| 153 | return res; | ||
| 154 | } | ||
| 155 | |||
| 156 | static FramebufferLayout SingleFrameLayout_Swapped(unsigned width, unsigned height) { | ||
| 157 | |||
| 158 | ASSERT(width > 0); | ||
| 159 | ASSERT(height > 0); | ||
| 160 | |||
| 161 | FramebufferLayout res {width, height, false, true, {}, {}}; | ||
| 162 | |||
| 163 | float window_aspect_ratio = static_cast<float>(height) / width; | ||
| 164 | float emulation_aspect_ratio = static_cast<float>(VideoCore::kScreenBottomHeight) / | ||
| 165 | VideoCore::kScreenBottomWidth; | ||
| 166 | |||
| 167 | if (window_aspect_ratio > emulation_aspect_ratio) { | ||
| 168 | // Window is narrower than the emulation content => apply borders to the top and bottom | ||
| 169 | int viewport_height = static_cast<int>(std::round(emulation_aspect_ratio * width)); | ||
| 170 | |||
| 171 | res.bottom_screen.left = 0; | ||
| 172 | res.bottom_screen.right = res.bottom_screen.left + width; | ||
| 173 | res.bottom_screen.top = (height - viewport_height) / 2; | ||
| 174 | res.bottom_screen.bottom = res.bottom_screen.top + viewport_height; | ||
| 175 | |||
| 176 | // The Rasterizer still depends on these fields to maintain the right aspect ratio | ||
| 177 | res.top_screen.left = 0; | ||
| 178 | res.top_screen.right = VideoCore::kScreenTopWidth; | ||
| 179 | res.top_screen.top = 0; | ||
| 180 | res.top_screen.bottom = VideoCore::kScreenTopHeight; | ||
| 181 | } else { | ||
| 182 | // Otherwise, apply borders to the left and right sides of the window. | ||
| 183 | int viewport_width = static_cast<int>(std::round(height / emulation_aspect_ratio)); | ||
| 184 | |||
| 185 | res.bottom_screen.left = (width - viewport_width) / 2; | ||
| 186 | res.bottom_screen.right = res.bottom_screen.left + viewport_width; | ||
| 187 | res.bottom_screen.top = 0; | ||
| 188 | res.bottom_screen.bottom = res.bottom_screen.top + height; | ||
| 189 | |||
| 190 | res.top_screen.left = 0; | ||
| 191 | res.top_screen.right = VideoCore::kScreenTopWidth; | ||
| 192 | res.top_screen.top = 0; | ||
| 193 | res.top_screen.bottom = VideoCore::kScreenTopHeight; | ||
| 194 | } | ||
| 195 | |||
| 196 | return res; | ||
| 197 | } | ||
| 198 | |||
| 199 | static FramebufferLayout LargeFrameLayout(unsigned width, unsigned height) { | ||
| 200 | |||
| 201 | ASSERT(width > 0); | ||
| 202 | ASSERT(height > 0); | ||
| 203 | |||
| 204 | FramebufferLayout res {width, height, true, true, {}, {}}; | ||
| 205 | |||
| 206 | float window_aspect_ratio = static_cast<float>(height) / width; | ||
| 207 | float emulation_aspect_ratio = static_cast<float>(VideoCore::kScreenTopHeight * 4) / | ||
| 208 | (VideoCore::kScreenTopWidth * 4 + VideoCore::kScreenBottomWidth); | ||
| 209 | |||
| 210 | if (window_aspect_ratio > emulation_aspect_ratio) { | ||
| 211 | // Window is narrower than the emulation content => apply borders to the top and bottom | ||
| 212 | int viewport_height = static_cast<int>(std::round(emulation_aspect_ratio * width)); | ||
| 213 | |||
| 214 | res.top_screen.left = 0; | ||
| 215 | // Top screen occupies 4 / 5ths of the total width | ||
| 216 | res.top_screen.right = static_cast<int>(std::round(width / 5)) * 4; | ||
| 217 | res.top_screen.top = (height - viewport_height) / 2; | ||
| 218 | res.top_screen.bottom = res.top_screen.top + viewport_height; | ||
| 219 | |||
| 220 | int bottom_height = static_cast<int>((static_cast<float>(VideoCore::kScreenBottomHeight) / | ||
| 221 | VideoCore::kScreenBottomWidth) * (width - res.top_screen.right)); | ||
| 222 | |||
| 223 | res.bottom_screen.left = res.top_screen.right; | ||
| 224 | res.bottom_screen.right = width; | ||
| 225 | res.bottom_screen.bottom = res.top_screen.bottom; | ||
| 226 | res.bottom_screen.top = res.bottom_screen.bottom - bottom_height; | ||
| 227 | } else { | ||
| 228 | // Otherwise, apply borders to the left and right sides of the window. | ||
| 229 | int viewport_width = static_cast<int>(std::round(height / emulation_aspect_ratio)); | ||
| 230 | // Break the viewport into fifths and give top 4 of them | ||
| 231 | int fifth_width = static_cast<int>(std::round(viewport_width / 5)); | ||
| 232 | |||
| 233 | res.top_screen.left = (width - viewport_width) / 2; | ||
| 234 | res.top_screen.right = res.top_screen.left + fifth_width * 4; | ||
| 235 | res.top_screen.top = 0; | ||
| 236 | res.top_screen.bottom = height; | ||
| 237 | |||
| 238 | int bottom_height = static_cast<int>((static_cast<float>(VideoCore::kScreenBottomHeight) / | ||
| 239 | VideoCore::kScreenBottomWidth) * (fifth_width)); | ||
| 240 | |||
| 241 | res.bottom_screen.left = res.top_screen.right; | ||
| 242 | res.bottom_screen.right = width - (width - viewport_width) / 2; | ||
| 243 | res.bottom_screen.bottom = res.top_screen.bottom; | ||
| 244 | res.bottom_screen.top = res.bottom_screen.bottom - bottom_height; | ||
| 245 | } | ||
| 246 | |||
| 247 | return res; | ||
| 248 | } | ||
| 249 | |||
| 250 | static FramebufferLayout LargeFrameLayout_Swapped(unsigned width, unsigned height) { | ||
| 251 | |||
| 252 | ASSERT(width > 0); | ||
| 253 | ASSERT(height > 0); | ||
| 254 | |||
| 255 | FramebufferLayout res {width, height, true, true, {}, {}}; | ||
| 256 | |||
| 257 | float window_aspect_ratio = static_cast<float>(height) / width; | ||
| 258 | float emulation_aspect_ratio = static_cast<float>(VideoCore::kScreenBottomHeight * 4) / | ||
| 259 | (VideoCore::kScreenBottomWidth * 4 + VideoCore::kScreenTopWidth); | ||
| 260 | |||
| 261 | if (window_aspect_ratio > emulation_aspect_ratio) { | ||
| 262 | // Window is narrower than the emulation content => apply borders to the top and bottom | ||
| 263 | int viewport_height = static_cast<int>(std::round(emulation_aspect_ratio * width)); | ||
| 264 | |||
| 265 | res.bottom_screen.left = 0; | ||
| 266 | // Top screen occupies 4 / 5ths of the total width | ||
| 267 | res.bottom_screen.right = static_cast<int>(std::round(width / 5)) * 4; | ||
| 268 | res.bottom_screen.top = (height - viewport_height) / 2; | ||
| 269 | res.bottom_screen.bottom = res.bottom_screen.top + viewport_height; | ||
| 270 | |||
| 271 | int top_height = static_cast<int>((static_cast<float>(VideoCore::kScreenTopHeight) / | ||
| 272 | VideoCore::kScreenTopWidth) * (width - res.bottom_screen.right)); | ||
| 273 | |||
| 274 | res.top_screen.left = res.bottom_screen.right; | ||
| 275 | res.top_screen.right = width; | ||
| 276 | res.top_screen.bottom = res.bottom_screen.bottom; | ||
| 277 | res.top_screen.top = res.top_screen.bottom - top_height; | ||
| 278 | } else { | ||
| 279 | // Otherwise, apply borders to the left and right sides of the window. | ||
| 280 | int viewport_width = static_cast<int>(std::round(height / emulation_aspect_ratio)); | ||
| 281 | // Break the viewport into fifths and give top 4 of them | ||
| 282 | int fifth_width = static_cast<int>(std::round(viewport_width / 5)); | ||
| 283 | |||
| 284 | res.bottom_screen.left = (width - viewport_width) / 2; | ||
| 285 | res.bottom_screen.right = res.bottom_screen.left + fifth_width * 4; | ||
| 286 | res.bottom_screen.top = 0; | ||
| 287 | res.bottom_screen.bottom = height; | ||
| 288 | |||
| 289 | int top_height = static_cast<int>((static_cast<float>(VideoCore::kScreenTopHeight) / | ||
| 290 | VideoCore::kScreenTopWidth) * (fifth_width)); | ||
| 291 | |||
| 292 | res.top_screen.left = res.bottom_screen.right; | ||
| 293 | res.top_screen.right = width - (width - viewport_width) / 2; | ||
| 294 | res.top_screen.bottom = res.bottom_screen.bottom; | ||
| 295 | res.top_screen.top = res.top_screen.bottom - top_height; | ||
| 296 | } | ||
| 297 | |||
| 298 | return res; | ||
| 299 | } | ||
| 300 | |||
| 301 | FramebufferLayout DefaultFrameLayout(unsigned width, unsigned height, bool is_swapped) { | ||
| 302 | return is_swapped ? DefaultFrameLayout_Swapped(width, height) : DefaultFrameLayout(width, height); | ||
| 303 | } | ||
| 304 | |||
| 305 | FramebufferLayout SingleFrameLayout(unsigned width, unsigned height, bool is_swapped) { | ||
| 306 | return is_swapped ? SingleFrameLayout_Swapped(width, height) : SingleFrameLayout(width, height); | ||
| 307 | } | ||
| 308 | |||
| 309 | FramebufferLayout LargeFrameLayout(unsigned width, unsigned height, bool is_swapped) { | ||
| 310 | return is_swapped ? LargeFrameLayout_Swapped(width, height) : LargeFrameLayout(width, height); | ||
| 311 | } | ||
| 312 | } \ No newline at end of file | ||
diff --git a/src/common/framebuffer_layout.h b/src/common/framebuffer_layout.h new file mode 100644 index 000000000..c69a80732 --- /dev/null +++ b/src/common/framebuffer_layout.h | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | // Copyright 2016 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "common/math_util.h" | ||
| 8 | namespace Layout { | ||
| 9 | /// Describes the layout of the window framebuffer (size and top/bottom screen positions) | ||
| 10 | struct FramebufferLayout { | ||
| 11 | unsigned width; | ||
| 12 | unsigned height; | ||
| 13 | bool top_screen_enabled; | ||
| 14 | bool bottom_screen_enabled; | ||
| 15 | MathUtil::Rectangle<unsigned> top_screen; | ||
| 16 | MathUtil::Rectangle<unsigned> bottom_screen; | ||
| 17 | }; | ||
| 18 | |||
| 19 | /** | ||
| 20 | * Factory method for constructing a default FramebufferLayout | ||
| 21 | * @param width Window framebuffer width in pixels | ||
| 22 | * @param height Window framebuffer height in pixels | ||
| 23 | * @return Newly created FramebufferLayout object with default screen regions initialized | ||
| 24 | */ | ||
| 25 | FramebufferLayout DefaultFrameLayout(unsigned width, unsigned height, bool is_swapped); | ||
| 26 | |||
| 27 | /** | ||
| 28 | * Factory method for constructing a FramebufferLayout with only the top screen | ||
| 29 | * @param width Window framebuffer width in pixels | ||
| 30 | * @param height Window framebuffer height in pixels | ||
| 31 | * @return Newly created FramebufferLayout object with default screen regions initialized | ||
| 32 | */ | ||
| 33 | FramebufferLayout SingleFrameLayout(unsigned width, unsigned height, bool is_swapped); | ||
| 34 | |||
| 35 | /** | ||
| 36 | * Factory method for constructing a Frame with the a 4x size Top screen with a 1x size bottom screen on the right | ||
| 37 | * This is useful in particular because it matches well with a 1920x1080 resolution monitor | ||
| 38 | * @param width Window framebuffer width in pixels | ||
| 39 | * @param height Window framebuffer height in pixels | ||
| 40 | * @return Newly created FramebufferLayout object with default screen regions initialized | ||
| 41 | */ | ||
| 42 | FramebufferLayout LargeFrameLayout(unsigned width, unsigned height, bool is_swapped); | ||
| 43 | } \ No newline at end of file | ||
diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 4a0969b00..05f41f798 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp | |||
| @@ -7,6 +7,8 @@ | |||
| 7 | #include "settings.h" | 7 | #include "settings.h" |
| 8 | #include "video_core/video_core.h" | 8 | #include "video_core/video_core.h" |
| 9 | 9 | ||
| 10 | #include "common/emu_window.h" | ||
| 11 | |||
| 10 | namespace Settings { | 12 | namespace Settings { |
| 11 | 13 | ||
| 12 | Values values = {}; | 14 | Values values = {}; |
| @@ -20,6 +22,11 @@ void Apply() { | |||
| 20 | VideoCore::g_shader_jit_enabled = values.use_shader_jit; | 22 | VideoCore::g_shader_jit_enabled = values.use_shader_jit; |
| 21 | VideoCore::g_scaled_resolution_enabled = values.use_scaled_resolution; | 23 | VideoCore::g_scaled_resolution_enabled = values.use_scaled_resolution; |
| 22 | 24 | ||
| 25 | if (VideoCore::g_emu_window) { | ||
| 26 | auto layout = VideoCore::g_emu_window->GetFramebufferLayout(); | ||
| 27 | VideoCore::g_emu_window->UpdateCurrentFramebufferLayout(layout.width, layout.height); | ||
| 28 | } | ||
| 29 | |||
| 23 | AudioCore::SelectSink(values.sink_id); | 30 | AudioCore::SelectSink(values.sink_id); |
| 24 | AudioCore::EnableStretching(values.enable_audio_stretching); | 31 | AudioCore::EnableStretching(values.enable_audio_stretching); |
| 25 | } | 32 | } |
diff --git a/src/core/settings.h b/src/core/settings.h index 5a64f8018..e931953d7 100644 --- a/src/core/settings.h +++ b/src/core/settings.h | |||
| @@ -10,7 +10,15 @@ | |||
| 10 | 10 | ||
| 11 | namespace Settings { | 11 | namespace Settings { |
| 12 | 12 | ||
| 13 | enum class LayoutOption { | ||
| 14 | Default, | ||
| 15 | SingleScreen, | ||
| 16 | LargeScreen, | ||
| 17 | Custom, | ||
| 18 | }; | ||
| 19 | |||
| 13 | namespace NativeInput { | 20 | namespace NativeInput { |
| 21 | |||
| 14 | enum Values { | 22 | enum Values { |
| 15 | // directly mapped keys | 23 | // directly mapped keys |
| 16 | A, | 24 | A, |
| @@ -84,6 +92,9 @@ struct Values { | |||
| 84 | bool use_scaled_resolution; | 92 | bool use_scaled_resolution; |
| 85 | bool use_vsync; | 93 | bool use_vsync; |
| 86 | 94 | ||
| 95 | LayoutOption layout_option; | ||
| 96 | bool swap_screen; | ||
| 97 | |||
| 87 | float bg_red; | 98 | float bg_red; |
| 88 | float bg_green; | 99 | float bg_green; |
| 89 | float bg_blue; | 100 | float bg_blue; |
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 03a588364..fd0d74ace 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp | |||
| @@ -390,6 +390,8 @@ void RendererOpenGL::DrawSingleScreenRotated(const ScreenInfo& screen_info, floa | |||
| 390 | */ | 390 | */ |
| 391 | void RendererOpenGL::DrawScreens() { | 391 | void RendererOpenGL::DrawScreens() { |
| 392 | auto layout = render_window->GetFramebufferLayout(); | 392 | auto layout = render_window->GetFramebufferLayout(); |
| 393 | const auto& top_screen = layout.top_screen; | ||
| 394 | const auto& bottom_screen = layout.bottom_screen; | ||
| 393 | 395 | ||
| 394 | glViewport(0, 0, layout.width, layout.height); | 396 | glViewport(0, 0, layout.width, layout.height); |
| 395 | glClear(GL_COLOR_BUFFER_BIT); | 397 | glClear(GL_COLOR_BUFFER_BIT); |
| @@ -403,12 +405,16 @@ void RendererOpenGL::DrawScreens() { | |||
| 403 | glActiveTexture(GL_TEXTURE0); | 405 | glActiveTexture(GL_TEXTURE0); |
| 404 | glUniform1i(uniform_color_texture, 0); | 406 | glUniform1i(uniform_color_texture, 0); |
| 405 | 407 | ||
| 406 | DrawSingleScreenRotated(screen_infos[0], (float)layout.top_screen.left, | 408 | if (layout.top_screen_enabled) { |
| 407 | (float)layout.top_screen.top, (float)layout.top_screen.GetWidth(), | 409 | DrawSingleScreenRotated(screen_infos[0], (float)top_screen.left, |
| 408 | (float)layout.top_screen.GetHeight()); | 410 | (float)top_screen.top, (float)top_screen.GetWidth(), |
| 409 | DrawSingleScreenRotated(screen_infos[1], (float)layout.bottom_screen.left, | 411 | (float)top_screen.GetHeight()); |
| 410 | (float)layout.bottom_screen.top, (float)layout.bottom_screen.GetWidth(), | 412 | } |
| 411 | (float)layout.bottom_screen.GetHeight()); | 413 | if (layout.bottom_screen_enabled) { |
| 414 | DrawSingleScreenRotated(screen_infos[1], (float)bottom_screen.left, | ||
| 415 | (float)bottom_screen.top, (float)bottom_screen.GetWidth(), | ||
| 416 | (float)bottom_screen.GetHeight()); | ||
| 417 | } | ||
| 412 | 418 | ||
| 413 | m_current_frame++; | 419 | m_current_frame++; |
| 414 | } | 420 | } |