mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-13 19:44:28 +00:00
lottie: ++scene rendering optimization
Apply LottieRenderPooler to maskings.
This commit is contained in:
parent
75ed0e4e09
commit
62f88ec072
3 changed files with 16 additions and 16 deletions
|
@ -342,7 +342,7 @@ static void _updateGradientStroke(TVG_UNUSED LottieGroup* parent, LottieObject**
|
|||
}
|
||||
|
||||
|
||||
static void _updateSolidFill(TVG_UNUSED LottieGroup* parent, LottieObject** child, float frameNo, TVG_UNUSED Inlist<RenderContext>& contexts, RenderContext* ctx, LottieExpressions* exps)
|
||||
static void _updateSolidFill(TVG_UNUSED LottieGroup* parent, LottieObject** child, float frameNo, Inlist<RenderContext>& contexts, RenderContext* ctx, LottieExpressions* exps)
|
||||
{
|
||||
if (_fragmented(child, contexts, ctx)) return;
|
||||
|
||||
|
@ -357,7 +357,7 @@ static void _updateSolidFill(TVG_UNUSED LottieGroup* parent, LottieObject** chil
|
|||
}
|
||||
|
||||
|
||||
static void _updateGradientFill(TVG_UNUSED LottieGroup* parent, LottieObject** child, float frameNo, TVG_UNUSED Inlist<RenderContext>& contexts, RenderContext* ctx, LottieExpressions* exps)
|
||||
static void _updateGradientFill(TVG_UNUSED LottieGroup* parent, LottieObject** child, float frameNo, Inlist<RenderContext>& contexts, RenderContext* ctx, LottieExpressions* exps)
|
||||
{
|
||||
if (_fragmented(child, contexts, ctx)) return;
|
||||
|
||||
|
@ -1056,7 +1056,7 @@ static void _updatePrecomp(LottieComposition* comp, LottieLayer* precomp, float
|
|||
}
|
||||
|
||||
//clip the layer viewport
|
||||
auto clipper = precomp->pooling(true);
|
||||
auto clipper = precomp->statical.pooling(true);
|
||||
clipper->transform(precomp->cache.matrix);
|
||||
precomp->scene->composite(cast(clipper), CompositeMethod::ClipPath);
|
||||
}
|
||||
|
@ -1064,7 +1064,7 @@ static void _updatePrecomp(LottieComposition* comp, LottieLayer* precomp, float
|
|||
|
||||
static void _updateSolid(LottieLayer* layer)
|
||||
{
|
||||
auto solidFill = layer->pooling(true);
|
||||
auto solidFill = layer->statical.pooling(true);
|
||||
solidFill->opacity(layer->cache.opacity);
|
||||
layer->scene->push(cast(solidFill));
|
||||
}
|
||||
|
@ -1215,12 +1215,11 @@ static void _updateMaskings(LottieLayer* layer, float frameNo, LottieExpressions
|
|||
auto pMask = static_cast<LottieMask*>(layer->masks[0]);
|
||||
auto pMethod = pMask->method;
|
||||
|
||||
auto pShape = Shape::gen().release();
|
||||
auto pShape = layer->pooling();
|
||||
pShape->reset();
|
||||
pShape->fill(255, 255, 255, pMask->opacity(frameNo));
|
||||
pShape->transform(layer->cache.matrix);
|
||||
if (pMask->pathset(frameNo, P(pShape)->rs.path.cmds, P(pShape)->rs.path.pts, nullptr, 0.0f, exps)) {
|
||||
P(pShape)->update(RenderUpdateFlag::Path);
|
||||
}
|
||||
pMask->pathset(frameNo, P(pShape)->rs.path.cmds, P(pShape)->rs.path.pts, nullptr, 0.0f, exps);
|
||||
|
||||
if (pMethod == CompositeMethod::SubtractMask || pMethod == CompositeMethod::InvAlphaMask) {
|
||||
layer->scene->composite(tvg::cast(pShape), CompositeMethod::InvAlphaMask);
|
||||
|
@ -1239,12 +1238,11 @@ static void _updateMaskings(LottieLayer* layer, float frameNo, LottieExpressions
|
|||
mask->pathset(frameNo, P(pShape)->rs.path.cmds, P(pShape)->rs.path.pts, nullptr, 0.0f, exps);
|
||||
//Chain composition
|
||||
} else {
|
||||
auto shape = Shape::gen().release();
|
||||
auto shape = layer->pooling();
|
||||
shape->reset();
|
||||
shape->fill(255, 255, 255, mask->opacity(frameNo));
|
||||
shape->transform(layer->cache.matrix);
|
||||
if (mask->pathset(frameNo, P(shape)->rs.path.cmds, P(shape)->rs.path.pts, nullptr, 0.0f, exps)) {
|
||||
P(shape)->update(RenderUpdateFlag::Path);
|
||||
}
|
||||
mask->pathset(frameNo, P(shape)->rs.path.cmds, P(shape)->rs.path.pts, nullptr, 0.0f, exps);
|
||||
pShape->composite(tvg::cast(shape), method);
|
||||
pShape = shape;
|
||||
pMethod = method;
|
||||
|
|
|
@ -400,14 +400,14 @@ void LottieLayer::prepare(RGB24* color)
|
|||
auto clipper = Shape::gen().release();
|
||||
clipper->appendRect(0.0f, 0.0f, w, h);
|
||||
PP(clipper)->ref();
|
||||
pooler.push(clipper);
|
||||
statical.pooler.push(clipper);
|
||||
//prepare solid fill in advance if it is a layer type.
|
||||
} else if (color && type == LottieLayer::Solid) {
|
||||
auto solidFill = Shape::gen().release();
|
||||
solidFill->appendRect(0, 0, static_cast<float>(w), static_cast<float>(h));
|
||||
solidFill->fill(color->rgb[0], color->rgb[1], color->rgb[2]);
|
||||
PP(solidFill)->ref();
|
||||
pooler.push(solidFill);
|
||||
statical.pooler.push(solidFill);
|
||||
}
|
||||
|
||||
LottieGroup::prepare(LottieObject::Layer);
|
||||
|
|
|
@ -659,7 +659,7 @@ struct LottieRepeater : LottieObject
|
|||
};
|
||||
|
||||
|
||||
struct LottieGroup : LottieObject
|
||||
struct LottieGroup : LottieObject, LottieRenderPooler<tvg::Shape>
|
||||
{
|
||||
LottieGroup();
|
||||
|
||||
|
@ -696,7 +696,7 @@ struct LottieGroup : LottieObject
|
|||
};
|
||||
|
||||
|
||||
struct LottieLayer : LottieGroup, LottieRenderPooler<tvg::Shape>
|
||||
struct LottieLayer : LottieGroup
|
||||
{
|
||||
enum Type : uint8_t {Precomp = 0, Solid, Image, Null, Shape, Text};
|
||||
|
||||
|
@ -722,6 +722,8 @@ struct LottieLayer : LottieGroup, LottieRenderPooler<tvg::Shape>
|
|||
Array<LottieMask*> masks;
|
||||
LottieLayer* matteTarget = nullptr;
|
||||
|
||||
LottieRenderPooler<tvg::Shape> statical; //static pooler for solid fill and clipper
|
||||
|
||||
float timeStretch = 1.0f;
|
||||
float w = 0.0f, h = 0.0f;
|
||||
float inFrame = 0.0f;
|
||||
|
|
Loading…
Add table
Reference in a new issue