mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-14 12:04:29 +00:00
lottie/parser: optimization++
Skip the data constructuion if the mask mode is none. it's not used at all.
This commit is contained in:
parent
e4cbee61c8
commit
b8b2478572
1 changed files with 16 additions and 5 deletions
|
@ -1161,16 +1161,26 @@ void LottieParser::getLayerSize(float& val)
|
|||
LottieMask* LottieParser::parseMask()
|
||||
{
|
||||
auto mask = new LottieMask;
|
||||
auto valid = true; //skip if the mask mode is none.
|
||||
|
||||
enterObject();
|
||||
while (auto key = nextObjectKey()) {
|
||||
if (KEY_AS("inv")) mask->inverse = getBool();
|
||||
else if (KEY_AS("mode")) mask->method = getMaskMethod(mask->inverse);
|
||||
else if (KEY_AS("pt")) getPathSet(mask->pathset);
|
||||
else if (KEY_AS("o")) parseProperty<LottieProperty::Type::Opacity>(mask->opacity);
|
||||
else if (KEY_AS("mode"))
|
||||
{
|
||||
mask->method = getMaskMethod(mask->inverse);
|
||||
if (mask->method == CompositeMethod::None) valid = false;
|
||||
}
|
||||
else if (valid && KEY_AS("pt")) getPathSet(mask->pathset);
|
||||
else if (valid && KEY_AS("o")) parseProperty<LottieProperty::Type::Opacity>(mask->opacity);
|
||||
else skip(key);
|
||||
}
|
||||
|
||||
if (!valid) {
|
||||
delete(mask);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
|
@ -1179,8 +1189,9 @@ void LottieParser::parseMasks(LottieLayer* layer)
|
|||
{
|
||||
enterArray();
|
||||
while (nextArrayValue()) {
|
||||
auto mask = parseMask();
|
||||
layer->masks.push(mask);
|
||||
if (auto mask = parseMask()) {
|
||||
layer->masks.push(mask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue