From 80f8d4989eca127c7ca8c7bd63134127d6fd5edc Mon Sep 17 00:00:00 2001 From: ameerj <52414509+ameerj@users.noreply.github.com> Date: Fri, 10 Sep 2021 01:28:02 -0400 Subject: [PATCH] bootmanager: Fix screenshot resolution factor usage Fixes screenshots at non integer scaling --- src/core/frontend/framebuffer_layout.cpp | 15 ++++++--------- src/core/frontend/framebuffer_layout.h | 2 +- src/yuzu/bootmanager.cpp | 8 +++----- src/yuzu/bootmanager.h | 2 +- src/yuzu/debugger/profiler.cpp | 2 +- src/yuzu/main.cpp | 3 +-- src/yuzu/uisettings.h | 1 - 7 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/core/frontend/framebuffer_layout.cpp b/src/core/frontend/framebuffer_layout.cpp index 0832463d6c..4b58b672ac 100644 --- a/src/core/frontend/framebuffer_layout.cpp +++ b/src/core/frontend/framebuffer_layout.cpp @@ -44,16 +44,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(static_cast(screen_width) * res_scale); + const u32 height = static_cast(static_cast(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 e2e3bbbb39..2e36c01636 100644 --- a/src/core/frontend/framebuffer_layout.h +++ b/src/core/frontend/framebuffer_layout.h @@ -60,7 +60,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 diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 46ab0603dd..976acd1761 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -628,11 +628,9 @@ void GRenderWindow::ReleaseRenderTarget() { main_context.reset(); } -void GRenderWindow::CaptureScreenshot(u32 res_scale, const QString& screenshot_path) { - VideoCore::RendererBase& renderer = system.Renderer(); - if (res_scale == 0) { - res_scale = VideoCore::GetResolutionScaleFactor(renderer); - } +void GRenderWindow::CaptureScreenshot(const QString& screenshot_path) { + auto& renderer = system.Renderer(); + const f32 res_scale = VideoCore::GetResolutionScaleFactor(renderer); const Layout::FramebufferLayout layout{Layout::FrameLayoutFromResolutionScale(res_scale)}; screenshot_image = QImage(QSize(layout.width, layout.height), QImage::Format_RGB32); diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h index e6a0666e9a..40fd4a9d64 100644 --- a/src/yuzu/bootmanager.h +++ b/src/yuzu/bootmanager.h @@ -178,7 +178,7 @@ public: bool IsLoadingComplete() const; - void CaptureScreenshot(u32 res_scale, const QString& screenshot_path); + void CaptureScreenshot(const QString& screenshot_path); std::pair ScaleTouch(const QPointF& pos) const; diff --git a/src/yuzu/debugger/profiler.cpp b/src/yuzu/debugger/profiler.cpp index 33110685ab..a8b2541999 100644 --- a/src/yuzu/debugger/profiler.cpp +++ b/src/yuzu/debugger/profiler.cpp @@ -163,7 +163,7 @@ void MicroProfileWidget::mouseReleaseEvent(QMouseEvent* ev) { } void MicroProfileWidget::wheelEvent(QWheelEvent* ev) { - const auto wheel_position = ev->position().toPoint(); + const auto wheel_position = ev->pos(); MicroProfileMousePosition(wheel_position.x() / x_scale, wheel_position.y() / y_scale, ev->angleDelta().y() / 120); ev->accept(); diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index a246f6bb34..3cb1469825 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -2892,8 +2892,7 @@ void GMainWindow::OnCaptureScreenshot() { } } #endif - render_window->CaptureScreenshot(UISettings::values.screenshot_resolution_factor.GetValue(), - filename); + render_window->CaptureScreenshot(filename); } // TODO: Written 2020-10-01: Remove per-game config migration code when it is irrelevant diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h index cac19452fe..936914ef32 100644 --- a/src/yuzu/uisettings.h +++ b/src/yuzu/uisettings.h @@ -68,7 +68,6 @@ struct Values { Settings::BasicSetting enable_discord_presence{true, "enable_discord_presence"}; Settings::BasicSetting enable_screenshot_save_as{true, "enable_screenshot_save_as"}; - Settings::BasicSetting screenshot_resolution_factor{0, "screenshot_resolution_factor"}; QString roms_path; QString symbols_path;