From 736a79674b0e9d135f145c2cbfdff5bd9d7c5684 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Wed, 27 Mar 2024 21:01:16 +0900 Subject: [PATCH] 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 --- src/loaders/lottie/tvgLottieBuilder.cpp | 5 ----- src/loaders/lottie/tvgLottieModel.cpp | 8 ++------ src/loaders/lottie/tvgLottieModel.h | 23 ++--------------------- src/loaders/lottie/tvgLottieParser.cpp | 1 - 4 files changed, 4 insertions(+), 33 deletions(-) diff --git a/src/loaders/lottie/tvgLottieBuilder.cpp b/src/loaders/lottie/tvgLottieBuilder.cpp index 66217064..8caec4b5 100644 --- a/src/loaders/lottie/tvgLottieBuilder.cpp +++ b/src/loaders/lottie/tvgLottieBuilder.cpp @@ -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; } diff --git a/src/loaders/lottie/tvgLottieModel.cpp b/src/loaders/lottie/tvgLottieModel.cpp index 1a2c7fcd..8046e047 100644 --- a/src/loaders/lottie/tvgLottieModel.cpp +++ b/src/loaders/lottie/tvgLottieModel.cpp @@ -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(*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(); diff --git a/src/loaders/lottie/tvgLottieModel.h b/src/loaders/lottie/tvgLottieModel.h index 1226d916..65aced12 100644 --- a/src/loaders/lottie/tvgLottieModel.h +++ b/src/loaders/lottie/tvgLottieModel.h @@ -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; diff --git a/src/loaders/lottie/tvgLottieParser.cpp b/src/loaders/lottie/tvgLottieParser.cpp index c9b10221..de30d38c 100644 --- a/src/loaders/lottie/tvgLottieParser.cpp +++ b/src/loaders/lottie/tvgLottieParser.cpp @@ -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); } }