mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-23 03:52:12 -04:00
remove V_LinearToPatch
It has a limitation: the maximum patch height is 256. Besides, the performance difference is not that big.
This commit is contained in:
parent
dbd79350a8
commit
f34ad25931
77
src/v_fmt.c
77
src/v_fmt.c
@ -111,7 +111,7 @@ patch_t *V_LinearToTransPatch(const byte *data, int width, int height,
|
||||
|
||||
// If the current pixel is not transparent, add it to the current
|
||||
// post
|
||||
if (data[offset] != color_key)
|
||||
if (color_key == NO_COLOR_KEY || data[offset] != color_key)
|
||||
{
|
||||
// If we're not currently building a post, begin one and set its
|
||||
// offset
|
||||
@ -239,7 +239,7 @@ patch_t *V_LinearToTransPatch(const byte *data, int width, int height,
|
||||
|
||||
array_free(columns);
|
||||
|
||||
if (*output_size)
|
||||
if (output_size)
|
||||
{
|
||||
*output_size = size;
|
||||
}
|
||||
@ -248,64 +248,6 @@ patch_t *V_LinearToTransPatch(const byte *data, int width, int height,
|
||||
return (patch_t *)output;
|
||||
}
|
||||
|
||||
patch_t *V_LinearToPatch(byte *data, int width, int height, int *output_size,
|
||||
int tag, void **user)
|
||||
{
|
||||
size_t size = 0;
|
||||
size += 4 * sizeof(int16_t); // 4 header shorts
|
||||
size += width * sizeof(int32_t); // offsets table
|
||||
size += width * (height + sizeof(column_t) + 3); // 2 pad bytes and cap
|
||||
|
||||
byte *output = Z_Malloc(size, tag, user);
|
||||
|
||||
byte *rover = output;
|
||||
|
||||
// write header fields
|
||||
PUTSHORT(rover, width);
|
||||
PUTSHORT(rover, height);
|
||||
// This is written to afterwards
|
||||
PUTSHORT(rover, 0);
|
||||
PUTSHORT(rover, 0);
|
||||
|
||||
// set starting position of column offsets table, and skip over it
|
||||
byte *col_offsets = rover;
|
||||
rover += width * sizeof(int32_t);
|
||||
|
||||
for (int x = 0; x < width; ++x)
|
||||
{
|
||||
// write column offset to offset table
|
||||
PUTLONG(col_offsets, rover - output);
|
||||
|
||||
// column_t topdelta
|
||||
PUTBYTE(rover, 0);
|
||||
// column_t length
|
||||
PUTBYTE(rover, height);
|
||||
|
||||
// pad byte
|
||||
++rover;
|
||||
|
||||
byte *src = data + x;
|
||||
for (int y = 0; y < height; ++y)
|
||||
{
|
||||
PUTBYTE(rover, *src);
|
||||
src += width;
|
||||
}
|
||||
|
||||
// pad byte
|
||||
++rover;
|
||||
|
||||
// Write 255 cap byte
|
||||
PUTBYTE(rover, 0xff);
|
||||
}
|
||||
|
||||
if (*output_size)
|
||||
{
|
||||
*output_size = size;
|
||||
}
|
||||
|
||||
return (patch_t *)output;
|
||||
}
|
||||
|
||||
static patch_t *DummyPatch(int lump, pu_tag tag)
|
||||
{
|
||||
int num = (W_CheckNumForName)("TNT1A0", ns_sprites);
|
||||
@ -688,18 +630,9 @@ patch_t *V_CachePatchNum(int lump, pu_tag tag)
|
||||
|
||||
Z_Free(buffer);
|
||||
|
||||
patch_t *patch;
|
||||
if (png.color_key == NO_COLOR_KEY)
|
||||
{
|
||||
patch = V_LinearToPatch(png.image, png.width, png.height,
|
||||
&lumpinfo[lump].fmt_size, tag, &lumpcache[lump]);
|
||||
}
|
||||
else
|
||||
{
|
||||
patch = V_LinearToTransPatch(png.image, png.width, png.height,
|
||||
&lumpinfo[lump].fmt_size, png.color_key,
|
||||
tag, &lumpcache[lump]);
|
||||
}
|
||||
patch_t *patch = V_LinearToTransPatch(png.image, png.width, png.height,
|
||||
&lumpinfo[lump].fmt_size,
|
||||
png.color_key, tag, &lumpcache[lump]);
|
||||
patch->leftoffset = leftoffset;
|
||||
patch->topoffset = topoffset;
|
||||
|
||||
|
@ -24,9 +24,6 @@ struct patch_s *V_LinearToTransPatch(const byte *data, int width, int height,
|
||||
int *output_size, int color_key,
|
||||
pu_tag tag, void **user);
|
||||
|
||||
struct patch_s *V_LinearToPatch(byte *data, int width, int height,
|
||||
int *output_size, int tag, void **user);
|
||||
|
||||
struct patch_s *V_CachePatchNum(int lump, pu_tag tag);
|
||||
|
||||
inline static struct patch_s *V_CachePatchName(const char *name, pu_tag tag)
|
||||
|
Loading…
x
Reference in New Issue
Block a user