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 e4cbee61c8
commit b8b2478572

View file

@ -1161,16 +1161,26 @@ void LottieParser::getLayerSize(float& val)
LottieMask* LottieParser::parseMask() LottieMask* LottieParser::parseMask()
{ {
auto mask = new LottieMask; auto mask = new LottieMask;
auto valid = true; //skip if the mask mode is none.
enterObject(); enterObject();
while (auto key = nextObjectKey()) { while (auto key = nextObjectKey()) {
if (KEY_AS("inv")) mask->inverse = getBool(); if (KEY_AS("inv")) mask->inverse = getBool();
else if (KEY_AS("mode")) mask->method = getMaskMethod(mask->inverse); else if (KEY_AS("mode"))
else if (KEY_AS("pt")) getPathSet(mask->pathset); {
else if (KEY_AS("o")) parseProperty<LottieProperty::Type::Opacity>(mask->opacity); 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); else skip(key);
} }
if (!valid) {
delete(mask);
return nullptr;
}
return mask; return mask;
} }
@ -1179,8 +1189,9 @@ void LottieParser::parseMasks(LottieLayer* layer)
{ {
enterArray(); enterArray();
while (nextArrayValue()) { while (nextArrayValue()) {
auto mask = parseMask(); if (auto mask = parseMask()) {
layer->masks.push(mask); layer->masks.push(mask);
}
} }
} }