emu/rendlay.cpp: Keep alpha channel intact when drawing text components. (#11820)

Improves appearance of text drawn over colors other than black.
This commit is contained in:
Devin Acker 2023-12-06 12:29:57 -05:00 committed by GitHub
parent d2e8df2916
commit c7f9676add
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3727,12 +3727,6 @@ void layout_element::component::draw_text(
int align,
const render_color &color)
{
// compute premultiplied color
u32 const r(color.r * 255.0f);
u32 const g(color.g * 255.0f);
u32 const b(color.b * 255.0f);
u32 const a(color.a * 255.0f);
// get the width of the string
float aspect = 1.0f;
s32 width;
@ -3797,12 +3791,7 @@ void layout_element::component::draw_text(
u32 spix = rgb_t(src[x]).a();
if (spix != 0)
{
rgb_t dpix = d[effx];
u32 ta = (a * (spix + 1)) >> 8;
u32 tr = (r * ta + dpix.r() * (0x100 - ta)) >> 8;
u32 tg = (g * ta + dpix.g() * (0x100 - ta)) >> 8;
u32 tb = (b * ta + dpix.b() * (0x100 - ta)) >> 8;
d[effx] = rgb_t(tr, tg, tb);
alpha_blend(d[effx], color, spix / 255.0);
}
}
}