sw_engine raster: adding antialiasing to the gradient rastering functions

The gradient rastering functions with composition did not take
antialiasing into account. The missing part has been added.
This commit is contained in:
Mira Grudzinska 2021-04-07 15:29:22 +02:00 committed by Hermet Park
parent 9d7a264610
commit fcad63ec1f

View file

@ -789,10 +789,19 @@ static bool _rasterOpaqueLinearGradientRle(SwSurface* surface, const SwRleData*
auto dst = &surface->buffer[span->y * surface->stride + span->x];
auto cmp = &cbuffer[span->y * surface->stride + span->x];
auto src = buf;
if (span->coverage == 255) {
for (uint32_t x = 0; x < span->len; ++x, ++dst, ++cmp, ++src) {
auto tmp = ALPHA_BLEND(*src, surface->blender.alpha(*cmp));
*dst = tmp + ALPHA_BLEND(*dst, 255 - surface->blender.alpha(tmp));
}
} else {
auto ialpha = 255 - span->coverage;
for (uint32_t x = 0; x < span->len; ++x, ++dst, ++cmp, ++src) {
auto tmp = ALPHA_BLEND(*src, surface->blender.alpha(*cmp));
tmp = ALPHA_BLEND(tmp, span->coverage) + ALPHA_BLEND(*dst, ialpha);
*dst = tmp + ALPHA_BLEND(*dst, 255 - surface->blender.alpha(tmp));
}
}
}
} else if (method == CompositeMethod::InvAlphaMask) {
for (uint32_t i = 0; i < rle->size; ++i, ++span) {
@ -800,10 +809,19 @@ static bool _rasterOpaqueLinearGradientRle(SwSurface* surface, const SwRleData*
auto dst = &surface->buffer[span->y * surface->stride + span->x];
auto cmp = &cbuffer[span->y * surface->stride + span->x];
auto src = buf;
if (span->coverage == 255) {
for (uint32_t x = 0; x < span->len; ++x, ++dst, ++cmp, ++src) {
auto tmp = ALPHA_BLEND(*src, 255 - surface->blender.alpha(*cmp));
*dst = tmp + ALPHA_BLEND(*dst, 255 - surface->blender.alpha(tmp));
}
} else {
auto ialpha = 255 - span->coverage;
for (uint32_t x = 0; x < span->len; ++x, ++dst, ++cmp, ++src) {
auto tmp = ALPHA_BLEND(*src, 255 - surface->blender.alpha(*cmp));
tmp = ALPHA_BLEND(tmp, span->coverage) + ALPHA_BLEND(*dst, ialpha);
*dst = tmp + ALPHA_BLEND(*dst, 255 - surface->blender.alpha(tmp));
}
}
}
}
} else {
@ -872,10 +890,19 @@ static bool _rasterOpaqueRadialGradientRle(SwSurface* surface, const SwRleData*
auto dst = &surface->buffer[span->y * surface->stride + span->x];
auto cmp = &cbuffer[span->y * surface->stride + span->x];
auto src = buf;
if (span->coverage == 255) {
for (uint32_t x = 0; x < span->len; ++x, ++dst, ++cmp, ++src) {
auto tmp = ALPHA_BLEND(*src, surface->blender.alpha(*cmp));
*dst = tmp + ALPHA_BLEND(*dst, 255 - surface->blender.alpha(tmp));
}
} else {
auto ialpha = 255 - span->coverage;
for (uint32_t x = 0; x < span->len; ++x, ++dst, ++cmp, ++src) {
auto tmp = ALPHA_BLEND(*src, surface->blender.alpha(*cmp));
tmp = ALPHA_BLEND(tmp, span->coverage) + ALPHA_BLEND(*dst, ialpha);
*dst = tmp + ALPHA_BLEND(*dst, 255 - surface->blender.alpha(tmp));
}
}
}
} else if (method == CompositeMethod::InvAlphaMask) {
for (uint32_t i = 0; i < rle->size; ++i, ++span) {
@ -883,10 +910,19 @@ static bool _rasterOpaqueRadialGradientRle(SwSurface* surface, const SwRleData*
auto dst = &surface->buffer[span->y * surface->stride + span->x];
auto cmp = &cbuffer[span->y * surface->stride + span->x];
auto src = buf;
if (span->coverage == 255) {
for (uint32_t x = 0; x < span->len; ++x, ++dst, ++cmp, ++src) {
auto tmp = ALPHA_BLEND(*src, 255 - surface->blender.alpha(*cmp));
*dst = tmp + ALPHA_BLEND(*dst, 255 - surface->blender.alpha(tmp));
}
} else {
auto ialpha = 255 - span->coverage;
for (uint32_t x = 0; x < span->len; ++x, ++dst, ++cmp, ++src) {
auto tmp = ALPHA_BLEND(*src, 255 - surface->blender.alpha(*cmp));
tmp = ALPHA_BLEND(tmp, span->coverage) + ALPHA_BLEND(*dst, ialpha);
*dst = tmp + ALPHA_BLEND(*dst, 255 - surface->blender.alpha(tmp));
}
}
}
}
} else {