sw_engine: fixing wrong 'if else' statement handling when gradient shapes rastered

The cases when composition was applied were handled only for AlphaMask and
InvAlphaMask. When opacity value was to be < 255, there was no code
to handle this.
This commit is contained in:
Mira Grudzinska 2021-05-18 02:57:48 +02:00 committed by Hermet Park
parent d999a05750
commit edaafd99b3

View file

@ -645,6 +645,7 @@ static bool _rasterOpaqueLinearGradientRect(SwSurface* surface, const SwBBox& re
buffer += surface->stride; buffer += surface->stride;
cbuffer += surface->stride; cbuffer += surface->stride;
} }
return true;
} else if (method == CompositeMethod::InvAlphaMask) { } else if (method == CompositeMethod::InvAlphaMask) {
for (uint32_t y = 0; y < h; ++y) { for (uint32_t y = 0; y < h; ++y) {
fillFetchLinear(fill, sbuffer, region.min.y + y, region.min.x, w); fillFetchLinear(fill, sbuffer, region.min.y + y, region.min.x, w);
@ -658,11 +659,12 @@ static bool _rasterOpaqueLinearGradientRect(SwSurface* surface, const SwBBox& re
buffer += surface->stride; buffer += surface->stride;
cbuffer += surface->stride; cbuffer += surface->stride;
} }
return true;
} }
} else { }
for (uint32_t y = 0; y < h; ++y) {
fillFetchLinear(fill, buffer + y * surface->stride, region.min.y + y, region.min.x, w); for (uint32_t y = 0; y < h; ++y) {
} fillFetchLinear(fill, buffer + y * surface->stride, region.min.y + y, region.min.x, w);
} }
return true; return true;
} }
@ -717,6 +719,7 @@ static bool _rasterOpaqueRadialGradientRect(SwSurface* surface, const SwBBox& re
buffer += surface->stride; buffer += surface->stride;
cbuffer += surface->stride; cbuffer += surface->stride;
} }
return true;
} else if (method == CompositeMethod::InvAlphaMask) { } else if (method == CompositeMethod::InvAlphaMask) {
for (uint32_t y = 0; y < h; ++y) { for (uint32_t y = 0; y < h; ++y) {
fillFetchRadial(fill, sbuffer, region.min.y + y, region.min.x, w); fillFetchRadial(fill, sbuffer, region.min.y + y, region.min.x, w);
@ -730,14 +733,14 @@ static bool _rasterOpaqueRadialGradientRect(SwSurface* surface, const SwBBox& re
buffer += surface->stride; buffer += surface->stride;
cbuffer += surface->stride; cbuffer += surface->stride;
} }
} return true;
} else {
for (uint32_t y = 0; y < h; ++y) {
auto dst = &buffer[y * surface->stride];
fillFetchRadial(fill, dst, region.min.y + y, region.min.x, w);
} }
} }
for (uint32_t y = 0; y < h; ++y) {
auto dst = &buffer[y * surface->stride];
fillFetchRadial(fill, dst, region.min.y + y, region.min.x, w);
}
return true; return true;
} }
@ -803,6 +806,7 @@ static bool _rasterOpaqueLinearGradientRle(SwSurface* surface, const SwRleData*
} }
} }
} }
return true;
} else if (method == CompositeMethod::InvAlphaMask) { } else if (method == CompositeMethod::InvAlphaMask) {
for (uint32_t i = 0; i < rle->size; ++i, ++span) { for (uint32_t i = 0; i < rle->size; ++i, ++span) {
fillFetchLinear(fill, buf, span->y, span->x, span->len); fillFetchLinear(fill, buf, span->y, span->x, span->len);
@ -823,21 +827,22 @@ static bool _rasterOpaqueLinearGradientRle(SwSurface* surface, const SwRleData*
} }
} }
} }
return true;
} }
} else { }
for (uint32_t i = 0; i < rle->size; ++i) {
if (span->coverage == 255) { for (uint32_t i = 0; i < rle->size; ++i) {
fillFetchLinear(fill, surface->buffer + span->y * surface->stride + span->x, span->y, span->x, span->len); if (span->coverage == 255) {
} else { fillFetchLinear(fill, surface->buffer + span->y * surface->stride + span->x, span->y, span->x, span->len);
fillFetchLinear(fill, buf, span->y, span->x, span->len); } else {
auto ialpha = 255 - span->coverage; fillFetchLinear(fill, buf, span->y, span->x, span->len);
auto dst = &surface->buffer[span->y * surface->stride + span->x]; auto ialpha = 255 - span->coverage;
for (uint32_t i = 0; i < span->len; ++i) { auto dst = &surface->buffer[span->y * surface->stride + span->x];
dst[i] = ALPHA_BLEND(buf[i], span->coverage) + ALPHA_BLEND(dst[i], ialpha); for (uint32_t i = 0; i < span->len; ++i) {
} dst[i] = ALPHA_BLEND(buf[i], span->coverage) + ALPHA_BLEND(dst[i], ialpha);
} }
++span;
} }
++span;
} }
return true; return true;
} }
@ -904,6 +909,7 @@ static bool _rasterOpaqueRadialGradientRle(SwSurface* surface, const SwRleData*
} }
} }
} }
return true;
} else if (method == CompositeMethod::InvAlphaMask) { } else if (method == CompositeMethod::InvAlphaMask) {
for (uint32_t i = 0; i < rle->size; ++i, ++span) { for (uint32_t i = 0; i < rle->size; ++i, ++span) {
fillFetchRadial(fill, buf, span->y, span->x, span->len); fillFetchRadial(fill, buf, span->y, span->x, span->len);
@ -924,21 +930,22 @@ static bool _rasterOpaqueRadialGradientRle(SwSurface* surface, const SwRleData*
} }
} }
} }
return true;
} }
} else { }
for (uint32_t i = 0; i < rle->size; ++i) {
auto dst = &surface->buffer[span->y * surface->stride + span->x]; for (uint32_t i = 0; i < rle->size; ++i) {
if (span->coverage == 255) { auto dst = &surface->buffer[span->y * surface->stride + span->x];
fillFetchRadial(fill, dst, span->y, span->x, span->len); if (span->coverage == 255) {
} else { fillFetchRadial(fill, dst, span->y, span->x, span->len);
fillFetchRadial(fill, buf, span->y, span->x, span->len); } else {
auto ialpha = 255 - span->coverage; fillFetchRadial(fill, buf, span->y, span->x, span->len);
for (uint32_t i = 0; i < span->len; ++i) { auto ialpha = 255 - span->coverage;
dst[i] = ALPHA_BLEND(buf[i], span->coverage) + ALPHA_BLEND(dst[i], ialpha); for (uint32_t i = 0; i < span->len; ++i) {
} dst[i] = ALPHA_BLEND(buf[i], span->coverage) + ALPHA_BLEND(dst[i], ialpha);
} }
++span;
} }
++span;
} }
return true; return true;
} }