| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include "Common/CommonTypes.h" |
| 7 |
#include "Common/Event.h" |
| 8 |
#include "Common/Flag.h" |
| 9 |
#include "Common/MathUtil.h" |
| 10 |
#include "Common/Thread.h" |
| 11 |
|
| 12 |
#include "VideoCommon/FrameDumpFFMpeg.h" |
| 13 |
#include "VideoCommon/VideoEvents.h" |
| 14 |
|
| 15 |
class AbstractStagingTexture; |
| 16 |
class AbstractTexture; |
| 17 |
class AbstractFramebuffer; |
| 18 |
|
| 19 |
class FrameDumper |
| 20 |
{ |
| 21 |
public: |
| 22 |
FrameDumper(); |
| 23 |
~FrameDumper(); |
| 24 |
|
| 25 |
|
| 26 |
void FlushFrameDump(); |
| 27 |
|
| 28 |
|
| 29 |
void DumpCurrentFrame(const AbstractTexture* src_texture, |
| 30 |
const MathUtil::Rectangle<int>& src_rect, |
| 31 |
const MathUtil::Rectangle<int>& target_rect, u64 ticks, int frame_number); |
| 32 |
|
| 33 |
void SaveScreenshot(std::string filename); |
| 34 |
|
| 35 |
bool IsFrameDumping() const; |
| 36 |
int GetRequiredResolutionLeastCommonMultiple() const; |
| 37 |
|
| 38 |
void DoState(PointerWrap& p); |
| 39 |
|
| 40 |
private: |
| 41 |
|
| 42 |
void FrameDumpThreadFunc(); |
| 43 |
bool StartFrameDumpToFFMPEG(const FrameData&); |
| 44 |
void DumpFrameToFFMPEG(const FrameData&); |
| 45 |
void StopFrameDumpToFFMPEG(); |
| 46 |
std::string GetFrameDumpNextImageFileName() const; |
| 47 |
bool StartFrameDumpToImage(const FrameData&); |
| 48 |
void DumpFrameToImage(const FrameData&); |
| 49 |
|
| 50 |
void ShutdownFrameDumping(); |
| 51 |
|
| 52 |
|
| 53 |
bool CheckFrameDumpRenderTexture(u32 target_width, u32 target_height); |
| 54 |
|
| 55 |
|
| 56 |
bool CheckFrameDumpReadbackTexture(u32 target_width, u32 target_height); |
| 57 |
|
| 58 |
|
| 59 |
void DumpFrameData(const u8* data, int w, int h, int stride); |
| 60 |
|
| 61 |
|
| 62 |
void FinishFrameData(); |
| 63 |
|
| 64 |
std::thread m_frame_dump_thread; |
| 65 |
Common::Flag m_frame_dump_thread_running; |
| 66 |
|
| 67 |
|
| 68 |
Common::Event m_frame_dump_start; |
| 69 |
|
| 70 |
|
| 71 |
Common::Event m_frame_dump_done; |
| 72 |
|
| 73 |
|
| 74 |
FrameState m_last_frame_state; |
| 75 |
|
| 76 |
|
| 77 |
FrameData m_frame_dump_data; |
| 78 |
|
| 79 |
|
| 80 |
std::unique_ptr<AbstractTexture> m_frame_dump_render_texture; |
| 81 |
std::unique_ptr<AbstractFramebuffer> m_frame_dump_render_framebuffer; |
| 82 |
|
| 83 |
|
| 84 |
std::unique_ptr<AbstractStagingTexture> m_frame_dump_readback_texture; |
| 85 |
std::unique_ptr<AbstractStagingTexture> m_frame_dump_output_texture; |
| 86 |
|
| 87 |
bool m_frame_dump_needs_flush = false; |
| 88 |
|
| 89 |
bool m_frame_dump_frame_running = false; |
| 90 |
|
| 91 |
|
| 92 |
u32 m_frame_dump_image_counter = 0; |
| 93 |
|
| 94 |
FFMpegFrameDump m_ffmpeg_dump; |
| 95 |
|
| 96 |
|
| 97 |
Common::Flag m_screenshot_request; |
| 98 |
Common::Event m_screenshot_completed; |
| 99 |
std::mutex m_screenshot_lock; |
| 100 |
std::string m_screenshot_name; |
| 101 |
|
| 102 |
Common::EventHook m_frame_end_handle; |
| 103 |
}; |
| 104 |
|
| 105 |
extern std::unique_ptr<FrameDumper> g_frame_dumper; |