- No matter how many drawers you have, you have more drawers to do.

This commit is contained in:
Rachael Alexanderson 2016-12-17 21:26:08 -05:00
parent 179c7dba83
commit 6235b12cfc
7 changed files with 53 additions and 138 deletions

View file

@ -303,6 +303,8 @@ namespace swrenderer
const uint32_t *_srcblend; const uint32_t *_srcblend;
const uint32_t *_destblend; const uint32_t *_destblend;
const uint8_t *_translation; const uint8_t *_translation;
fixed_t _srcalpha;
fixed_t _destalpha;
int _color; int _color;
}; };

View file

@ -173,6 +173,8 @@ namespace swrenderer
_colormap = dc_colormap; _colormap = dc_colormap;
_srcblend = dc_srcblend; _srcblend = dc_srcblend;
_destblend = dc_destblend; _destblend = dc_destblend;
_srcalpha = dc_srcalpha;
_destalpha = dc_destalpha;
_translation = dc_translation; _translation = dc_translation;
_color = dc_color; _color = dc_color;
} }
@ -440,8 +442,6 @@ namespace swrenderer
if (count <= 0) if (count <= 0)
return; return;
const uint32_t *fg2rgb = _srcblend;
const uint32_t *bg2rgb = _destblend;
dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg;
source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx];
pitch = _pitch * thread->num_cores; pitch = _pitch * thread->num_cores;
@ -451,10 +451,10 @@ namespace swrenderer
uint32_t fg = colormap[*source]; uint32_t fg = colormap[*source];
uint32_t bg = *dest; uint32_t bg = *dest;
fg = fg2rgb[fg]; int r = MIN((GPalette.BaseColors[fg].r * _srcalpha + GPalette.BaseColors[bg].r * _destalpha)>>18, 63);
bg = bg2rgb[bg]; int g = MIN((GPalette.BaseColors[fg].g * _srcalpha + GPalette.BaseColors[bg].g * _destalpha)>>18, 63);
fg = (fg+bg) | 0x1f07c1f; int b = MIN((GPalette.BaseColors[fg].b * _srcalpha + GPalette.BaseColors[bg].b * _destalpha)>>18, 63);
*dest = RGB32k.All[fg & (fg>>15)]; *dest = RGB256k.RGB[r][g][b];
source += 4; source += 4;
dest += pitch; dest += pitch;
} while (--count); } while (--count);
@ -472,42 +472,21 @@ namespace swrenderer
if (count <= 0) if (count <= 0)
return; return;
const uint32_t *fg2rgb = _srcblend;
const uint32_t *bg2rgb = _destblend;
dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg;
source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4]; source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4];
pitch = _pitch * thread->num_cores; pitch = _pitch * thread->num_cores;
colormap = _colormap; colormap = _colormap;
do { do {
uint32_t fg = colormap[source[0]]; for (int ks = 0; ks < 4; ks++)
uint32_t bg = dest[0]; { // [SP] this 4col function was a block of copy-pasted code. 4 times. I regret nothing.
fg = fg2rgb[fg]; uint32_t fg = colormap[source[ks]];
bg = bg2rgb[bg]; uint32_t bg = dest[ks];
fg = (fg+bg) | 0x1f07c1f; int r = MIN((GPalette.BaseColors[fg].r * _srcalpha + GPalette.BaseColors[bg].r * _destalpha)>>18, 63);
dest[0] = RGB32k.All[fg & (fg>>15)]; int g = MIN((GPalette.BaseColors[fg].g * _srcalpha + GPalette.BaseColors[bg].g * _destalpha)>>18, 63);
int b = MIN((GPalette.BaseColors[fg].b * _srcalpha + GPalette.BaseColors[bg].b * _destalpha)>>18, 63);
fg = colormap[source[1]]; dest[ks] = RGB256k.RGB[r][g][b];
bg = dest[1]; }
fg = fg2rgb[fg];
bg = bg2rgb[bg];
fg = (fg+bg) | 0x1f07c1f;
dest[1] = RGB32k.All[fg & (fg>>15)];
fg = colormap[source[2]];
bg = dest[2];
fg = fg2rgb[fg];
bg = bg2rgb[bg];
fg = (fg+bg) | 0x1f07c1f;
dest[2] = RGB32k.All[fg & (fg>>15)];
fg = colormap[source[3]];
bg = dest[3];
fg = fg2rgb[fg];
bg = bg2rgb[bg];
fg = (fg+bg) | 0x1f07c1f;
dest[3] = RGB32k.All[fg & (fg>>15)];
source += 4; source += 4;
dest += pitch; dest += pitch;
@ -534,10 +513,11 @@ namespace swrenderer
pitch = _pitch * thread->num_cores; pitch = _pitch * thread->num_cores;
do { do {
uint32_t val = colormap[*source]; uint32_t val = *source;
uint32_t fg = fgstart[val<<8]; int r = (GPalette.BaseColors[*dest].r * (63-val) + GPalette.BaseColors[_color].r * val) >> 8;
val = (Col2RGB8[64-val][*dest] + fg) | 0x1f07c1f; int g = (GPalette.BaseColors[*dest].g * (63-val) + GPalette.BaseColors[_color].g * val) >> 8;
*dest = RGB32k.All[val & (val>>15)]; int b = (GPalette.BaseColors[*dest].b * (63-val) + GPalette.BaseColors[_color].b * val) >> 8;
*dest = RGB256k.RGB[MIN(r,63)][MIN(g,63)][MIN(b,63)];
source += 4; source += 4;
dest += pitch; dest += pitch;
} while (--count); } while (--count);
@ -565,21 +545,14 @@ namespace swrenderer
do { do {
uint32_t val; uint32_t val;
val = colormap[source[0]]; for (int ks = 0; ks < 4; ks++)
val = (Col2RGB8[64-val][dest[0]] + fgstart[val<<8]) | 0x1f07c1f; {
dest[0] = RGB32k.All[val & (val>>15)]; val = source[ks];
int r = (GPalette.BaseColors[dest[ks]].r * (63-val) + GPalette.BaseColors[_color].r * val) >> 8;
val = colormap[source[1]]; int g = (GPalette.BaseColors[dest[ks]].g * (63-val) + GPalette.BaseColors[_color].g * val) >> 8;
val = (Col2RGB8[64-val][dest[1]] + fgstart[val<<8]) | 0x1f07c1f; int b = (GPalette.BaseColors[dest[ks]].b * (63-val) + GPalette.BaseColors[_color].b * val) >> 8;
dest[1] = RGB32k.All[val & (val>>15)]; dest[ks] = RGB256k.RGB[MIN(r,63)][MIN(g,63)][MIN(b,63)];
}
val = colormap[source[2]];
val = (Col2RGB8[64-val][dest[2]] + fgstart[val<<8]) | 0x1f07c1f;
dest[2] = RGB32k.All[val & (val>>15)];
val = colormap[source[3]];
val = (Col2RGB8[64-val][dest[3]] + fgstart[val<<8]) | 0x1f07c1f;
dest[3] = RGB32k.All[val & (val>>15)];
source += 4; source += 4;
dest += pitch; dest += pitch;
@ -598,23 +571,18 @@ namespace swrenderer
if (count <= 0) if (count <= 0)
return; return;
const uint32_t *fg2rgb = _srcblend;
const uint32_t *bg2rgb = _destblend;
dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg; dest = ylookup[yl + thread->skipped_by_thread(yl)] + sx + _destorg;
source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx]; source = &thread->dc_temp[thread->temp_line_for_thread(yl)*4 + hx];
pitch = _pitch * thread->num_cores; pitch = _pitch * thread->num_cores;
colormap = _colormap; colormap = _colormap;
do { do {
uint32_t a = fg2rgb[colormap[*source]] + bg2rgb[*dest]; int fg = *source;
uint32_t b = a; int bg = *dest;
int r = MIN((GPalette.BaseColors[fg].r * _srcalpha + GPalette.BaseColors[bg].r * _destalpha)>>18, 63);
a |= 0x01f07c1f; int g = MIN((GPalette.BaseColors[fg].g * _srcalpha + GPalette.BaseColors[bg].g * _destalpha)>>18, 63);
b &= 0x40100400; int b = MIN((GPalette.BaseColors[fg].b * _srcalpha + GPalette.BaseColors[bg].b * _destalpha)>>18, 63);
a &= 0x3fffffff; *dest = RGB256k.RGB[r][g][b];
b = b - (b >> 5);
a |= b;
*dest = RGB32k.All[(a>>15) & a];
source += 4; source += 4;
dest += pitch; dest += pitch;
} while (--count); } while (--count);
@ -637,46 +605,16 @@ namespace swrenderer
pitch = _pitch * thread->num_cores; pitch = _pitch * thread->num_cores;
colormap = _colormap; colormap = _colormap;
const uint32_t *fg2rgb = _srcblend;
const uint32_t *bg2rgb = _destblend;
do { do {
uint32_t a = fg2rgb[colormap[source[0]]] + bg2rgb[dest[0]]; for (int ks = 0; ks < 4; ks++)
uint32_t b = a; {
int fg = source[ks];
a |= 0x01f07c1f; int bg = dest[ks];
b &= 0x40100400; int r = MIN((GPalette.BaseColors[fg].r * _srcalpha + GPalette.BaseColors[bg].r * _destalpha)>>18, 63);
a &= 0x3fffffff; int g = MIN((GPalette.BaseColors[fg].g * _srcalpha + GPalette.BaseColors[bg].g * _destalpha)>>18, 63);
b = b - (b >> 5); int b = MIN((GPalette.BaseColors[fg].b * _srcalpha + GPalette.BaseColors[bg].b * _destalpha)>>18, 63);
a |= b; dest[ks] = RGB256k.RGB[r][g][b];
dest[0] = RGB32k.All[(a>>15) & a]; }
a = fg2rgb[colormap[source[1]]] + bg2rgb[dest[1]];
b = a;
a |= 0x01f07c1f;
b &= 0x40100400;
a &= 0x3fffffff;
b = b - (b >> 5);
a |= b;
dest[1] = RGB32k.All[(a>>15) & a];
a = fg2rgb[colormap[source[2]]] + bg2rgb[dest[2]];
b = a;
a |= 0x01f07c1f;
b &= 0x40100400;
a &= 0x3fffffff;
b = b - (b >> 5);
a |= b;
dest[2] = RGB32k.All[(a>>15) & a];
a = fg2rgb[colormap[source[3]]] + bg2rgb[dest[3]];
b = a;
a |= 0x01f07c1f;
b &= 0x40100400;
a &= 0x3fffffff;
b = b - (b >> 5);
a |= b;
dest[3] = RGB32k.All[(a>>15) & a];
source += 4; source += 4;
dest += pitch; dest += pitch;

View file

@ -551,7 +551,7 @@ void FDDSTexture::ReadRGB (FWadLump &lump, BYTE *tcbuf)
DWORD r = (c & RMask) << RShiftL; r |= r >> RShiftR; DWORD r = (c & RMask) << RShiftL; r |= r >> RShiftR;
DWORD g = (c & GMask) << GShiftL; g |= g >> GShiftR; DWORD g = (c & GMask) << GShiftL; g |= g >> GShiftR;
DWORD b = (c & BMask) << BShiftL; b |= b >> BShiftR; DWORD b = (c & BMask) << BShiftL; b |= b >> BShiftR;
*pixelp = RGB32k.RGB[r >> 27][g >> 27][b >> 27]; *pixelp = RGB256k.RGB[r >> 26][g >> 26][b >> 26];
} }
else else
{ {
@ -637,7 +637,7 @@ void FDDSTexture::DecompressDXT1 (FWadLump &lump, BYTE *tcbuf)
// Pick colors from the palette for each of the four colors. // Pick colors from the palette for each of the four colors.
/*if (!tcbuf)*/ for (i = 3; i >= 0; --i) /*if (!tcbuf)*/ for (i = 3; i >= 0; --i)
{ {
palcol[i] = color[i].a ? RGB32k.RGB[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3] : 0; palcol[i] = color[i].a ? RGB256k.RGB[color[i].r >> 2][color[i].g >> 2][color[i].b >> 2] : 0;
} }
// Now decode this 4x4 block to the pixel buffer. // Now decode this 4x4 block to the pixel buffer.
for (y = 0; y < 4; ++y) 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. // Pick colors from the palette for each of the four colors.
if (!tcbuf) for (i = 3; i >= 0; --i) if (!tcbuf) for (i = 3; i >= 0; --i)
{ {
palcol[i] = RGB32k.RGB[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3]; palcol[i] = RGB256k.RGB[color[i].r >> 2][color[i].g >> 2][color[i].b >> 2];
} }
// Now decode this 4x4 block to the pixel buffer. // Now decode this 4x4 block to the pixel buffer.
for (y = 0; y < 4; ++y) 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. // Pick colors from the palette for each of the four colors.
if (!tcbuf) for (i = 3; i >= 0; --i) if (!tcbuf) for (i = 3; i >= 0; --i)
{ {
palcol[i] = RGB32k.RGB[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3]; palcol[i] = RGB256k.RGB[color[i].r >> 2][color[i].g >> 2][color[i].b >> 2];
} }
// Now decode this 4x4 block to the pixel buffer. // Now decode this 4x4 block to the pixel buffer.
for (y = 0; y < 4; ++y) for (y = 0; y < 4; ++y)

View file

@ -406,7 +406,7 @@ void FJPEGTexture::MakeTexture ()
case JCS_RGB: case JCS_RGB:
for (int x = Width; x > 0; --x) for (int x = Width; x > 0; --x)
{ {
*out = RGB32k.RGB[in[0]>>3][in[1]>>3][in[2]>>3]; *out = RGB256k.RGB[in[0]>>2][in[1]>>2][in[2]>>2];
out += Height; out += Height;
in += 3; in += 3;
} }
@ -430,7 +430,7 @@ void FJPEGTexture::MakeTexture ()
int r = in[3] - (((256-in[0])*in[3]) >> 8); int r = in[3] - (((256-in[0])*in[3]) >> 8);
int g = in[3] - (((256-in[1])*in[3]) >> 8); int g = in[3] - (((256-in[1])*in[3]) >> 8);
int b = in[3] - (((256-in[2])*in[3]) >> 8); int b = in[3] - (((256-in[2])*in[3]) >> 8);
*out = RGB32k.RGB[r >> 3][g >> 3][b >> 3]; *out = RGB256k.RGB[r >> 2][g >> 2][b >> 2];
out += Height; out += Height;
in += 4; in += 4;
} }

View file

@ -531,7 +531,7 @@ void FMultiPatchTexture::MakeTexture ()
{ {
if (*out == 0 && in[3] != 0) if (*out == 0 && in[3] != 0)
{ {
*out = RGB32k.RGB[in[2]>>3][in[1]>>3][in[0]>>3]; *out = RGB256k.RGB[in[2]>>2][in[1]>>2][in[0]>>2];
} }
out += Height; out += Height;
in += 4; in += 4;

View file

@ -536,12 +536,7 @@ void FPNGTexture::MakeTexture ()
{ {
if (!HaveTrans) if (!HaveTrans)
{ {
#ifdef NO_RGB666
*out++ = RGB32k.RGB[in[0]>>3][in[1]>>3][in[2]>>3];
#else
*out++ = RGB256k.RGB[in[0]>>2][in[1]>>2][in[2]>>2]; *out++ = RGB256k.RGB[in[0]>>2][in[1]>>2][in[2]>>2];
#endif
} }
else else
{ {
@ -553,11 +548,7 @@ void FPNGTexture::MakeTexture ()
} }
else else
{ {
#ifdef NO_RGB666
*out++ = RGB32k.RGB[in[0]>>3][in[1]>>3][in[2]>>3];
#else
*out++ = RGB256k.RGB[in[0]>>2][in[1]>>2][in[2]>>2]; *out++ = RGB256k.RGB[in[0]>>2][in[1]>>2][in[2]>>2];
#endif
} }
} }
in += pitch; in += pitch;
@ -602,11 +593,7 @@ void FPNGTexture::MakeTexture ()
{ {
for (y = Height; y > 0; --y) for (y = Height; y > 0; --y)
{ {
#ifdef NO_RGB666
*out++ = in[3] < 128 ? 0 : RGB32k.RGB[in[0]>>3][in[1]>>3][in[2]>>3];
#else
*out++ = in[3] < 128 ? 0 : RGB256k.RGB[in[0]>>2][in[1]>>2][in[2]>>2]; *out++ = in[3] < 128 ? 0 : RGB256k.RGB[in[0]>>2][in[1]>>2][in[2]>>2];
#endif
in += pitch; in += pitch;
} }
in -= backstep; in -= backstep;

View file

@ -393,7 +393,7 @@ void FTGATexture::MakeTexture ()
for(int x=0;x<Width;x++) for(int x=0;x<Width;x++)
{ {
int v = LittleLong(*p); int v = LittleLong(*p);
Pixels[x*Height+y] = RGB32k.RGB[(v>>10) & 0x1f][(v>>5) & 0x1f][v & 0x1f]; Pixels[x*Height+y] = RGB256k.RGB[((v>>10) & 0x1f)*2][((v>>5) & 0x1f)*2][(v & 0x1f)*2];
p+=step_x; p+=step_x;
} }
} }
@ -405,11 +405,7 @@ void FTGATexture::MakeTexture ()
BYTE * p = ptr + y * Pitch; BYTE * p = ptr + y * Pitch;
for(int x=0;x<Width;x++) for(int x=0;x<Width;x++)
{ {
#ifdef NO_RGB666
Pixels[x*Height+y] = RGB32k.RGB[p[2]>>3][p[1]>>3][p[0]>>3];
#else
Pixels[x*Height+y] = RGB256k.RGB[p[2]>>2][p[1]>>2][p[0]>>2]; Pixels[x*Height+y] = RGB256k.RGB[p[2]>>2][p[1]>>2][p[0]>>2];
#endif
p+=step_x; p+=step_x;
} }
} }
@ -423,11 +419,7 @@ void FTGATexture::MakeTexture ()
BYTE * p = ptr + y * Pitch; BYTE * p = ptr + y * Pitch;
for(int x=0;x<Width;x++) for(int x=0;x<Width;x++)
{ {
#ifdef NO_RGB666
Pixels[x*Height+y] = RGB32k.RGB[p[2]>>3][p[1]>>3][p[0]>>3];
#else
Pixels[x*Height+y] = RGB256k.RGB[p[2]>>2][p[1]>>2][p[0]>>2]; Pixels[x*Height+y] = RGB256k.RGB[p[2]>>2][p[1]>>2][p[0]>>2];
#endif
p+=step_x; p+=step_x;
} }
} }
@ -439,11 +431,7 @@ void FTGATexture::MakeTexture ()
BYTE * p = ptr + y * Pitch; BYTE * p = ptr + y * Pitch;
for(int x=0;x<Width;x++) for(int x=0;x<Width;x++)
{ {
#ifdef NO_RGB666
Pixels[x*Height+y] = p[3] >= 128? RGB32k.RGB[p[2]>>3][p[1]>>3][p[0]>>3] : 0;
#else
Pixels[x*Height+y] = p[3] >= 128? RGB256k.RGB[p[2]>>2][p[1]>>2][p[0]>>2] : 0; Pixels[x*Height+y] = p[3] >= 128? RGB256k.RGB[p[2]>>2][p[1]>>2][p[0]>>2] : 0;
#endif
p+=step_x; p+=step_x;
} }
} }