diff options
| author | degasus <wickmarkus@web.de> | 2016-10-08 18:23:57 +0200 |
|---|---|---|
| committer | degasus <wickmarkus@web.de> | 2016-10-08 19:38:57 +0200 |
| commit | 64927a2f81fe64503060c949ead525995fd63a2a (patch) | |
| tree | c40d8f488df2c695a1e97cbe49198ffaf99fcfe1 /Source/Core/VideoCommon/RenderBase.cpp | |
| parent | 21e42c68c4ec1e9e9925f3cfeefed12054cc6b71 (diff) | |
Renderer: Merge screenshot logic into VideoCommon.
Diffstat (limited to 'Source/Core/VideoCommon/RenderBase.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/RenderBase.cpp | 55 |
1 files changed, 38 insertions, 17 deletions
diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index 21bf1eeb54..9a81fa5e4d 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -41,6 +41,7 @@ #include "VideoCommon/Debugger.h" #include "VideoCommon/FPSCounter.h" #include "VideoCommon/FramebufferManagerBase.h" +#include "VideoCommon/ImageWrite.h" #include "VideoCommon/PostProcessing.h" #include "VideoCommon/RenderBase.h" #include "VideoCommon/Statistics.h" @@ -538,6 +539,9 @@ void Renderer::Swap(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, const bool Renderer::IsFrameDumping() { + if (s_bScreenshot) + return true; + #if defined(HAVE_LIBAV) || defined(_WIN32) if (SConfig::GetInstance().m_DumpFrames) return true; @@ -556,35 +560,52 @@ bool Renderer::IsFrameDumping() void Renderer::DumpFrameData(const u8* data, int w, int h, int stride, bool swap_upside_down) { -#if defined(HAVE_LIBAV) || defined(_WIN32) if (w == 0 || h == 0) return; // TODO: Refactor this. Right now it's needed for the implace flipping of the image. m_frame_data.assign(data, data + stride * h); + if (swap_upside_down) + FlipImageData(m_frame_data.data(), w, h, 4); + + // Save screenshot + if (s_bScreenshot) + { + std::lock_guard<std::mutex> lk(s_criticalScreenshot); + + if (TextureToPng(m_frame_data.data(), stride, s_sScreenshotName, w, h, false)) + OSD::AddMessage("Screenshot saved to " + s_sScreenshotName); + + // Reset settings + s_sScreenshotName.clear(); + s_bScreenshot = false; + s_screenshotCompleted.Set(); + } - if (!m_last_frame_dumped) +#if defined(HAVE_LIBAV) || defined(_WIN32) + if (SConfig::GetInstance().m_DumpFrames) { - m_AVI_dumping = AVIDump::Start(w, h); - if (!m_AVI_dumping) + if (!m_last_frame_dumped) { - OSD::AddMessage("AVIDump Start failed", 2000); + m_AVI_dumping = AVIDump::Start(w, h); + if (!m_AVI_dumping) + { + OSD::AddMessage("AVIDump Start failed", 2000); + } + else + { + OSD::AddMessage(StringFromFormat("Dumping Frames to \"%sframedump0.avi\" (%dx%d RGB24)", + File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), w, h), + 2000); + } } - else + if (m_AVI_dumping) { - OSD::AddMessage(StringFromFormat("Dumping Frames to \"%sframedump0.avi\" (%dx%d RGB24)", - File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), w, h), - 2000); + AVIDump::AddFrame(m_frame_data.data(), w, h, stride); } - } - if (m_AVI_dumping) - { - if (swap_upside_down) - FlipImageData(m_frame_data.data(), w, h, 4); - AVIDump::AddFrame(m_frame_data.data(), w, h, stride); - } - m_last_frame_dumped = true; + m_last_frame_dumped = true; + } #endif } |
