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()
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue