mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-21 15:32:49 +00:00
Revert "Revert "lottie: ++ scene composing optimization""
This reverts commit 8c3586a7c4
.
This commit is contained in:
parent
f6c4d8a94e
commit
4f2f4dbf26
3 changed files with 15 additions and 10 deletions
|
@ -1027,18 +1027,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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -333,6 +333,7 @@ LottieLayer::~LottieLayer()
|
|||
|
||||
//Remove tvg render paints
|
||||
if (solidFill && PP(solidFill)->unref() == 0) delete(solidFill);
|
||||
if (clipper && PP(clipper)->unref() == 0) delete(clipper);
|
||||
|
||||
delete(transform);
|
||||
free(name);
|
||||
|
|
|
@ -594,6 +594,7 @@ struct LottieLayer : LottieGroup
|
|||
LottieLayer* matteTarget = nullptr;
|
||||
|
||||
tvg::Shape* solidFill = nullptr;
|
||||
tvg::Shape* clipper = nullptr;
|
||||
|
||||
float timeStretch = 1.0f;
|
||||
float w = 0.0f, h = 0.0f;
|
||||
|
|
Loading…
Add table
Reference in a new issue