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:
Mira Grudzinska 2025-02-21 15:19:47 +01:00 committed by Hermet Park
parent 8f9527ccf1
commit 5b30e2ad65

View file

@ -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);