Pyrogenesis
13997
|
Go to the source code of this file.
Classes | |
struct | TexCodecVTbl |
virtual method table for TexCodecs. More... | |
Macros | |
#define | TEX_CODEC_REGISTER(name) |
build codec vtbl and register it. More... | |
Typedefs | |
typedef const u8 * | RowPtr |
allocate an array of row pointers that point into the given texture data. More... | |
Functions | |
int | tex_codec_register (TexCodecVTbl *c) |
add this vtbl to the codec list. More... | |
Status | tex_codec_for_filename (const OsPath &extension, const TexCodecVTbl **c) |
Find codec that recognizes the desired output file extension. More... | |
Status | tex_codec_for_header (const u8 *data, size_t data_size, const TexCodecVTbl **c) |
find codec that recognizes the header's magic field. More... | |
const TexCodecVTbl * | tex_codec_next (const TexCodecVTbl *prev_codec) |
enumerate all registered codecs. More... | |
Status | tex_codec_transform (Tex *t, size_t transforms) |
transform the texture's pixel format. More... | |
std::vector< RowPtr > | tex_codec_alloc_rows (const u8 *data, size_t h, size_t pitch, size_t src_flags, size_t dst_orientation) |
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. More... | |
#define TEX_CODEC_REGISTER | ( | name | ) |
build codec vtbl and register it.
the codec will be queried for future texture load requests. call order is undefined, but since each codec only steps up if it can handle the given format, this is not a problem.
name | identifier of codec (not string!). used to bind 'member' functions prefixed with it to the vtbl, and as the TexCodecVTbl name. it should also mirror the default file extension (e.g. dds) - this is relied upon (but verified) in the self-test. |
usage: at file scope within the source file containing the codec's methods.
Definition at line 137 of file tex_codec.h.
allocate an array of row pointers that point into the given texture data.
for texture decoders that support output via row pointers (e.g. PNG), this allows flipping the image vertically (useful when matching bottom-up textures to a global orientation) directly, which is much more efficient than transforming later via copying all pixels.
data | the texture data into which row pointers will point. note: we don't allocate it here because this function is needed for encoding, too (where data is already present). |
h | height [pixels] of texture. |
pitch | size [bytes] of one texture row, i.e. width*bytes_per_pixel. |
src_flags | TexFlags of source texture. used to extract its orientation. |
dst_orientation | desired orientation of the output data. can be one of TEX_BOTTOM_UP, TEX_TOP_DOWN, or 0 for the "global orientation". depending on src and dst, the row array is flipped if necessary. |
Definition at line 228 of file tex_codec.h.
std::vector<RowPtr> tex_codec_alloc_rows | ( | const u8 * | data, |
size_t | h, | ||
size_t | pitch, | ||
size_t | src_flags, | ||
size_t | dst_orientation | ||
) |
Definition at line 154 of file tex_codec.cpp.
Status tex_codec_for_filename | ( | const OsPath & | extension, |
const TexCodecVTbl ** | c | ||
) |
Find codec that recognizes the desired output file extension.
extension | |
c | (out) vtbl of responsible codec |
Definition at line 65 of file tex_codec.cpp.
Status tex_codec_for_header | ( | const u8 * | data, |
size_t | data_size, | ||
const TexCodecVTbl ** | c | ||
) |
find codec that recognizes the header's magic field.
data | typically contents of file, but need only include the (first 4 bytes of) header. |
data_size | [bytes] |
c | (out) vtbl of responsible codec |
Definition at line 79 of file tex_codec.cpp.
const TexCodecVTbl* tex_codec_next | ( | const TexCodecVTbl * | prev_codec | ) |
enumerate all registered codecs.
used by self-test to test each one of them in turn.
prev_codec | the last codec returned by this function. pass 0 the first time. note: this routine is stateless and therefore reentrant. |
Definition at line 96 of file tex_codec.cpp.
int tex_codec_register | ( | TexCodecVTbl * | c | ) |
add this vtbl to the codec list.
called at NLSO init time by the TEX_CODEC_REGISTER in each codec file. order in list is unspecified; see TEX_CODEC_REGISTER.
c | pointer to vtbl. |
Definition at line 44 of file tex_codec.cpp.
transform the texture's pixel format.
tries each codec's transform method once, or until one indicates success.
t | texture object |
transforms,: | OR-ed combination of TEX_* flags that are to be changed. |
Definition at line 107 of file tex_codec.cpp.
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.
t | input texture object |
transforms | transformations to be applied to pixel format |
hdr | header data |
hdr_size | [bytes] |
da | output data array (will be expanded as necessary) |
Definition at line 176 of file tex_codec.cpp.