diff options
author | zhupengfei <zhupengfei321@sina.cn> | 2018-08-31 14:16:16 +0800 |
---|---|---|
committer | fearlessTobi <thm.frey@gmail.com> | 2018-12-18 22:54:41 +0100 |
commit | a2be49305d8c5c66cfa2ec2060688013cf3729b9 (patch) | |
tree | 2a2e38805ae8af0718628682d7e911ccb253fc16 /src/yuzu/bootmanager.cpp | |
parent | f761e3ef8627b9f93b9766d6de76a61af7c9e5a9 (diff) |
yuzu, video_core: Screenshot functionality
Allows capturing screenshot at the current internal resolution (native for software renderer), but a setting is available to capture it in other resolutions. The screenshot is saved to a single PNG in the current layout.
Diffstat (limited to 'src/yuzu/bootmanager.cpp')
-rw-r--r-- | src/yuzu/bootmanager.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 384e17921e..40db7a5e92 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -14,6 +14,8 @@ #include "input_common/keyboard.h" #include "input_common/main.h" #include "input_common/motion_emu.h" +#include "video_core/renderer_base.h" +#include "video_core/video_core.h" #include "yuzu/bootmanager.h" EmuThread::EmuThread(GRenderWindow* render_window) : render_window(render_window) {} @@ -333,6 +335,22 @@ void GRenderWindow::InitRenderTarget() { BackupGeometry(); } +void GRenderWindow::CaptureScreenshot(u16 res_scale, const QString& screenshot_path) { + auto& renderer = Core::System::GetInstance().Renderer(); + + if (!res_scale) + res_scale = VideoCore::GetResolutionScaleFactor(renderer); + + const Layout::FramebufferLayout layout{Layout::FrameLayoutFromResolutionScale(res_scale)}; + screenshot_image = QImage(QSize(layout.width, layout.height), QImage::Format_RGB32); + renderer.RequestScreenshot(screenshot_image.bits(), + [=] { + screenshot_image.mirrored(false, true).save(screenshot_path); + LOG_INFO(Frontend, "The screenshot is saved."); + }, + layout); +} + void GRenderWindow::OnMinimalClientAreaChangeRequest( const std::pair<unsigned, unsigned>& minimal_size) { setMinimumSize(minimal_size.first, minimal_size.second); |