diff options
author | Lioncash <mathew1800@gmail.com> | 2016-04-14 01:29:16 +0200 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2016-04-14 02:17:17 +0200 |
commit | a4120ca66cc6c0f3a8056c6ea247c15f63c7feff (patch) | |
tree | a0db95eee61ce8070add52e3abd55971be6458df /src/video_core/debug_utils/debug_utils.cpp | |
parent | file_util: Check for is_trivially_copyable (diff) | |
download | yuzu-a4120ca66cc6c0f3a8056c6ea247c15f63c7feff.tar yuzu-a4120ca66cc6c0f3a8056c6ea247c15f63c7feff.tar.gz yuzu-a4120ca66cc6c0f3a8056c6ea247c15f63c7feff.tar.bz2 yuzu-a4120ca66cc6c0f3a8056c6ea247c15f63c7feff.tar.lz yuzu-a4120ca66cc6c0f3a8056c6ea247c15f63c7feff.tar.xz yuzu-a4120ca66cc6c0f3a8056c6ea247c15f63c7feff.tar.zst yuzu-a4120ca66cc6c0f3a8056c6ea247c15f63c7feff.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/debug_utils/debug_utils.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp index 693f93597..c8752c003 100644 --- a/src/video_core/debug_utils/debug_utils.cpp +++ b/src/video_core/debug_utils/debug_utils.cpp @@ -586,6 +586,21 @@ TextureInfo TextureInfo::FromPicaRegister(const Regs::TextureConfig& config, return info; } +#ifdef HAVE_PNG +// Adapter functions to libpng to write/flush to File::IOFile instances. +static void WriteIOFile(png_structp png_ptr, png_bytep data, png_size_t length) { + auto* fp = static_cast<FileUtil::IOFile*>(png_get_io_ptr(png_ptr)); + if (!fp->WriteBytes(data, length)) + png_error(png_ptr, "Failed to write to output PNG file."); +} + +static void FlushIOFile(png_structp png_ptr) { + auto* fp = static_cast<FileUtil::IOFile*>(png_get_io_ptr(png_ptr)); + if (!fp->Flush()) + png_error(png_ptr, "Failed to flush to output PNG file."); +} +#endif + void DumpTexture(const Pica::Regs::TextureConfig& texture_config, u8* data) { #ifndef HAVE_PNG return; @@ -629,7 +644,7 @@ void DumpTexture(const Pica::Regs::TextureConfig& texture_config, u8* data) { goto finalise; } - png_init_io(png_ptr, fp.GetHandle()); + png_set_write_fn(png_ptr, static_cast<void*>(&fp), WriteIOFile, FlushIOFile); // Write header (8 bit color depth) png_set_IHDR(png_ptr, info_ptr, texture_config.width, texture_config.height, |