mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
common: fix composition while masking
Using a mask (any type) with alpha set to less than 255 through the fill(r, g, b, a) API resulted in incorrect compositions of fill and stroke. Incorrect results were also observed for luma masks, as their alpha is calculated based on the other color channels. @issue: https://github.com/thorvg/thorvg/issues/1653
This commit is contained in:
parent
25d43ddacf
commit
9183f1c11e
1 changed files with 15 additions and 2 deletions
|
@ -76,8 +76,21 @@ struct Shape::Impl
|
|||
//Composition test
|
||||
const Paint* target;
|
||||
auto method = shape->composite(&target);
|
||||
if (!target || method == tvg::CompositeMethod::ClipPath) return false;
|
||||
if (target->pImpl->opacity == 255 || target->pImpl->opacity == 0) return false;
|
||||
if (!target || method == CompositeMethod::ClipPath) return false;
|
||||
if (target->pImpl->opacity == 255 || target->pImpl->opacity == 0) {
|
||||
if (target->identifier() == TVG_CLASS_ID_SHAPE) {
|
||||
auto shape = static_cast<const Shape*>(target);
|
||||
if (!shape->fill()) {
|
||||
uint8_t r, g, b, a;
|
||||
shape->fillColor(&r, &g, &b, &a);
|
||||
if (a == 0 || a == 255) {
|
||||
if (method == CompositeMethod::LumaMask || method == CompositeMethod::InvLumaMask) {
|
||||
if ((r == 255 && g == 255 && b == 255) || (r == 0 && g == 0 && b == 0)) return false;
|
||||
} else return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue