mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 06:51:47 +00:00
Minor speedup (*foo++, dammit!), some whitespace.
This commit is contained in:
parent
825b02ad87
commit
b5e93ffd6c
1 changed files with 32 additions and 38 deletions
|
@ -52,7 +52,7 @@ static const char rcsid[] =
|
||||||
static int
|
static int
|
||||||
fgetLittleShort (VFile *f)
|
fgetLittleShort (VFile *f)
|
||||||
{
|
{
|
||||||
byte b1, b2;
|
byte b1, b2;
|
||||||
|
|
||||||
b1 = Qgetc (f);
|
b1 = Qgetc (f);
|
||||||
b2 = Qgetc (f);
|
b2 = Qgetc (f);
|
||||||
|
@ -64,7 +64,7 @@ fgetLittleShort (VFile *f)
|
||||||
static int
|
static int
|
||||||
fgetLittleLong (VFile *f)
|
fgetLittleLong (VFile *f)
|
||||||
{
|
{
|
||||||
byte b1, b2, b3, b4;
|
byte b1, b2, b3, b4;
|
||||||
|
|
||||||
b1 = Qgetc(f);
|
b1 = Qgetc(f);
|
||||||
b2 = Qgetc(f);
|
b2 = Qgetc(f);
|
||||||
|
@ -79,10 +79,9 @@ static inline byte *
|
||||||
blit_rgb (byte *buf, int count, byte red, byte green, byte blue)
|
blit_rgb (byte *buf, int count, byte red, byte green, byte blue)
|
||||||
{
|
{
|
||||||
while (count--) {
|
while (count--) {
|
||||||
buf[0] = red;
|
*buf++ = red;
|
||||||
buf[1] = green;
|
*buf++ = green;
|
||||||
buf[2] = blue;
|
*buf++ = blue;
|
||||||
buf += 3;
|
|
||||||
}
|
}
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
@ -91,11 +90,10 @@ static inline byte *
|
||||||
blit_rgba (byte *buf, int count, byte red, byte green, byte blue, byte alpha)
|
blit_rgba (byte *buf, int count, byte red, byte green, byte blue, byte alpha)
|
||||||
{
|
{
|
||||||
while (count--) {
|
while (count--) {
|
||||||
buf[0] = red;
|
*buf++ = red;
|
||||||
buf[1] = green;
|
*buf++ = green;
|
||||||
buf[2] = blue;
|
*buf++ = blue;
|
||||||
buf[3] = alpha;
|
*buf++ = alpha;
|
||||||
buf += 4;
|
|
||||||
}
|
}
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
@ -103,46 +101,42 @@ blit_rgba (byte *buf, int count, byte red, byte green, byte blue, byte alpha)
|
||||||
static inline byte *
|
static inline byte *
|
||||||
read_bgr (byte *buf, int count, byte **data)
|
read_bgr (byte *buf, int count, byte **data)
|
||||||
{
|
{
|
||||||
byte blue = (*data)[0];
|
byte blue = *(*data)++;
|
||||||
byte green = (*data)[1];
|
byte green = *(*data)++;
|
||||||
byte red = (*data)[2];
|
byte red = *(*data)++;
|
||||||
|
|
||||||
*data += 3;
|
return blit_rgb (buf, count, red, green, blue);
|
||||||
return blit_rgb(buf, count, red, green, blue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline byte *
|
static inline byte *
|
||||||
read_rgb (byte *buf, int count, byte **data)
|
read_rgb (byte *buf, int count, byte **data)
|
||||||
{
|
{
|
||||||
byte red = (*data)[0];
|
byte red = *(*data)++;
|
||||||
byte green = (*data)[1];
|
byte green = *(*data)++;
|
||||||
byte blue = (*data)[2];
|
byte blue = *(*data)++;
|
||||||
|
|
||||||
*data += 3;
|
return blit_rgb (buf, count, red, green, blue);
|
||||||
return blit_rgb(buf, count, red, green, blue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline byte *
|
static inline byte *
|
||||||
read_bgra (byte *buf, int count, byte **data)
|
read_bgra (byte *buf, int count, byte **data)
|
||||||
{
|
{
|
||||||
byte blue = (*data)[0];
|
byte blue = *(*data)++;
|
||||||
byte green = (*data)[1];
|
byte green = *(*data)++;
|
||||||
byte red = (*data)[2];
|
byte red = *(*data)++;
|
||||||
byte alpha = (*data)[3];
|
byte alpha = *(*data)++;
|
||||||
|
|
||||||
*data += 4;
|
|
||||||
return blit_rgba (buf, count, red, green, blue, alpha);
|
return blit_rgba (buf, count, red, green, blue, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline byte *
|
static inline byte *
|
||||||
read_rgba (byte *buf, int count, byte **data)
|
read_rgba (byte *buf, int count, byte **data)
|
||||||
{
|
{
|
||||||
byte red = (*data)[0];
|
byte red = *(*data)++;
|
||||||
byte green = (*data)[1];
|
byte green = *(*data)++;
|
||||||
byte blue = (*data)[2];
|
byte blue = *(*data)++;
|
||||||
byte alpha = (*data)[3];
|
byte alpha = *(*data)++;
|
||||||
|
|
||||||
*data += 4;
|
|
||||||
return blit_rgba (buf, count, red, green, blue, alpha);
|
return blit_rgba (buf, count, red, green, blue, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +193,7 @@ LoadTGA (VFile *fin)
|
||||||
tex->palette = 0;
|
tex->palette = 0;
|
||||||
|
|
||||||
// skip TARGA image comment
|
// skip TARGA image comment
|
||||||
dataByte = (byte *)(targa + 1);
|
dataByte = (byte *) (targa + 1);
|
||||||
dataByte += targa->id_length;
|
dataByte += targa->id_length;
|
||||||
|
|
||||||
span = columns * tex->format;
|
span = columns * tex->format;
|
||||||
|
@ -225,7 +219,7 @@ LoadTGA (VFile *fin)
|
||||||
} else if (targa->image_type == 10) { // RLE compressed image
|
} else if (targa->image_type == 10) { // RLE compressed image
|
||||||
unsigned char packetHeader, packetSize;
|
unsigned char packetHeader, packetSize;
|
||||||
|
|
||||||
byte *(*expand)(byte *buf, int count, byte **data);
|
byte *(*expand) (byte *buf, int count, byte **data);
|
||||||
|
|
||||||
if (targa->pixel_size == 24)
|
if (targa->pixel_size == 24)
|
||||||
expand = read_bgr;
|
expand = read_bgr;
|
||||||
|
@ -241,9 +235,9 @@ LoadTGA (VFile *fin)
|
||||||
int count = columns - column;
|
int count = columns - column;
|
||||||
|
|
||||||
packetSize -= count;
|
packetSize -= count;
|
||||||
if (packetHeader & 0x80) { // run-length packet
|
if (packetHeader & 0x80) { // run-length packet
|
||||||
expand (pixcol, count, &dataByte);
|
expand (pixcol, count, &dataByte);
|
||||||
} else { // non run-length packet
|
} else { // non run-length packet
|
||||||
while (count--)
|
while (count--)
|
||||||
expand (pixcol, 1, &dataByte);
|
expand (pixcol, 1, &dataByte);
|
||||||
}
|
}
|
||||||
|
@ -253,15 +247,15 @@ LoadTGA (VFile *fin)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
column += packetSize;
|
column += packetSize;
|
||||||
if (packetHeader & 0x80) { // run-length packet
|
if (packetHeader & 0x80) { // run-length packet
|
||||||
pixcol = expand (pixcol, packetSize, &dataByte);
|
pixcol = expand (pixcol, packetSize, &dataByte);
|
||||||
} else { // non run-length packet
|
} else { // non run-length packet
|
||||||
while (packetSize--)
|
while (packetSize--)
|
||||||
pixcol = expand (pixcol, 1, &dataByte);
|
pixcol = expand (pixcol, 1, &dataByte);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
done:
|
done:;
|
||||||
}
|
}
|
||||||
|
|
||||||
Hunk_FreeToLowMark (targa_mark);
|
Hunk_FreeToLowMark (targa_mark);
|
||||||
|
|
Loading…
Reference in a new issue