mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-13 19:44:28 +00:00
lottie: ++ scene composing optimization
retain reusable precomp clipper shapes during animation.
This commit is contained in:
parent
f7728a8b7a
commit
3adee7238c
3 changed files with 17 additions and 10 deletions
|
@ -1000,18 +1000,21 @@ static void _updatePrecomp(LottieLayer* precomp, float frameNo, LottieExpression
|
|||
if (!child->matteSrc) _updateLayer(precomp, child, frameNo, exps);
|
||||
}
|
||||
|
||||
//clip the layer viewport
|
||||
if (precomp->w > 0 && precomp->h > 0) {
|
||||
auto clipper = Shape::gen().release();
|
||||
clipper->appendRect(0, 0, static_cast<float>(precomp->w), static_cast<float>(precomp->h));
|
||||
clipper->transform(precomp->cache.matrix);
|
||||
|
||||
//TODO: remove the intermediate scene....
|
||||
auto cscene = Scene::gen();
|
||||
cscene->composite(cast(clipper), CompositeMethod::ClipPath);
|
||||
//TODO: remove the intermediate scene....
|
||||
if (precomp->scene->composite(nullptr) != tvg::CompositeMethod::None) {
|
||||
auto cscene = Scene::gen().release();
|
||||
cscene->push(cast(precomp->scene));
|
||||
precomp->scene = cscene.release();
|
||||
precomp->scene = cscene;
|
||||
}
|
||||
|
||||
//clip the layer viewport
|
||||
if (!precomp->clipper) {
|
||||
precomp->clipper = Shape::gen().release();
|
||||
precomp->clipper->appendRect(0, 0, static_cast<float>(precomp->w), static_cast<float>(precomp->h));
|
||||
PP(precomp->clipper)->ref();
|
||||
}
|
||||
precomp->clipper->transform(precomp->cache.matrix);
|
||||
precomp->scene->composite(cast(precomp->clipper), CompositeMethod::ClipPath);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -331,6 +331,8 @@ LottieLayer::~LottieLayer()
|
|||
delete(*m);
|
||||
}
|
||||
|
||||
if (clipper && PP(clipper)->unref() == 0) delete(clipper);
|
||||
|
||||
delete(transform);
|
||||
free(name);
|
||||
}
|
||||
|
|
|
@ -594,6 +594,8 @@ struct LottieLayer : LottieGroup
|
|||
RGB24 color; //used by Solid layer
|
||||
LottieLayer* matteTarget = nullptr;
|
||||
|
||||
tvg::Shape* clipper = nullptr;
|
||||
|
||||
float timeStretch = 1.0f;
|
||||
float w = 0.0f, h = 0.0f;
|
||||
float inFrame = 0.0f;
|
||||
|
|
Loading…
Add table
Reference in a new issue