lottie: code clean up

- a file name (LottieCommon -> LottieData) was changed
- removed duplicate code
- removed dead code
This commit is contained in:
Hermet Park 2024-12-09 15:56:34 +09:00 committed by Hermet Park
parent 6b416409c3
commit b24d196809
6 changed files with 10 additions and 16 deletions

View file

@ -4,7 +4,7 @@ endif
source_file = [ source_file = [
'tvgLottieBuilder.h', 'tvgLottieBuilder.h',
'tvgLottieCommon.h', 'tvgLottieData.h',
'tvgLottieExpressions.h', 'tvgLottieExpressions.h',
'tvgLottieInterpolator.h', 'tvgLottieInterpolator.h',
'tvgLottieLoader.h', 'tvgLottieLoader.h',

View file

@ -238,7 +238,7 @@ static jerry_value_t _buildTrimpath(LottieTrimpath* trimpath, float frameNo)
jerry_object_set_sz(obj, "end", end); jerry_object_set_sz(obj, "end", end);
jerry_value_free(end); jerry_value_free(end);
auto offset = jerry_number(trimpath->offset(frameNo)); auto offset = jerry_number(trimpath->offset(frameNo));
jerry_object_set_sz(obj, "offset", offset); jerry_object_set_sz(obj, EXP_OFFSET, offset);
jerry_value_free(offset); jerry_value_free(offset);
return obj; return obj;

View file

@ -24,7 +24,7 @@
#define _TVG_LOTTIE_EXPRESSIONS_H_ #define _TVG_LOTTIE_EXPRESSIONS_H_
#include "tvgCommon.h" #include "tvgCommon.h"
#include "tvgLottieCommon.h" #include "tvgLottieData.h"
struct LottieExpression; struct LottieExpression;
struct LottieComposition; struct LottieComposition;

View file

@ -760,15 +760,7 @@ struct LottieLayer : LottieGroup
~LottieLayer(); ~LottieLayer();
uint8_t opacity(float frameNo)
{
//return zero if the visibility is false.
if (type == Null) return 255;
return transform->opacity(frameNo);
}
bool mergeable() override { return false; } bool mergeable() override { return false; }
void prepare(RGB24* color = nullptr); void prepare(RGB24* color = nullptr);
float remap(LottieComposition* comp, float frameNo, LottieExpressions* exp); float remap(LottieComposition* comp, float frameNo, LottieExpressions* exp);

View file

@ -25,7 +25,7 @@
#include <algorithm> #include <algorithm>
#include "tvgMath.h" #include "tvgMath.h"
#include "tvgLottieCommon.h" #include "tvgLottieData.h"
#include "tvgLottieInterpolator.h" #include "tvgLottieInterpolator.h"
#include "tvgLottieExpressions.h" #include "tvgLottieExpressions.h"
#include "tvgLottieModifier.h" #include "tvgLottieModifier.h"
@ -222,6 +222,8 @@ float _frameNo(T* frames, int32_t key)
template<typename T> template<typename T>
float _loop(T* frames, float frameNo, LottieExpression* exp) float _loop(T* frames, float frameNo, LottieExpression* exp)
{ {
if (exp->loop.mode == LottieExpression::LoopMode::None) return frameNo;
if (frameNo >= exp->loop.in || frameNo < frames->first().no || frameNo < frames->last().no) return frameNo; if (frameNo >= exp->loop.in || frameNo < frames->first().no || frameNo < frames->last().no) return frameNo;
frameNo -= frames->first().no; frameNo -= frames->first().no;
@ -329,7 +331,7 @@ struct LottieGenericProperty : LottieProperty
{ {
if (exps && exp) { if (exps && exp) {
T out{}; T out{};
if (exp->loop.mode != LottieExpression::LoopMode::None) frameNo = _loop(frames, frameNo, exp); frameNo = _loop(frames, frameNo, exp);
if (exps->result<LottieGenericProperty<T>>(frameNo, out, exp)) return out; if (exps->result<LottieGenericProperty<T>>(frameNo, out, exp)) return out;
} }
return operator()(frameNo); return operator()(frameNo);
@ -496,7 +498,7 @@ struct LottiePathSet : LottieProperty
bool operator()(float frameNo, Array<PathCommand>& cmds, Array<Point>& pts, Matrix* transform, const LottieRoundnessModifier* roundness, const LottieOffsetModifier* offsetPath, LottieExpressions* exps) bool operator()(float frameNo, Array<PathCommand>& cmds, Array<Point>& pts, Matrix* transform, const LottieRoundnessModifier* roundness, const LottieOffsetModifier* offsetPath, LottieExpressions* exps)
{ {
if (exps && exp) { if (exps && exp) {
if (exp->loop.mode != LottieExpression::LoopMode::None) frameNo = _loop(frames, frameNo, exp); frameNo = _loop(frames, frameNo, exp);
if (exps->result<LottiePathSet>(frameNo, cmds, pts, transform, roundness, offsetPath, exp)) return true; if (exps->result<LottiePathSet>(frameNo, cmds, pts, transform, roundness, offsetPath, exp)) return true;
} }
return operator()(frameNo, cmds, pts, transform, roundness, offsetPath); return operator()(frameNo, cmds, pts, transform, roundness, offsetPath);
@ -585,7 +587,7 @@ struct LottieColorStop : LottieProperty
Result operator()(float frameNo, Fill* fill, LottieExpressions* exps) Result operator()(float frameNo, Fill* fill, LottieExpressions* exps)
{ {
if (exps && exp) { if (exps && exp) {
if (exp->loop.mode != LottieExpression::LoopMode::None) frameNo = _loop(frames, frameNo, exp); frameNo = _loop(frames, frameNo, exp);
if (exps->result<LottieColorStop>(frameNo, fill, exp)) return Result::Success; if (exps->result<LottieColorStop>(frameNo, fill, exp)) return Result::Success;
} }
@ -719,7 +721,7 @@ struct LottiePosition : LottieProperty
{ {
Point out{}; Point out{};
if (exps && exp) { if (exps && exp) {
if (exp->loop.mode != LottieExpression::LoopMode::None) frameNo = _loop(frames, frameNo, exp); frameNo = _loop(frames, frameNo, exp);
if (exps->result<LottiePosition>(frameNo, out, exp)) return out; if (exps->result<LottiePosition>(frameNo, out, exp)) return out;
} }
return operator()(frameNo); return operator()(frameNo);