9 #ifndef hifi_gpu_FrameIO_h
10 #define hifi_gpu_FrameIO_h
15 #include <shared/Storage.h>
21 using TextureCapturer = std::function<storage::StoragePointer(
const TexturePointer&)>;
23 void writeFrame(
const std::string& filename,
const FramePointer& frame,
const TextureCapturer& capturer =
nullptr);
24 FramePointer readFrame(
const std::string& filename, uint32_t externalTexture);
28 using Storage = storage::Storage;
29 using StoragePointer = storage::Pointer;
30 using StorageBuilders = storage::Builders;
32 constexpr
const char*
const EXTENSION{
".hfb" };
33 constexpr uint32_t HEADER_SIZE{
sizeof(uint32_t) * 3 };
34 constexpr uint32_t CHUNK_HEADER_SIZE =
sizeof(uint32_t) * 2;
35 constexpr uint32_t MAGIC{ 0x49464948 };
36 constexpr uint32_t VERSION{ 0x01 };
37 constexpr uint32_t CHUNK_TYPE_JSON{ 0x4E4F534A };
38 constexpr uint32_t CHUNK_TYPE_KTX{ 0x0058544b };
39 constexpr uint32_t CHUNK_TYPE_BIN{ 0x004E4942 };
40 constexpr uint32_t CHUNK_TYPE_PNG{ 0x00474E50 };
42 using Buffer = std::vector<uint8_t>;
46 uint32_t version{ 0 };
55 struct Chunk :
public ChunkHeader {
61 using Chunks = std::vector<Chunk>;
64 using Pointer = std::shared_ptr<Descriptor>;
68 StoragePointer storage;
70 Descriptor(
const StoragePointer& storage);
71 operator bool()
const {
return header.magic == MAGIC; }
72 StoragePointer getChunk(uint32_t chunk)
const;
75 void writeFrame(
const std::string& filename,
76 const std::string& json,
77 const Buffer& binaryBuffer,
78 const StorageBuilders& pngBuffers);