1
0
mirror of synced 2025-02-16 10:52:34 +01:00

Slight optimization for AA passes.

This commit is contained in:
Jennifer Taylor 2021-06-13 16:46:22 +00:00
parent d9469babee
commit 8e8fa77d36
2 changed files with 13 additions and 2 deletions

View File

@ -453,8 +453,13 @@ def pixel_renderer(
# blend to ensure that partial transparency pixel values don't unnecessarily factor
# into average calculations.
texoff = (aax + (aay * texwidth)) * 4
apercent = texbytes[texoff + 3] / 255.0
# If this is a fully transparent pixel, the below formulas work out to adding nothing
# so we should skip this altogether.
if texbytes[texoff + 3] == 0:
continue
apercent = texbytes[texoff + 3] / 255.0
r += int(texbytes[texoff] * apercent)
g += int(texbytes[texoff + 1] * apercent)
b += int(texbytes[texoff + 2] * apercent)

View File

@ -294,8 +294,14 @@ extern "C"
// blend to ensure that partial transparency pixel values don't unnecessarily factor
// into average calculations.
unsigned int texoff = aax + (aay * work->texwidth);
float apercent = work->texdata[texoff].a / 255.0;
// If this is a fully transparent pixel, the below formulas work out to adding nothing
// so we should skip this altogether.
if (work->texdata[texoff].a == 0) {
continue;
}
float apercent = work->texdata[texoff].a / 255.0;
r += (int)(work->texdata[texoff].r * apercent);
g += (int)(work->texdata[texoff].g * apercent);
b += (int)(work->texdata[texoff].b * apercent);