diff options
| author | Markus Wick <degasus@users.noreply.github.com> | 2016-10-10 11:48:57 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-10-10 11:48:57 +0200 |
| commit | a583d36c7f38fac9fb66c059bf6990bfd819591f (patch) | |
| tree | 842adfb6ca1a3ac76b290677bd72db2a406b781f /Source/Core/VideoCommon/RenderBase.cpp | |
| parent | 562bc01d0e21f103fa9d8ee1993654a81e51fb26 (diff) | |
| parent | 64927a2f81fe64503060c949ead525995fd63a2a (diff) | |
Merge pull request #4326 from degasus/framedump
Framedump: Merge screenshot code with framedumping.
Diffstat (limited to 'Source/Core/VideoCommon/RenderBase.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/RenderBase.cpp | 64 |
1 files changed, 39 insertions, 25 deletions
diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index e523fd8a67..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; @@ -546,7 +550,6 @@ bool Renderer::IsFrameDumping() { AVIDump::Stop(); std::vector<u8>().swap(m_frame_data); - m_last_framedump_width = m_last_framedump_height = 0; m_AVI_dumping = false; OSD::AddMessage("Stop dumping frames", 2000); } @@ -555,43 +558,54 @@ bool Renderer::IsFrameDumping() return false; } -void Renderer::DumpFrameData(const u8* data, int w, int h, int stride, AVIDump::DumpFormat format, - bool swap_upside_down) +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; - m_last_framedump_width = w; - m_last_framedump_height = h; - m_last_framedump_format = format; - m_last_framedump_stride = stride; - // 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); - if (!m_last_frame_dumped) + // Save screenshot + if (s_bScreenshot) { - m_AVI_dumping = AVIDump::Start(w, h, format); - if (!m_AVI_dumping) + 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 defined(HAVE_LIBAV) || defined(_WIN32) + if (SConfig::GetInstance().m_DumpFrames) + { + 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 } |
