lottie/parser: optimization++

Skip the data constructuion if the mask mode
is none. it's not used at all.
This commit is contained in:
Hermet Park 2024-07-02 14:57:06 +09:00
parent b94c30675c
commit 98e613e3f0

View file

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