mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-10 14:41:50 +00:00
lottie: hotfix for preventing a crash.
MaskMode=None is not properly addressed, Prevent the crash from the use-case. issue: https://github.com/thorvg/thorvg/issues/2426
This commit is contained in:
parent
8939f7cbd4
commit
2c7a83406e
2 changed files with 27 additions and 11 deletions
|
@ -1146,32 +1146,40 @@ static void _updateMaskings(LottieLayer* layer, float frameNo, LottieExpressions
|
||||||
|
|
||||||
//maskings
|
//maskings
|
||||||
Shape* pmask = nullptr;
|
Shape* pmask = nullptr;
|
||||||
auto pmethod = CompositeMethod::AlphaMask;
|
auto pmethod = CompositeMethod::None;
|
||||||
|
|
||||||
for (auto m = layer->masks.begin(); m < layer->masks.end(); ++m) {
|
for (auto m = layer->masks.begin(); m < layer->masks.end(); ++m) {
|
||||||
auto mask = static_cast<LottieMask*>(*m);
|
auto mask = static_cast<LottieMask*>(*m);
|
||||||
|
auto method = mask->method;
|
||||||
|
|
||||||
|
//FIXME: None method mask should be appended to the root layer?
|
||||||
|
if (method == CompositeMethod::None) {
|
||||||
|
pmethod = method;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Masking shape
|
||||||
auto shape = Shape::gen().release();
|
auto shape = Shape::gen().release();
|
||||||
shape->fill(255, 255, 255, mask->opacity(frameNo));
|
shape->fill(255, 255, 255, mask->opacity(frameNo));
|
||||||
shape->transform(layer->cache.matrix);
|
shape->transform(layer->cache.matrix);
|
||||||
if (mask->pathset(frameNo, P(shape)->rs.path.cmds, P(shape)->rs.path.pts, nullptr, 0.0f, exps)) {
|
if (mask->pathset(frameNo, P(shape)->rs.path.cmds, P(shape)->rs.path.pts, nullptr, 0.0f, exps)) {
|
||||||
P(shape)->update(RenderUpdateFlag::Path);
|
P(shape)->update(RenderUpdateFlag::Path);
|
||||||
}
|
}
|
||||||
auto method = mask->method;
|
|
||||||
|
//Append the chain-masking composition
|
||||||
if (pmask) {
|
if (pmask) {
|
||||||
//false of false is true. invert.
|
//false of false is true. invert?
|
||||||
if (method == CompositeMethod::SubtractMask && pmethod == method) {
|
if (pmethod == method) {
|
||||||
method = CompositeMethod::AddMask;
|
if (method == CompositeMethod::SubtractMask) method = CompositeMethod::AddMask;
|
||||||
} else if (pmethod == CompositeMethod::DifferenceMask && pmethod == method) {
|
else if (method == CompositeMethod::DifferenceMask) method = CompositeMethod::IntersectMask;
|
||||||
method = CompositeMethod::IntersectMask;
|
|
||||||
}
|
}
|
||||||
pmask->composite(cast<Shape>(shape), method);
|
pmask->composite(cast<Shape>(shape), method);
|
||||||
|
//Apply the masking
|
||||||
} else {
|
} else {
|
||||||
if (method == CompositeMethod::SubtractMask) method = CompositeMethod::InvAlphaMask;
|
method = (method == CompositeMethod::SubtractMask) ? CompositeMethod::InvAlphaMask : CompositeMethod::AlphaMask;
|
||||||
else if (method == CompositeMethod::AddMask) method = CompositeMethod::AlphaMask;
|
|
||||||
else if (method == CompositeMethod::IntersectMask) method = CompositeMethod::AlphaMask;
|
|
||||||
else if (method == CompositeMethod::DifferenceMask) method = CompositeMethod::AlphaMask; //does this correct?
|
|
||||||
layer->scene->composite(cast<Shape>(shape), method);
|
layer->scene->composite(cast<Shape>(shape), method);
|
||||||
}
|
}
|
||||||
|
|
||||||
pmethod = mask->method;
|
pmethod = mask->method;
|
||||||
pmask = shape;
|
pmask = shape;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,14 @@ CompositeMethod LottieParser::getMaskMethod(bool inversed)
|
||||||
case 's': return CompositeMethod::SubtractMask;
|
case 's': return CompositeMethod::SubtractMask;
|
||||||
case 'i': return CompositeMethod::IntersectMask;
|
case 'i': return CompositeMethod::IntersectMask;
|
||||||
case 'f': return CompositeMethod::DifferenceMask;
|
case 'f': return CompositeMethod::DifferenceMask;
|
||||||
|
case 'l': {
|
||||||
|
TVGLOG("LOTTIE", "Mask Lighten is not supported");
|
||||||
|
return CompositeMethod::None;
|
||||||
|
}
|
||||||
|
case 'd': {
|
||||||
|
TVGLOG("LOTTIE", "Mask Darken is not supported");
|
||||||
|
return CompositeMethod::None;
|
||||||
|
}
|
||||||
default: return CompositeMethod::None;
|
default: return CompositeMethod::None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue