mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 06:39:46 -06:00
Merge pull request #4326 from degasus/framedump
Framedump: Merge screenshot code with framedumping.
This commit is contained in:
@ -36,7 +36,6 @@
|
||||
#include "VideoCommon/BPFunctions.h"
|
||||
#include "VideoCommon/DriverDetails.h"
|
||||
#include "VideoCommon/Fifo.h"
|
||||
#include "VideoCommon/ImageWrite.h"
|
||||
#include "VideoCommon/IndexGenerator.h"
|
||||
#include "VideoCommon/OnScreenDisplay.h"
|
||||
#include "VideoCommon/PixelEngine.h"
|
||||
@ -1444,23 +1443,8 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
|
||||
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||
|
||||
// Save screenshot
|
||||
if (s_bScreenshot)
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(s_criticalScreenshot);
|
||||
|
||||
if (SaveScreenshot(s_sScreenshotName, flipped_trc))
|
||||
OSD::AddMessage("Screenshot saved to " + s_sScreenshotName);
|
||||
|
||||
// Reset settings
|
||||
s_sScreenshotName.clear();
|
||||
s_bScreenshot = false;
|
||||
s_screenshotCompleted.Set();
|
||||
}
|
||||
|
||||
if (IsFrameDumping())
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(s_criticalScreenshot);
|
||||
std::vector<u8> image(flipped_trc.GetWidth() * flipped_trc.GetHeight() * 4);
|
||||
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
@ -1468,7 +1452,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
|
||||
flipped_trc.GetHeight(), GL_RGBA, GL_UNSIGNED_BYTE, image.data());
|
||||
|
||||
DumpFrameData(image.data(), flipped_trc.GetWidth(), flipped_trc.GetHeight(),
|
||||
flipped_trc.GetWidth() * 4, AVIDump::DumpFormat::FORMAT_RGBA, true);
|
||||
flipped_trc.GetWidth() * 4, true);
|
||||
FinishFrameData();
|
||||
}
|
||||
// Finish up the current frame, print some stats
|
||||
@ -1726,21 +1710,6 @@ void Renderer::SetInterlacingMode()
|
||||
|
||||
namespace OGL
|
||||
{
|
||||
bool Renderer::SaveScreenshot(const std::string& filename, const TargetRectangle& back_rc)
|
||||
{
|
||||
u32 W = back_rc.GetWidth();
|
||||
u32 H = back_rc.GetHeight();
|
||||
std::unique_ptr<u8[]> data(new u8[W * 4 * H]);
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
|
||||
glReadPixels(back_rc.left, back_rc.bottom, W, H, GL_RGBA, GL_UNSIGNED_BYTE, data.get());
|
||||
|
||||
// Turn image upside down
|
||||
FlipImageData(data.get(), W, H, 4);
|
||||
|
||||
return TextureToPng(data.get(), W * 4, filename, W, H, false);
|
||||
}
|
||||
|
||||
u32 Renderer::GetMaxTextureSize()
|
||||
{
|
||||
// Right now nvidia seems to do something very weird if we try to cache GL_MAX_TEXTURE_SIZE in
|
||||
|
@ -101,8 +101,6 @@ public:
|
||||
|
||||
void ReinterpretPixelData(unsigned int convtype) override;
|
||||
|
||||
bool SaveScreenshot(const std::string& filename, const TargetRectangle& rc) override;
|
||||
|
||||
u32 GetMaxTextureSize() override;
|
||||
|
||||
void ChangeSurface(void* new_surface_handle) override;
|
||||
|
@ -220,19 +220,6 @@ void VertexManager::vFlush(bool useDstAlpha)
|
||||
OpenFStream(fvs, filename, std::ios_base::out);
|
||||
fvs << prog.shader.strvprog;
|
||||
}
|
||||
|
||||
if (g_ActiveConfig.iLog & CONF_SAVETARGETS)
|
||||
{
|
||||
std::string filename =
|
||||
StringFromFormat("%starg%.3d.png", File::GetUserPath(D_DUMPFRAMES_IDX).c_str(),
|
||||
g_ActiveConfig.iSaveTargetId);
|
||||
TargetRectangle tr;
|
||||
tr.left = 0;
|
||||
tr.right = Renderer::GetTargetWidth();
|
||||
tr.top = 0;
|
||||
tr.bottom = Renderer::GetTargetHeight();
|
||||
g_renderer->SaveScreenshot(filename, tr);
|
||||
}
|
||||
#endif
|
||||
g_Config.iSaveTargetId++;
|
||||
|
||||
|
Reference in New Issue
Block a user