Move software canvas drawing to its own file in the software renderer
This commit is contained in:
parent
10b36934c2
commit
9159e3b1f0
6 changed files with 913 additions and 800 deletions
130
src/v_video.cpp
130
src/v_video.cpp
|
|
@ -337,136 +337,6 @@ void DCanvas::Dim (PalEntry color)
|
|||
Dim (dimmer, amount, 0, 0, Width, Height);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// DCanvas :: Dim
|
||||
//
|
||||
// Applies a colored overlay to an area of the screen.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h)
|
||||
{
|
||||
if (damount == 0.f)
|
||||
return;
|
||||
|
||||
int gap;
|
||||
int x, y;
|
||||
|
||||
if (x1 >= Width || y1 >= Height)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (x1 + w > Width)
|
||||
{
|
||||
w = Width - x1;
|
||||
}
|
||||
if (y1 + h > Height)
|
||||
{
|
||||
h = Height - y1;
|
||||
}
|
||||
if (w <= 0 || h <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
gap = Pitch - w;
|
||||
|
||||
if (IsBgra())
|
||||
{
|
||||
uint32_t *spot = (uint32_t*)Buffer + x1 + y1*Pitch;
|
||||
|
||||
uint32_t fg = color.d;
|
||||
uint32_t fg_red = (fg >> 16) & 0xff;
|
||||
uint32_t fg_green = (fg >> 8) & 0xff;
|
||||
uint32_t fg_blue = fg & 0xff;
|
||||
|
||||
uint32_t alpha = (uint32_t)clamp(damount * 256 + 0.5f, 0.0f, 256.0f);
|
||||
uint32_t inv_alpha = 256 - alpha;
|
||||
|
||||
fg_red *= alpha;
|
||||
fg_green *= alpha;
|
||||
fg_blue *= alpha;
|
||||
|
||||
for (y = h; y != 0; y--)
|
||||
{
|
||||
for (x = w; x != 0; x--)
|
||||
{
|
||||
uint32_t bg_red = (*spot >> 16) & 0xff;
|
||||
uint32_t bg_green = (*spot >> 8) & 0xff;
|
||||
uint32_t bg_blue = (*spot) & 0xff;
|
||||
|
||||
uint32_t red = (fg_red + bg_red * inv_alpha) / 256;
|
||||
uint32_t green = (fg_green + bg_green * inv_alpha) / 256;
|
||||
uint32_t blue = (fg_blue + bg_blue * inv_alpha) / 256;
|
||||
|
||||
*spot = 0xff000000 | (red << 16) | (green << 8) | blue;
|
||||
spot++;
|
||||
}
|
||||
spot += gap;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BYTE *spot = Buffer + x1 + y1*Pitch;
|
||||
|
||||
DWORD *bg2rgb;
|
||||
DWORD fg;
|
||||
|
||||
spot = Buffer + x1 + y1*Pitch;
|
||||
gap = Pitch - w;
|
||||
|
||||
int alpha = (int)((float)64 * damount);
|
||||
int ialpha = 64 - alpha;
|
||||
int dimmedcolor_r = color.r * alpha;
|
||||
int dimmedcolor_g = color.g * alpha;
|
||||
int dimmedcolor_b = color.b * alpha;
|
||||
|
||||
if (!r_blendmethod)
|
||||
{
|
||||
{
|
||||
int amount;
|
||||
|
||||
amount = (int)(damount * 64);
|
||||
bg2rgb = Col2RGB8[64 - amount];
|
||||
|
||||
fg = (((color.r * amount) >> 4) << 20) |
|
||||
((color.g * amount) >> 4) |
|
||||
(((color.b * amount) >> 4) << 10);
|
||||
}
|
||||
|
||||
for (y = h; y != 0; y--)
|
||||
{
|
||||
for (x = w; x != 0; x--)
|
||||
{
|
||||
DWORD bg;
|
||||
|
||||
bg = bg2rgb[(*spot)&0xff];
|
||||
bg = (fg+bg) | 0x1f07c1f;
|
||||
*spot = RGB32k.All[bg&(bg>>15)];
|
||||
spot++;
|
||||
}
|
||||
spot += gap;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (y = h; y != 0; y--)
|
||||
{
|
||||
for (x = w; x != 0; x--)
|
||||
{
|
||||
uint32_t r = (dimmedcolor_r + GPalette.BaseColors[*spot].r * ialpha) >> 8;
|
||||
uint32_t g = (dimmedcolor_g + GPalette.BaseColors[*spot].g * ialpha) >> 8;
|
||||
uint32_t b = (dimmedcolor_b + GPalette.BaseColors[*spot].b * ialpha) >> 8;
|
||||
*spot = (BYTE)RGB256k.RGB[r][g][b];
|
||||
spot++;
|
||||
}
|
||||
spot += gap;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// DCanvas :: GetScreenshotBuffer
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue