Change RGB32k to a union of BYTE[32][32][32] and BYTE[32*32*32]
- Clang's optional runtime array bounds checking doesn't understand when we
intentionally "overflow" by doing this:
RGB32k[0][0][colorval]
It will warn that it was accessed at an index will past the bounds
of type 'BYTE [32]', which makes it less than useful for catching real
array bounds overflows. So now do this:
RGB32k.All[colorval]
And if you want this:
RGB32k[r][g][b]
Now do this:
RGB32k.RGB[r][g][b]
This commit is contained in:
parent
308a036955
commit
e259087c19
13 changed files with 88 additions and 77 deletions
|
|
@ -551,7 +551,7 @@ void FDDSTexture::ReadRGB (FWadLump &lump, BYTE *tcbuf)
|
|||
DWORD r = (c & RMask) << RShiftL; r |= r >> RShiftR;
|
||||
DWORD g = (c & GMask) << GShiftL; g |= g >> GShiftR;
|
||||
DWORD b = (c & BMask) << BShiftL; b |= b >> BShiftR;
|
||||
*pixelp = RGB32k[r >> 27][g >> 27][b >> 27];
|
||||
*pixelp = RGB32k.RGB[r >> 27][g >> 27][b >> 27];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -637,7 +637,7 @@ void FDDSTexture::DecompressDXT1 (FWadLump &lump, BYTE *tcbuf)
|
|||
// Pick colors from the palette for each of the four colors.
|
||||
/*if (!tcbuf)*/ for (i = 3; i >= 0; --i)
|
||||
{
|
||||
palcol[i] = color[i].a ? RGB32k[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3] : 0;
|
||||
palcol[i] = color[i].a ? RGB32k.RGB[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3] : 0;
|
||||
}
|
||||
// Now decode this 4x4 block to the pixel buffer.
|
||||
for (y = 0; y < 4; ++y)
|
||||
|
|
@ -717,7 +717,7 @@ void FDDSTexture::DecompressDXT3 (FWadLump &lump, bool premultiplied, BYTE *tcbu
|
|||
// Pick colors from the palette for each of the four colors.
|
||||
if (!tcbuf) for (i = 3; i >= 0; --i)
|
||||
{
|
||||
palcol[i] = RGB32k[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3];
|
||||
palcol[i] = RGB32k.RGB[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3];
|
||||
}
|
||||
// Now decode this 4x4 block to the pixel buffer.
|
||||
for (y = 0; y < 4; ++y)
|
||||
|
|
@ -822,7 +822,7 @@ void FDDSTexture::DecompressDXT5 (FWadLump &lump, bool premultiplied, BYTE *tcbu
|
|||
// Pick colors from the palette for each of the four colors.
|
||||
if (!tcbuf) for (i = 3; i >= 0; --i)
|
||||
{
|
||||
palcol[i] = RGB32k[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3];
|
||||
palcol[i] = RGB32k.RGB[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3];
|
||||
}
|
||||
// Now decode this 4x4 block to the pixel buffer.
|
||||
for (y = 0; y < 4; ++y)
|
||||
|
|
|
|||
|
|
@ -406,7 +406,7 @@ void FJPEGTexture::MakeTexture ()
|
|||
case JCS_RGB:
|
||||
for (int x = Width; x > 0; --x)
|
||||
{
|
||||
*out = RGB32k[in[0]>>3][in[1]>>3][in[2]>>3];
|
||||
*out = RGB32k.RGB[in[0]>>3][in[1]>>3][in[2]>>3];
|
||||
out += Height;
|
||||
in += 3;
|
||||
}
|
||||
|
|
@ -430,7 +430,7 @@ void FJPEGTexture::MakeTexture ()
|
|||
int r = in[3] - (((256-in[0])*in[3]) >> 8);
|
||||
int g = in[3] - (((256-in[1])*in[3]) >> 8);
|
||||
int b = in[3] - (((256-in[2])*in[3]) >> 8);
|
||||
*out = RGB32k[r >> 3][g >> 3][b >> 3];
|
||||
*out = RGB32k.RGB[r >> 3][g >> 3][b >> 3];
|
||||
out += Height;
|
||||
in += 4;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -534,7 +534,7 @@ void FMultiPatchTexture::MakeTexture ()
|
|||
{
|
||||
if (*out == 0 && in[3] != 0)
|
||||
{
|
||||
*out = RGB32k[in[2]>>3][in[1]>>3][in[0]>>3];
|
||||
*out = RGB32k.RGB[in[2]>>3][in[1]>>3][in[0]>>3];
|
||||
}
|
||||
out += Height;
|
||||
in += 4;
|
||||
|
|
|
|||
|
|
@ -528,7 +528,7 @@ void FPCXTexture::MakeTexture()
|
|||
{
|
||||
for(int x=0; x < Width; x++)
|
||||
{
|
||||
Pixels[y+Height*x] = RGB32k[row[0]>>3][row[1]>>3][row[2]>>3];
|
||||
Pixels[y+Height*x] = RGB32k.RGB[row[0]>>3][row[1]>>3][row[2]>>3];
|
||||
row+=3;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -521,7 +521,7 @@ void FPNGTexture::MakeTexture ()
|
|||
{
|
||||
for (y = Height; y > 0; --y)
|
||||
{
|
||||
*out++ = RGB32k[in[0]>>3][in[1]>>3][in[2]>>3];
|
||||
*out++ = RGB32k.RGB[in[0]>>3][in[1]>>3][in[2]>>3];
|
||||
in += pitch;
|
||||
}
|
||||
in -= backstep;
|
||||
|
|
@ -564,7 +564,7 @@ void FPNGTexture::MakeTexture ()
|
|||
{
|
||||
for (y = Height; y > 0; --y)
|
||||
{
|
||||
*out++ = in[3] < 128 ? 0 : RGB32k[in[0]>>3][in[1]>>3][in[2]>>3];
|
||||
*out++ = in[3] < 128 ? 0 : RGB32k.RGB[in[0]>>3][in[1]>>3][in[2]>>3];
|
||||
in += pitch;
|
||||
}
|
||||
in -= backstep;
|
||||
|
|
|
|||
|
|
@ -393,7 +393,7 @@ void FTGATexture::MakeTexture ()
|
|||
for(int x=0;x<Width;x++)
|
||||
{
|
||||
int v = LittleLong(*p);
|
||||
Pixels[x*Height+y] = RGB32k[(v>>10) & 0x1f][(v>>5) & 0x1f][v & 0x1f];
|
||||
Pixels[x*Height+y] = RGB32k.RGB[(v>>10) & 0x1f][(v>>5) & 0x1f][v & 0x1f];
|
||||
p+=step_x;
|
||||
}
|
||||
}
|
||||
|
|
@ -405,7 +405,7 @@ void FTGATexture::MakeTexture ()
|
|||
BYTE * p = ptr + y * Pitch;
|
||||
for(int x=0;x<Width;x++)
|
||||
{
|
||||
Pixels[x*Height+y] = RGB32k[p[2]>>3][p[1]>>3][p[0]>>3];
|
||||
Pixels[x*Height+y] = RGB32k.RGB[p[2]>>3][p[1]>>3][p[0]>>3];
|
||||
p+=step_x;
|
||||
}
|
||||
}
|
||||
|
|
@ -419,7 +419,7 @@ void FTGATexture::MakeTexture ()
|
|||
BYTE * p = ptr + y * Pitch;
|
||||
for(int x=0;x<Width;x++)
|
||||
{
|
||||
Pixels[x*Height+y] = RGB32k[p[2]>>3][p[1]>>3][p[0]>>3];
|
||||
Pixels[x*Height+y] = RGB32k.RGB[p[2]>>3][p[1]>>3][p[0]>>3];
|
||||
p+=step_x;
|
||||
}
|
||||
}
|
||||
|
|
@ -431,7 +431,7 @@ void FTGATexture::MakeTexture ()
|
|||
BYTE * p = ptr + y * Pitch;
|
||||
for(int x=0;x<Width;x++)
|
||||
{
|
||||
Pixels[x*Height+y] = p[3] >= 128? RGB32k[p[2]>>3][p[1]>>3][p[0]>>3] : 0;
|
||||
Pixels[x*Height+y] = p[3] >= 128? RGB32k.RGB[p[2]>>3][p[1]>>3][p[0]>>3] : 0;
|
||||
p+=step_x;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue