From 5185ebbc28f9124ad872e1b42aedd8c63799ef5b Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sun, 4 Jun 2017 12:46:39 -0400 Subject: [PATCH] - fixed: Add light diminishing to true-color stencil drawers - fixed: Non-SSE AddClampShadedBgra (stencil) drawer did not handle overflows --- src/swrenderer/drawers/r_draw_sprite32.h | 10 +++++----- src/swrenderer/drawers/r_draw_sprite32_sse2.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/swrenderer/drawers/r_draw_sprite32.h b/src/swrenderer/drawers/r_draw_sprite32.h index 1441de5a32..63f6426928 100644 --- a/src/swrenderer/drawers/r_draw_sprite32.h +++ b/src/swrenderer/drawers/r_draw_sprite32.h @@ -194,7 +194,7 @@ namespace swrenderer uint32_t srcalpha = args.SrcAlpha() >> (FRACBITS - 8); uint32_t destalpha = args.DestAlpha() >> (FRACBITS - 8); uint32_t srccolor = args.SrcColorBgra(); - uint32_t color = LightBgra::shade_bgra_simple(args.SolidColorBgra() && 0xffffff, + uint32_t color = LightBgra::shade_bgra_simple(args.SolidColorBgra(), LightBgra::calc_light_multiplier(light)); for (int index = 0; index < count; index++) @@ -291,7 +291,7 @@ namespace swrenderer { using namespace DrawSprite32TModes; - if (BlendT::Mode == (int)SpriteBlendModes::Copy || BlendT::Mode == (int)SpriteBlendModes::Shaded) + if (BlendT::Mode == (int)SpriteBlendModes::Copy) return fgcolor; if (ShadeModeT::Mode == (int)ShadeMode::Simple) @@ -341,9 +341,9 @@ namespace swrenderer { uint32_t alpha = ifgshade; BgraColor outcolor; - outcolor.r = ((fgcolor.r * alpha) >> 8) + bgcolor.r; - outcolor.g = ((fgcolor.g * alpha) >> 8) + bgcolor.g; - outcolor.b = ((fgcolor.b * alpha) >> 8) + bgcolor.b; + outcolor.r = MIN(((fgcolor.r * alpha) >> 8) + bgcolor.r, 255); + outcolor.g = MIN(((fgcolor.g * alpha) >> 8) + bgcolor.g, 255); + outcolor.b = MIN(((fgcolor.b * alpha) >> 8) + bgcolor.b, 255); outcolor.a = 255; return outcolor; } diff --git a/src/swrenderer/drawers/r_draw_sprite32_sse2.h b/src/swrenderer/drawers/r_draw_sprite32_sse2.h index 1511cc76f9..1b5e682b12 100644 --- a/src/swrenderer/drawers/r_draw_sprite32_sse2.h +++ b/src/swrenderer/drawers/r_draw_sprite32_sse2.h @@ -326,7 +326,7 @@ namespace swrenderer { using namespace DrawSprite32TModes; - if (BlendT::Mode == (int)SpriteBlendModes::Copy || BlendT::Mode == (int)SpriteBlendModes::Shaded) + if (BlendT::Mode == (int)SpriteBlendModes::Copy) return fgcolor; if (ShadeModeT::Mode == (int)ShadeMode::Simple)