Pyrogenesis trunk
|
#include "precompiled.h"
#include "tex.h"
#include "lib/allocators/shared_ptr.h"
#include "lib/bits.h"
#include "lib/sysdep/cpu.h"
#include "lib/tex/tex_codec.h"
#include "lib/timer.h"
#include <algorithm>
#include <cmath>
#include <cstdlib>
Classes | |
struct | CreateLevelData |
Macros | |
#define | CHECK_TEX(t) RETURN_STATUS_IF_ERR((t->validate())) |
Functions | |
STATUS_ADD_DEFINITIONS (texStatusDefinitions) | |
Status | tex_validate_plain_format (size_t bpp, size_t flags) |
check if the given texture format is acceptable: 8bpp grey, 24bpp color or 32bpp color+alpha (BGR / upside down are permitted). More... | |
void | tex_util_foreach_mipmap (size_t w, size_t h, size_t bpp, const u8 *pixels, int levels_to_skip, size_t data_padding, MipmapCB cb, void *RESTRICT cbData) |
for a series of mipmaps stored from base to highest, call back for each level. More... | |
static void | create_level (size_t level, size_t level_w, size_t level_h, const u8 *RESTRICT level_data, size_t level_dataSize, void *RESTRICT cbData) |
static Status | add_mipmaps (Tex *t, size_t w, size_t h, size_t bpp, void *newData, size_t dataSize) |
TIMER_ADD_CLIENT (tc_plain_transform) | |
static Status | plain_transform (Tex *t, size_t transforms) |
TIMER_ADD_CLIENT (tc_transform) | |
void | tex_set_global_orientation (int o) |
Set the orientation to which all loaded images will automatically be converted (excepting file formats that don't specify their orientation, i.e. More... | |
static void | flip_to_global_orientation (Tex *t) |
bool | tex_orientations_match (size_t src_flags, size_t dst_orientation) |
indicate if the two vertical orientations match. More... | |
bool | tex_is_known_extension (const VfsPath &pathname) |
Is the file's extension that of a texture format supported by tex_load? More... | |
static void | add_level_size (size_t level, size_t level_w, size_t level_h, const u8 *RESTRICT level_data, size_t level_dataSize, void *RESTRICT cbData) |
size_t | tex_hdr_size (const VfsPath &filename) |
return the minimum header size (i.e. More... | |
Variables | |
static const StatusDefinition | texStatusDefinitions [] |
static int | global_orientation = TEX_TOP_DOWN |
#define CHECK_TEX | ( | t | ) | RETURN_STATUS_IF_ERR((t->validate())) |
|
static |
|
static |
|
static |
|
static |
STATUS_ADD_DEFINITIONS | ( | texStatusDefinitions | ) |
size_t tex_hdr_size | ( | const VfsPath & | filename | ) |
return the minimum header size (i.e.
offset to pixel data) of the file format corresponding to the filename.
rationale: this can be used to optimize calls to tex_write: when allocating the buffer that will hold the image, allocate this much extra and pass the pointer as base+hdr_size. this allows writing the header directly into the output buffer and makes for zero-copy IO.
filename | Filename; only the extension (that after '.') is used. case-insensitive. |
bool tex_is_known_extension | ( | const VfsPath & | pathname | ) |
Is the file's extension that of a texture format supported by tex_load?
Rationale: tex_load complains if the given file is of an unsupported type. this API allows users to preempt that warning (by checking the filename themselves), and also provides for e.g. enumerating only images in a file picker. an alternative might be a flag to suppress warning about invalid files, but this is open to misuse.
pathname | Only the extension (starting with '.') is used. case-insensitive. |
bool tex_orientations_match | ( | size_t | src_flags, |
size_t | dst_orientation | ||
) |
indicate if the two vertical orientations match.
used by tex_codec.
src_flags | TexFlags, used to extract the orientation. we ask for this instead of src_orientation so callers don't have to mask off TEX_ORIENTATION. |
dst_orientation | orientation to compare against. can be one of TEX_BOTTOM_UP, TEX_TOP_DOWN, or 0 for the "global orientation". |
void tex_set_global_orientation | ( | int | orientation | ) |
Set the orientation to which all loaded images will automatically be converted (excepting file formats that don't specify their orientation, i.e.
DDS). See "Default Orientation" in docs.
orientation | Either TEX_BOTTOM_UP or TEX_TOP_DOWN. |
void tex_util_foreach_mipmap | ( | size_t | w, |
size_t | h, | ||
size_t | bpp, | ||
const u8 * | data, | ||
int | levels_to_skip, | ||
size_t | data_padding, | ||
MipmapCB | cb, | ||
void *RESTRICT | cbData | ||
) |
for a series of mipmaps stored from base to highest, call back for each level.
w,h | Pixel dimensions. |
bpp | Bits per pixel. |
data | Series of mipmaps. |
levels_to_skip | Number of levels (counting from base) to skip, or TEX_BASE_LEVEL_ONLY to only call back for the base image. Rationale: this avoids needing to special case for images with or without mipmaps. |
data_padding | Minimum pixel dimensions of mipmap levels. This is used in S3TC images, where each level is actually stored in 4x4 blocks. usually 1 to indicate levels are consecutive. |
cb | MipmapCB to call. |
cbData | Extra data to pass to cb. |
Status tex_validate_plain_format | ( | size_t | bpp, |
size_t | flags | ||
) |
check if the given texture format is acceptable: 8bpp grey, 24bpp color or 32bpp color+alpha (BGR / upside down are permitted).
basically, this is the "plain" format understood by all codecs and tex_codec_plain_transform.
bpp | bits per pixel |
flags | TexFlags |
TIMER_ADD_CLIENT | ( | tc_plain_transform | ) |
TIMER_ADD_CLIENT | ( | tc_transform | ) |
|
static |
|
static |