mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
lottie: prevent trimming in masks
Until now the fill's trimming was not supported, which allowed masks to function correctly. Introducing trimming for the entire shape caused the mask to be trimmed as well, leading to incorrect results. Co-Authored-By: Hermet Park <hermet@lottiefiles.com>
This commit is contained in:
parent
8f9527ccf1
commit
5b30e2ad65
1 changed files with 6 additions and 7 deletions
|
@ -1177,14 +1177,10 @@ void LottieBuilder::updateMasks(LottieLayer* layer, float frameNo)
|
|||
//the first mask
|
||||
if (!pShape) {
|
||||
pShape = layer->pooling();
|
||||
pShape->reset();
|
||||
pShape->fill(255, 255, 255, opacity);
|
||||
pShape->transform(layer->cache.matrix);
|
||||
auto compMethod = (method == MaskMethod::Subtract || method == MaskMethod::InvAlpha) ? MaskMethod::InvAlpha : MaskMethod::Alpha;
|
||||
//Cheaper. Replace the masking with a clipper
|
||||
if (layer->masks.count == 1 && compMethod == MaskMethod::Alpha) {
|
||||
layer->scene->opacity(MULTIPLY(layer->scene->opacity(), opacity));
|
||||
pShape->strokeWidth(0.0f); //enforce fill clipper over stroke clipper
|
||||
layer->scene->clip(pShape);
|
||||
fastTrack = true;
|
||||
} else {
|
||||
|
@ -1193,13 +1189,16 @@ void LottieBuilder::updateMasks(LottieLayer* layer, float frameNo)
|
|||
//Chain mask composition
|
||||
} else if (pMethod != method || pOpacity != opacity || (method != MaskMethod::Subtract && method != MaskMethod::Difference)) {
|
||||
auto shape = layer->pooling();
|
||||
shape->reset();
|
||||
shape->fill(255, 255, 255, opacity);
|
||||
shape->transform(layer->cache.matrix);
|
||||
pShape->mask(shape, method);
|
||||
pShape = shape;
|
||||
}
|
||||
|
||||
pShape->reset();
|
||||
pShape->trimpath(0.0f, 1.0f);
|
||||
pShape->strokeWidth(0.0f);
|
||||
pShape->fill(255, 255, 255, opacity);
|
||||
pShape->transform(layer->cache.matrix);
|
||||
|
||||
//Default Masking
|
||||
if (expand == 0.0f) {
|
||||
mask->pathset(frameNo, SHAPE(pShape)->rs.path, nullptr, tween, exps);
|
||||
|
|
Loading…
Add table
Reference in a new issue