Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Macros | Functions | Variables
tex_codec.cpp File Reference
#include "precompiled.h"
#include "tex_codec.h"
#include <string.h>
#include <stdlib.h>
#include "lib/allocators/shared_ptr.h"
#include "tex.h"

Go to the source code of this file.

Macros

#define REGISTER_CODEC(name)   extern void name##_register(); name##_register()
 

Functions

int tex_codec_register (TexCodecVTbl *c)
 add this vtbl to the codec list. More...
 
void tex_codec_unregister_all ()
 remove all codecs that have been registered. 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 *file, size_t file_size, const TexCodecVTbl **c)
 find codec that recognizes the header's magic field. More...
 
const TexCodecVTbltex_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...
 
void tex_codec_register_all ()
 Manually register codecs. More...
 
std::vector< RowPtrtex_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...
 

Variables

static const TexCodecVTblcodecs
 

Macro Definition Documentation

#define REGISTER_CODEC (   name)    extern void name##_register(); name##_register()

Function Documentation

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.

Parameters
extension
c(out) vtbl of responsible codec
Returns
Status; ERR::RES_UNKNOWN_FORMAT (without warning, because this is called by tex_is_known_extension) if no codec indicates they can handle the given extension.

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.

Parameters
datatypically contents of file, but need only include the (first 4 bytes of) header.
data_size[bytes]
c(out) vtbl of responsible codec
Returns
Status; ERR::RES_UNKNOWN_FORMAT if no codec indicates they can handle the given format (header).

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.

Parameters
prev_codecthe last codec returned by this function. pass 0 the first time. note: this routine is stateless and therefore reentrant.
Returns
the next codec, or 0 if all have been returned.

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.

Parameters
cpointer to vtbl.
Returns
int (allows calling from a macro at file scope; value is not used)

Definition at line 44 of file tex_codec.cpp.

void tex_codec_register_all ( )

Manually register codecs.

must be called before first use of a codec (e.g. loading a texture).

This would normally be taken care of by TEX_CODEC_REGISTER, but no longer works when building as a static library. Workaround: hard-code a list of codecs in tex_codec.cpp and call their registration functions.

Definition at line 134 of file tex_codec.cpp.

Status tex_codec_transform ( Tex t,
size_t  transforms 
)

transform the texture's pixel format.

tries each codec's transform method once, or until one indicates success.

Parameters
ttexture object
transforms,:OR-ed combination of TEX_* flags that are to be changed.
Returns
Status

Definition at line 107 of file tex_codec.cpp.

void tex_codec_unregister_all ( )

remove all codecs that have been registered.

Definition at line 56 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.

Parameters
tinput texture object
transformstransformations to be applied to pixel format
hdrheader data
hdr_size[bytes]
daoutput data array (will be expanded as necessary)
Returns
Status

Definition at line 176 of file tex_codec.cpp.

Variable Documentation

const TexCodecVTbl* codecs
static

Definition at line 36 of file tex_codec.cpp.