Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Attributes | List of all members
TexCodecVTbl Struct Reference

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_tname
 name of codec for debug purposes. More...
 
const TexCodecVTblnext
 intrusive linked-list of codecs: more convenient than fixed-size static storage. More...
 

Detailed Description

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.

Member Data Documentation

Status(* TexCodecVTbl::decode)(u8 *data, size_t size, Tex *RESTRICT t)

decode the file into a Tex structure.

Parameters
datainput 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)
toutput texture object
Returns
Status

Definition at line 52 of file tex_codec.h.

Status(* TexCodecVTbl::encode)(Tex *RESTRICT t, DynArray *RESTRICT da)

encode the texture data into the codec's file format (in memory).

Parameters
tinput texture object. note: non-const because encoding may require a tex_transform.
daoutput 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.
Returns
Status

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.

Parameters
filethe 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.
Returns
size [bytes]

Definition at line 109 of file tex_codec.h.

bool(* TexCodecVTbl::is_ext)(const OsPath &extension)

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).

Parameters
extension(including '.')
Returns
bool

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?

Parameters
fileinput data; only guaranteed to be 4 bytes! (this should be enough to examine the header's 'magic' field)
Returns
bool

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.

Status(* TexCodecVTbl::transform)(Tex *t, size_t transforms)

transform the texture's pixel format.

Parameters
ttexture 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.


The documentation for this struct was generated from the following file: