citra_qt, 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.
This commit is contained in:
zhupengfei
2018-08-31 14:16:16 +08:00
committed by zhupengfei
parent 7e90abec78
commit 071b41cb61
14 changed files with 202 additions and 14 deletions

View File

@ -15,6 +15,7 @@
#include "input_common/main.h"
#include "input_common/motion_emu.h"
#include "network/network.h"
#include "video_core/video_core.h"
EmuThread::EmuThread(GRenderWindow* render_window) : render_window(render_window) {}
@ -335,6 +336,19 @@ void GRenderWindow::InitRenderTarget() {
BackupGeometry();
}
void GRenderWindow::CaptureScreenshot(u16 res_scale, const QString& screenshot_path) {
if (!res_scale)
res_scale = VideoCore::GetResolutionScaleFactor();
const Layout::FramebufferLayout layout{Layout::FrameLayoutFromResolutionScale(res_scale)};
screenshot_image = QImage(QSize(layout.width, layout.height), QImage::Format_RGB32);
VideoCore::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);