mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-13 19:44:28 +00:00
lottie: code refactoring.
removed unused static condition. static was prepared for optimization, but not used at all. we will revisit this later when time permits. binary size: -6kb
This commit is contained in:
parent
7ec7a4c08c
commit
736a79674b
4 changed files with 4 additions and 33 deletions
|
@ -1106,7 +1106,6 @@ static void _buildReference(LottieComposition* comp, LottieLayer* layer)
|
|||
} else if (layer->type == LottieLayer::Image) {
|
||||
layer->children.push(*asset);
|
||||
}
|
||||
layer->statical &= (*asset)->statical;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1173,15 +1172,11 @@ static bool _buildComposition(LottieComposition* comp, LottieGroup* parent)
|
|||
_bulidHierarchy(parent, child->matte.target);
|
||||
//precomp referencing
|
||||
if (child->matte.target->refId) _buildReference(comp, child->matte.target);
|
||||
child->statical &= child->matte.target->statical;
|
||||
}
|
||||
_bulidHierarchy(parent, child);
|
||||
|
||||
//attach the necessary font data
|
||||
if (child->type == LottieLayer::Text) _attachFont(comp, child);
|
||||
|
||||
child->statical &= parent->statical;
|
||||
parent->statical &= child->statical;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -142,9 +142,8 @@ void LottieGroup::prepare(LottieObject::Type type)
|
|||
size_t fillCnt = 0;
|
||||
|
||||
for (auto c = children.end() - 1; c >= children.begin(); --c) {
|
||||
if (reqFragment && !statical) break;
|
||||
if (reqFragment) break;
|
||||
auto child = static_cast<LottieObject*>(*c);
|
||||
if (statical) statical &= child->statical;
|
||||
/* Figure out if the rendering context should be fragmented.
|
||||
Multiple stroking or grouping with a stroking would occur this.
|
||||
This fragment resolves the overlapped stroke outlines. */
|
||||
|
@ -180,11 +179,8 @@ LottieLayer::~LottieLayer()
|
|||
|
||||
void LottieLayer::prepare()
|
||||
{
|
||||
if (transform) statical &= transform->statical;
|
||||
if (timeRemap.frames) statical = false;
|
||||
|
||||
/* if layer is hidden, only useful data is its transform matrix.
|
||||
so force it to be a Null Layer and release all resource. */
|
||||
so force it to be a Null Layer and release all resource. */
|
||||
if (hidden) {
|
||||
type = LottieLayer::Null;
|
||||
children.reset();
|
||||
|
|
|
@ -88,12 +88,6 @@ struct LottieMask
|
|||
LottieOpacity opacity = 255;
|
||||
CompositeMethod method;
|
||||
bool inverse = false;
|
||||
|
||||
bool dynamic()
|
||||
{
|
||||
if (opacity.frames || pathset.frames) return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -132,7 +126,6 @@ struct LottieObject
|
|||
|
||||
char* name = nullptr;
|
||||
Type type;
|
||||
bool statical = true; //no keyframes
|
||||
bool hidden = false; //remove?
|
||||
};
|
||||
|
||||
|
@ -207,7 +200,6 @@ struct LottieTrimpath : LottieObject
|
|||
void prepare()
|
||||
{
|
||||
LottieObject::type = LottieObject::Trimpath;
|
||||
if (start.frames || end.frames || offset.frames) statical = false;
|
||||
}
|
||||
|
||||
void segment(float frameNo, float& start, float& end);
|
||||
|
@ -231,7 +223,6 @@ struct LottieRoundedCorner : LottieObject
|
|||
void prepare()
|
||||
{
|
||||
LottieObject::type = LottieObject::RoundedCorner;
|
||||
if (radius.frames) statical = false;
|
||||
}
|
||||
LottieFloat radius = 0.0f;
|
||||
};
|
||||
|
@ -242,7 +233,6 @@ struct LottiePath : LottieShape
|
|||
void prepare()
|
||||
{
|
||||
LottieObject::type = LottieObject::Path;
|
||||
if (pathset.frames) statical = false;
|
||||
}
|
||||
|
||||
LottiePathSet pathset;
|
||||
|
@ -254,7 +244,6 @@ struct LottieRect : LottieShape
|
|||
void prepare()
|
||||
{
|
||||
LottieObject::type = LottieObject::Rect;
|
||||
if (position.frames || size.frames || radius.frames) statical = false;
|
||||
}
|
||||
|
||||
LottiePosition position = Point{0.0f, 0.0f};
|
||||
|
@ -270,7 +259,6 @@ struct LottiePolyStar : LottieShape
|
|||
void prepare()
|
||||
{
|
||||
LottieObject::type = LottieObject::Polystar;
|
||||
if (position.frames || innerRadius.frames || outerRadius.frames || innerRoundness.frames || outerRoundness.frames || rotation.frames || ptsCnt.frames) statical = false;
|
||||
}
|
||||
|
||||
LottiePosition position = Point{0.0f, 0.0f};
|
||||
|
@ -289,7 +277,6 @@ struct LottieEllipse : LottieShape
|
|||
void prepare()
|
||||
{
|
||||
LottieObject::type = LottieObject::Ellipse;
|
||||
if (position.frames || size.frames) statical = false;
|
||||
}
|
||||
|
||||
LottiePosition position = Point{0.0f, 0.0f};
|
||||
|
@ -320,9 +307,6 @@ struct LottieTransform : LottieObject
|
|||
void prepare()
|
||||
{
|
||||
LottieObject::type = LottieObject::Transform;
|
||||
if (position.frames || rotation.frames || scale.frames || anchor.frames || opacity.frames || (coords && (coords->x.frames || coords->y.frames)) || (rotationEx && (rotationEx->x.frames || rotationEx->y.frames))) {
|
||||
statical = false;
|
||||
}
|
||||
}
|
||||
|
||||
LottiePosition position = Point{0.0f, 0.0f};
|
||||
|
@ -348,7 +332,6 @@ struct LottieSolidStroke : LottieSolid, LottieStroke
|
|||
void prepare()
|
||||
{
|
||||
LottieObject::type = LottieObject::SolidStroke;
|
||||
if (color.frames || opacity.frames || LottieStroke::dynamic()) statical = false;
|
||||
}
|
||||
|
||||
void override(LottieProperty* prop) override
|
||||
|
@ -364,7 +347,6 @@ struct LottieSolidFill : LottieSolid
|
|||
void prepare()
|
||||
{
|
||||
LottieObject::type = LottieObject::SolidFill;
|
||||
if (color.frames || opacity.frames) statical = false;
|
||||
}
|
||||
|
||||
void override(LottieProperty* prop) override
|
||||
|
@ -493,7 +475,7 @@ struct LottieGradientFill : LottieGradient
|
|||
void prepare()
|
||||
{
|
||||
LottieObject::type = LottieObject::GradientFill;
|
||||
if (LottieGradient::prepare()) statical = false;
|
||||
LottieGradient::prepare();
|
||||
}
|
||||
|
||||
void override(LottieProperty* prop) override
|
||||
|
@ -511,7 +493,7 @@ struct LottieGradientStroke : LottieGradient, LottieStroke
|
|||
void prepare()
|
||||
{
|
||||
LottieObject::type = LottieObject::GradientStroke;
|
||||
if (LottieGradient::prepare() || LottieStroke::dynamic()) statical = false;
|
||||
LottieGradient::prepare();
|
||||
}
|
||||
|
||||
void override(LottieProperty* prop) override
|
||||
|
@ -547,7 +529,6 @@ struct LottieRepeater : LottieObject
|
|||
void prepare()
|
||||
{
|
||||
LottieObject::type = LottieObject::Repeater;
|
||||
if (copies.frames || offset.frames || position.frames || rotation.frames || scale.frames || anchor.frames || startOpacity.frames || endOpacity.frames) statical = false;
|
||||
}
|
||||
|
||||
LottieFloat copies = 0.0f;
|
||||
|
|
|
@ -1124,7 +1124,6 @@ void LottieParser::parseMasks(LottieLayer* layer)
|
|||
enterArray();
|
||||
while (nextArrayValue()) {
|
||||
auto mask = parseMask();
|
||||
if (mask->dynamic()) layer->statical = false;
|
||||
layer->masks.push(mask);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue