mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
lottie: minor optimization
trim out a group when it has only one child.
This commit is contained in:
parent
bd520c1c69
commit
51bc7e81f8
2 changed files with 11 additions and 7 deletions
|
@ -1042,13 +1042,14 @@ void LottieBuilder::updateText(LottieLayer* layer, float frameNo)
|
||||||
auto& textGroupMatrix = textGroup->transform();
|
auto& textGroupMatrix = textGroup->transform();
|
||||||
auto shape = text->pooling();
|
auto shape = text->pooling();
|
||||||
shape->reset();
|
shape->reset();
|
||||||
|
|
||||||
ARRAY_FOREACH(p, glyph->children) {
|
ARRAY_FOREACH(p, glyph->children) {
|
||||||
auto group = static_cast<LottieGroup*>(*p);
|
//Either group of a single path
|
||||||
ARRAY_FOREACH(p, group->children) {
|
if ((*p)->type == LottieObject::Group) {
|
||||||
if (static_cast<LottiePath*>(*p)->pathset(frameNo, SHAPE(shape)->rs.path, nullptr, tween, exps)) {
|
ARRAY_FOREACH(p2, static_cast<LottieGroup*>(*p)->children) {
|
||||||
PAINT(shape)->update(RenderUpdateFlag::Path);
|
static_cast<LottiePath*>(*p2)->pathset(frameNo, SHAPE(shape)->rs.path, nullptr, tween, exps);
|
||||||
}
|
}
|
||||||
}
|
} else static_cast<LottiePath*>(*p)->pathset(frameNo, SHAPE(shape)->rs.path, nullptr, tween, exps);
|
||||||
}
|
}
|
||||||
shape->fill(doc.color.rgb[0], doc.color.rgb[1], doc.color.rgb[2]);
|
shape->fill(doc.color.rgb[0], doc.color.rgb[1], doc.color.rgb[2]);
|
||||||
shape->translate(cursor.x - textGroupMatrix.e13, cursor.y - textGroupMatrix.e23);
|
shape->translate(cursor.x - textGroupMatrix.e13, cursor.y - textGroupMatrix.e23);
|
||||||
|
|
|
@ -1079,9 +1079,12 @@ LottieObject* LottieParser::parseGroup()
|
||||||
while (nextArrayValue()) parseObject(group->children);
|
while (nextArrayValue()) parseObject(group->children);
|
||||||
} else skip();
|
} else skip();
|
||||||
}
|
}
|
||||||
if (group->children.empty()) {
|
|
||||||
|
if (group->children.count == 1) {
|
||||||
|
auto child = group->children.first();
|
||||||
|
group->children.clear();
|
||||||
delete(group);
|
delete(group);
|
||||||
return nullptr;
|
return child;
|
||||||
}
|
}
|
||||||
group->prepare();
|
group->prepare();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue