summaryrefslogtreecommitdiff
path: root/src/video_core/debug_utils
diff options
context:
space:
mode:
authorGravatar bunnei2016-04-14 16:28:15 -0400
committerGravatar bunnei2016-04-14 16:28:15 -0400
commitaff35d3e58f65b72e22b079cafbf5c35135c3814 (patch)
tree0ea7f1fee63d93709d7b7f2f751897b5fb8afe91 /src/video_core/debug_utils
parentMerge pull request #1546 from bunnei/refactor-shader-jit (diff)
parentfile_util: In-class initialize data members (diff)
downloadyuzu-aff35d3e58f65b72e22b079cafbf5c35135c3814.tar.gz
yuzu-aff35d3e58f65b72e22b079cafbf5c35135c3814.tar.xz
yuzu-aff35d3e58f65b72e22b079cafbf5c35135c3814.zip
Merge pull request #1665 from lioncash/file
IOFile: Minor API changes
Diffstat (limited to 'src/video_core/debug_utils')
-rw-r--r--src/video_core/debug_utils/debug_utils.cpp17
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,
586 return info; 586 return info;
587} 587}
588 588
589#ifdef HAVE_PNG
590// Adapter functions to libpng to write/flush to File::IOFile instances.
591static void WriteIOFile(png_structp png_ptr, png_bytep data, png_size_t length) {
592 auto* fp = static_cast<FileUtil::IOFile*>(png_get_io_ptr(png_ptr));
593 if (!fp->WriteBytes(data, length))
594 png_error(png_ptr, "Failed to write to output PNG file.");
595}
596
597static void FlushIOFile(png_structp png_ptr) {
598 auto* fp = static_cast<FileUtil::IOFile*>(png_get_io_ptr(png_ptr));
599 if (!fp->Flush())
600 png_error(png_ptr, "Failed to flush to output PNG file.");
601}
602#endif
603
589void DumpTexture(const Pica::Regs::TextureConfig& texture_config, u8* data) { 604void DumpTexture(const Pica::Regs::TextureConfig& texture_config, u8* data) {
590#ifndef HAVE_PNG 605#ifndef HAVE_PNG
591 return; 606 return;
@@ -629,7 +644,7 @@ void DumpTexture(const Pica::Regs::TextureConfig& texture_config, u8* data) {
629 goto finalise; 644 goto finalise;
630 } 645 }
631 646
632 png_init_io(png_ptr, fp.GetHandle()); 647 png_set_write_fn(png_ptr, static_cast<void*>(&fp), WriteIOFile, FlushIOFile);
633 648
634 // Write header (8 bit color depth) 649 // Write header (8 bit color depth)
635 png_set_IHDR(png_ptr, info_ptr, texture_config.width, texture_config.height, 650 png_set_IHDR(png_ptr, info_ptr, texture_config.width, texture_config.height,