27 #ifndef INCLUDED_TEX_CODEC
28 #define INCLUDED_TEX_CODEC
137 #define TEX_CODEC_REGISTER(name)\
138 static TexCodecVTbl UID__ = \
140 name##_decode, name##_encode, name##_transform,\
141 name##_is_hdr, name##_is_ext, name##_hdr_size,\
149 void name##_register() { tex_codec_register(&UID__); }
229 extern std::vector<RowPtr>
tex_codec_alloc_rows(
const u8* data,
size_t h,
size_t pitch,
size_t src_flags,
size_t dst_orientation);
243 #endif // #ifndef INCLUDED_TEX_CODEC
bool(* is_ext)(const OsPath &extension)
is the extension that of a file format supported by this codec?
Status(* transform)(Tex *t, size_t transforms)
transform the texture's pixel format.
Status tex_codec_for_filename(const OsPath &extension, const TexCodecVTbl **c)
Find codec that recognizes the desired output file extension.
Status tex_codec_write(Tex *t, size_t transforms, const void *hdr, size_t hdr_size, DynArray *da)
apply transforms and then copy header and image into output buffer.
const TexCodecVTbl * tex_codec_next(const TexCodecVTbl *prev_codec)
enumerate all registered codecs.
Status(* encode)(Tex *RESTRICT t, DynArray *RESTRICT da)
encode the texture data into the codec's file format (in memory).
provides a memory range that can be expanded but doesn't waste physical memory or relocate itself...
const wchar_t * name
name of codec for debug purposes.
Status(* decode)(u8 *data, size_t size, Tex *RESTRICT t)
decode the file into a Tex structure.
std::vector< RowPtr > tex_codec_alloc_rows(const u8 *data, size_t h, size_t pitch, size_t src_flags, size_t dst_orientation)
const TexCodecVTbl * next
intrusive linked-list of codecs: more convenient than fixed-size static storage.
bool(* is_hdr)(const u8 *file)
indicate if the data appears to be an instance of this codec's header, i.e.
i64 Status
Error handling system.
stores all data describing an image.
Status tex_codec_transform(Tex *t, size_t transforms)
transform the texture's pixel format.
const u8 * RowPtr
allocate an array of row pointers that point into the given texture data.
virtual method table for TexCodecs.
size_t(* hdr_size)(const u8 *file)
return size of the file header supported by this codec.
Status tex_codec_for_header(const u8 *file, size_t file_size, const TexCodecVTbl **c)
find codec that recognizes the header's magic field.
int tex_codec_register(TexCodecVTbl *c)
add this vtbl to the codec list.