diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/frontend/framebuffer_layout.cpp | 13 | ||||
| -rw-r--r-- | src/core/frontend/framebuffer_layout.h | 21 | ||||
| -rw-r--r-- | src/yuzu/bootmanager.cpp | 5 | ||||
| -rw-r--r-- | src/yuzu/bootmanager.h | 2 |
4 files changed, 25 insertions, 16 deletions
diff --git a/src/core/frontend/framebuffer_layout.cpp b/src/core/frontend/framebuffer_layout.cpp index a1357179f..d6d2cf3f0 100644 --- a/src/core/frontend/framebuffer_layout.cpp +++ b/src/core/frontend/framebuffer_layout.cpp | |||
| @@ -20,7 +20,7 @@ static Common::Rectangle<T> MaxRectangle(Common::Rectangle<T> window_area, | |||
| 20 | static_cast<T>(std::round(scale * screen_aspect_ratio))}; | 20 | static_cast<T>(std::round(scale * screen_aspect_ratio))}; |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | FramebufferLayout DefaultFrameLayout(unsigned width, unsigned height) { | 23 | FramebufferLayout DefaultFrameLayout(u32 width, u32 height) { |
| 24 | ASSERT(width > 0); | 24 | ASSERT(width > 0); |
| 25 | ASSERT(height > 0); | 25 | ASSERT(height > 0); |
| 26 | // The drawing code needs at least somewhat valid values for both screens | 26 | // The drawing code needs at least somewhat valid values for both screens |
| @@ -29,22 +29,23 @@ FramebufferLayout DefaultFrameLayout(unsigned width, unsigned height) { | |||
| 29 | 29 | ||
| 30 | const float emulation_aspect_ratio{static_cast<float>(ScreenUndocked::Height) / | 30 | const float emulation_aspect_ratio{static_cast<float>(ScreenUndocked::Height) / |
| 31 | ScreenUndocked::Width}; | 31 | ScreenUndocked::Width}; |
| 32 | Common::Rectangle<unsigned> screen_window_area{0, 0, width, height}; | 32 | const auto window_aspect_ratio = static_cast<float>(height) / width; |
| 33 | Common::Rectangle<unsigned> screen = MaxRectangle(screen_window_area, emulation_aspect_ratio); | ||
| 34 | 33 | ||
| 35 | float window_aspect_ratio = static_cast<float>(height) / width; | 34 | const Common::Rectangle<u32> screen_window_area{0, 0, width, height}; |
| 35 | Common::Rectangle<u32> screen = MaxRectangle(screen_window_area, emulation_aspect_ratio); | ||
| 36 | 36 | ||
| 37 | if (window_aspect_ratio < emulation_aspect_ratio) { | 37 | if (window_aspect_ratio < emulation_aspect_ratio) { |
| 38 | screen = screen.TranslateX((screen_window_area.GetWidth() - screen.GetWidth()) / 2); | 38 | screen = screen.TranslateX((screen_window_area.GetWidth() - screen.GetWidth()) / 2); |
| 39 | } else { | 39 | } else { |
| 40 | screen = screen.TranslateY((height - screen.GetHeight()) / 2); | 40 | screen = screen.TranslateY((height - screen.GetHeight()) / 2); |
| 41 | } | 41 | } |
| 42 | |||
| 42 | res.screen = screen; | 43 | res.screen = screen; |
| 43 | return res; | 44 | return res; |
| 44 | } | 45 | } |
| 45 | 46 | ||
| 46 | FramebufferLayout FrameLayoutFromResolutionScale(u16 res_scale) { | 47 | FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale) { |
| 47 | int width, height; | 48 | u32 width, height; |
| 48 | 49 | ||
| 49 | if (Settings::values.use_docked_mode) { | 50 | if (Settings::values.use_docked_mode) { |
| 50 | width = ScreenDocked::WidthDocked * res_scale; | 51 | width = ScreenDocked::WidthDocked * res_scale; |
diff --git a/src/core/frontend/framebuffer_layout.h b/src/core/frontend/framebuffer_layout.h index c2c63d08c..d2370adde 100644 --- a/src/core/frontend/framebuffer_layout.h +++ b/src/core/frontend/framebuffer_layout.h | |||
| @@ -8,15 +8,22 @@ | |||
| 8 | 8 | ||
| 9 | namespace Layout { | 9 | namespace Layout { |
| 10 | 10 | ||
| 11 | enum ScreenUndocked : unsigned { Width = 1280, Height = 720 }; | 11 | enum ScreenUndocked : u32 { |
| 12 | enum ScreenDocked : unsigned { WidthDocked = 1920, HeightDocked = 1080 }; | 12 | Width = 1280, |
| 13 | Height = 720, | ||
| 14 | }; | ||
| 15 | |||
| 16 | enum ScreenDocked : u32 { | ||
| 17 | WidthDocked = 1920, | ||
| 18 | HeightDocked = 1080, | ||
| 19 | }; | ||
| 13 | 20 | ||
| 14 | /// Describes the layout of the window framebuffer | 21 | /// Describes the layout of the window framebuffer |
| 15 | struct FramebufferLayout { | 22 | struct FramebufferLayout { |
| 16 | unsigned width{ScreenUndocked::Width}; | 23 | u32 width{ScreenUndocked::Width}; |
| 17 | unsigned height{ScreenUndocked::Height}; | 24 | u32 height{ScreenUndocked::Height}; |
| 18 | 25 | ||
| 19 | Common::Rectangle<unsigned> screen; | 26 | Common::Rectangle<u32> screen; |
| 20 | 27 | ||
| 21 | /** | 28 | /** |
| 22 | * Returns the ration of pixel size of the screen, compared to the native size of the undocked | 29 | * Returns the ration of pixel size of the screen, compared to the native size of the undocked |
| @@ -33,12 +40,12 @@ struct FramebufferLayout { | |||
| 33 | * @param height Window framebuffer height in pixels | 40 | * @param height Window framebuffer height in pixels |
| 34 | * @return Newly created FramebufferLayout object with default screen regions initialized | 41 | * @return Newly created FramebufferLayout object with default screen regions initialized |
| 35 | */ | 42 | */ |
| 36 | FramebufferLayout DefaultFrameLayout(unsigned width, unsigned height); | 43 | FramebufferLayout DefaultFrameLayout(u32 width, u32 height); |
| 37 | 44 | ||
| 38 | /** | 45 | /** |
| 39 | * Convenience method to get frame layout by resolution scale | 46 | * Convenience method to get frame layout by resolution scale |
| 40 | * @param res_scale resolution scale factor | 47 | * @param res_scale resolution scale factor |
| 41 | */ | 48 | */ |
| 42 | FramebufferLayout FrameLayoutFromResolutionScale(u16 res_scale); | 49 | FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale); |
| 43 | 50 | ||
| 44 | } // namespace Layout | 51 | } // namespace Layout |
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 97dee32e1..7818b141f 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp | |||
| @@ -426,11 +426,12 @@ void GRenderWindow::InitRenderTarget() { | |||
| 426 | BackupGeometry(); | 426 | BackupGeometry(); |
| 427 | } | 427 | } |
| 428 | 428 | ||
| 429 | void GRenderWindow::CaptureScreenshot(u16 res_scale, const QString& screenshot_path) { | 429 | void GRenderWindow::CaptureScreenshot(u32 res_scale, const QString& screenshot_path) { |
| 430 | auto& renderer = Core::System::GetInstance().Renderer(); | 430 | auto& renderer = Core::System::GetInstance().Renderer(); |
| 431 | 431 | ||
| 432 | if (!res_scale) | 432 | if (res_scale == 0) { |
| 433 | res_scale = VideoCore::GetResolutionScaleFactor(renderer); | 433 | res_scale = VideoCore::GetResolutionScaleFactor(renderer); |
| 434 | } | ||
| 434 | 435 | ||
| 435 | const Layout::FramebufferLayout layout{Layout::FrameLayoutFromResolutionScale(res_scale)}; | 436 | const Layout::FramebufferLayout layout{Layout::FrameLayoutFromResolutionScale(res_scale)}; |
| 436 | screenshot_image = QImage(QSize(layout.width, layout.height), QImage::Format_RGB32); | 437 | screenshot_image = QImage(QSize(layout.width, layout.height), QImage::Format_RGB32); |
diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h index 21b4958ff..2fc64895f 100644 --- a/src/yuzu/bootmanager.h +++ b/src/yuzu/bootmanager.h | |||
| @@ -144,7 +144,7 @@ public: | |||
| 144 | 144 | ||
| 145 | void InitRenderTarget(); | 145 | void InitRenderTarget(); |
| 146 | 146 | ||
| 147 | void CaptureScreenshot(u16 res_scale, const QString& screenshot_path); | 147 | void CaptureScreenshot(u32 res_scale, const QString& screenshot_path); |
| 148 | 148 | ||
| 149 | public slots: | 149 | public slots: |
| 150 | void moveContext(); // overridden | 150 | void moveContext(); // overridden |