Pyrogenesis
13997
|
virtual method table for TexCodecs. More...
#include <tex_codec.h>
Public Attributes | |
Status(* | decode )(u8 *data, size_t size, Tex *RESTRICT t) |
decode the file into a Tex structure. More... | |
Status(* | encode )(Tex *RESTRICT t, DynArray *RESTRICT da) |
encode the texture data into the codec's file format (in memory). More... | |
Status(* | transform )(Tex *t, size_t transforms) |
transform the texture's pixel format. More... | |
bool(* | is_hdr )(const u8 *file) |
indicate if the data appears to be an instance of this codec's header, i.e. More... | |
bool(* | is_ext )(const OsPath &extension) |
is the extension that of a file format supported by this codec? More... | |
size_t(* | hdr_size )(const u8 *file) |
return size of the file header supported by this codec. More... | |
const wchar_t * | name |
name of codec for debug purposes. More... | |
const TexCodecVTbl * | next |
intrusive linked-list of codecs: more convenient than fixed-size static storage. More... | |
virtual method table for TexCodecs.
rationale: this works in C and also allows storing name and next in vtbl. 'template method'-style interface to increase code reuse and simplify writing new codecs.
Definition at line 39 of file tex_codec.h.
decode the file into a Tex structure.
data | input data array (non-const, because the texture may have to be flipped in-place - see "texture orientation"). |
size | [bytes] of data, always >= 4 (this is usually enough to compare the header's "magic" field, and no legitimate file will be smaller) |
t | output texture object |
Definition at line 52 of file tex_codec.h.
encode the texture data into the codec's file format (in memory).
t | input texture object. note: non-const because encoding may require a tex_transform. |
da | output data array, allocated by codec. rationale: some codecs cannot calculate the output size beforehand (e.g. PNG output via libpng), so the output memory cannot be allocated by the caller. |
Definition at line 65 of file tex_codec.h.
size_t(* TexCodecVTbl::hdr_size)(const u8 *file) |
return size of the file header supported by this codec.
file | the specific header to return length of (taking its variable-length fields into account). if NULL, return minimum guaranteed header size, i.e. the header without any variable-length fields. |
Definition at line 109 of file tex_codec.h.
is the extension that of a file format supported by this codec?
rationale: cannot just return the extension string and have caller compare it (-> smaller code) because a codec's file format may have several valid extensions (e.g. jpg and jpeg).
extension | (including '.') |
Definition at line 98 of file tex_codec.h.
bool(* TexCodecVTbl::is_hdr)(const u8 *file) |
indicate if the data appears to be an instance of this codec's header, i.e.
can this codec decode it?
file | input data; only guaranteed to be 4 bytes! (this should be enough to examine the header's 'magic' field) |
Definition at line 86 of file tex_codec.h.
const wchar_t* TexCodecVTbl::name |
name of codec for debug purposes.
typically set via TEX_CODEC_REGISTER.
Definition at line 114 of file tex_codec.h.
const TexCodecVTbl* TexCodecVTbl::next |
intrusive linked-list of codecs: more convenient than fixed-size static storage.
set by caller; should be initialized to NULL.
Definition at line 121 of file tex_codec.h.
transform the texture's pixel format.
t | texture object |
transforms,: | OR-ed combination of TEX_* flags that are to be changed. note: the codec needs only handle situations specific to its format; generic pixel format transforms are handled by the caller. |
Definition at line 76 of file tex_codec.h.