|
0 A.D. | |||||||
| FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
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.
| Field Summary | |
LibError ( * )( DynArray* RESTRICT da, Tex* RESTRICT t ) |
decode
decode the file into a Tex structure. |
LibError ( * )( Tex* RESTRICT t, DynArray* RESTRICT da ) |
encode
encode the texture data into the codec's file format (in memory). |
size_t ( * )( const u8* file ) |
hdr_size
return size of the file header supported by this codec. |
bool ( * )( const char* ext ) |
is_ext
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). |
bool ( * )( const u8* file ) |
is_hdr
indicate if the data appears to be an instance of this codec's header, i. |
const char* |
name
name of codec for debug purposes. |
const TexCodecVTbl* |
next
intrusive linked-list of codecs: more convenient than fixed-size static storage. |
LibError ( * )( Tex* t, uint s ) |
transform
transform the texture's pixel format. |
| Field Detail |
public LibError ( * decode )( DynArray* RESTRICT da, Tex* RESTRICT t );
da - input data array (not const, because the texture
may have to be flipped in-place - see "texture orientation").
its size is guaranteed to be >= 4.
(usually enough to compare the header's "magic" field;
anyway, no legitimate file will be smaller)
t - output texture objectpublic LibError ( * encode )( Tex* RESTRICT t, DynArray* RESTRICT da );
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.public size_t ( * hdr_size )( const u8* file );
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.public bool ( * is_ext )( const char* ext );
ext - non-NULL extension string; does not contain '.'.
must be compared as case-insensitive.public bool ( * is_hdr )( const u8* file );
file - input data; only guaranteed to be 4 bytes!
(this should be enough to examine the header's 'magic' field)public const char* name;
public const TexCodecVTbl* next;
public LibError ( * transform )( Tex* t, uint transforms );
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.
|
0 A.D.
Generated on September 04, 2007 at 18:14 CppDoc v2.4.0 |
|||||||
| FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||