From b7a156f7c8b5353b6b457b7b8c64dd1851ad0df2 Mon Sep 17 00:00:00 2001 From: bunnei Date: Mon, 22 Jul 2019 14:58:54 -0400 Subject: [PATCH] android: frontend: Track screen layout separately for orientation. android framebuffer --- src/core/frontend/emu_window.cpp | 9 ++++++++- src/core/frontend/emu_window.h | 3 ++- src/core/settings.cpp | 2 ++ src/video_core/renderer_base.cpp | 4 ++-- src/video_core/renderer_base.h | 2 +- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/core/frontend/emu_window.cpp b/src/core/frontend/emu_window.cpp index 2a954c5541..73909b09c9 100644 --- a/src/core/frontend/emu_window.cpp +++ b/src/core/frontend/emu_window.cpp @@ -145,7 +145,8 @@ void EmuWindow::TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y) { TouchPressed(framebuffer_x, framebuffer_y); } -void EmuWindow::UpdateCurrentFramebufferLayout(unsigned width, unsigned height) { +void EmuWindow::UpdateCurrentFramebufferLayout(unsigned width, unsigned height, + bool is_portrait_mode) { Layout::FramebufferLayout layout; const auto layout_option = Settings::values.layout_option; const auto min_size = @@ -156,6 +157,12 @@ void EmuWindow::UpdateCurrentFramebufferLayout(unsigned width, unsigned height) } else { width = std::max(width, min_size.first); height = std::max(height, min_size.second); + + // If in portrait mode, only the MobilePortrait option really makes sense + const Settings::LayoutOption layout_option = is_portrait_mode + ? Settings::LayoutOption::MobilePortrait + : Settings::values.layout_option; + switch (layout_option) { case Settings::LayoutOption::SingleScreen: layout = Layout::SingleFrameLayout(width, height, Settings::values.swap_screen, diff --git a/src/core/frontend/emu_window.h b/src/core/frontend/emu_window.h index efaa25d9f3..65ee25bc9d 100644 --- a/src/core/frontend/emu_window.h +++ b/src/core/frontend/emu_window.h @@ -159,7 +159,8 @@ public: * Convenience method to update the current frame layout * Read from the current settings to determine which layout to use. */ - void UpdateCurrentFramebufferLayout(unsigned width, unsigned height); + void UpdateCurrentFramebufferLayout(unsigned width, unsigned height, + bool is_portrait_mode = {}); std::unique_ptr mailbox = nullptr; diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 855307ba59..a63f23b07c 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -33,9 +33,11 @@ void Apply() { VideoCore::g_hw_shader_accurate_mul = values.shaders_accurate_mul; VideoCore::g_use_disk_shader_cache = values.use_disk_shader_cache; +#ifndef ANDROID if (VideoCore::g_renderer) { VideoCore::g_renderer->UpdateCurrentFramebufferLayout(); } +#endif VideoCore::g_renderer_bg_color_update_requested = true; VideoCore::g_renderer_sampler_update_requested = true; diff --git a/src/video_core/renderer_base.cpp b/src/video_core/renderer_base.cpp index 48a3601c2d..353550dee9 100644 --- a/src/video_core/renderer_base.cpp +++ b/src/video_core/renderer_base.cpp @@ -11,9 +11,9 @@ RendererBase::RendererBase(Frontend::EmuWindow& window) : render_window{window} {} RendererBase::~RendererBase() = default; -void RendererBase::UpdateCurrentFramebufferLayout() { +void RendererBase::UpdateCurrentFramebufferLayout(bool is_portrait_mode) { const Layout::FramebufferLayout& layout = render_window.GetFramebufferLayout(); - render_window.UpdateCurrentFramebufferLayout(layout.width, layout.height); + render_window.UpdateCurrentFramebufferLayout(layout.width, layout.height, is_portrait_mode); } void RendererBase::RefreshRasterizerSetting() { diff --git a/src/video_core/renderer_base.h b/src/video_core/renderer_base.h index ba49d3f285..9322742cf1 100644 --- a/src/video_core/renderer_base.h +++ b/src/video_core/renderer_base.h @@ -38,7 +38,7 @@ public: virtual void CleanupVideoDumping() = 0; /// Updates the framebuffer layout of the contained render window handle. - void UpdateCurrentFramebufferLayout(); + void UpdateCurrentFramebufferLayout(bool is_portrait_mode = {}); // Getter/setter functions: // ------------------------