diff --git a/src/loaders/lottie/tvgLottieExpressions.cpp b/src/loaders/lottie/tvgLottieExpressions.cpp index b5489be9..cbf0f17b 100644 --- a/src/loaders/lottie/tvgLottieExpressions.cpp +++ b/src/loaders/lottie/tvgLottieExpressions.cpp @@ -1326,7 +1326,7 @@ jerry_value_t LottieExpressions::evaluate(float frameNo, LottieExpression* exp) auto eval = jerry_eval((jerry_char_t *) exp->code, strlen(exp->code), JERRY_PARSE_NO_OPTS); if (jerry_value_is_exception(eval) || jerry_value_is_undefined(eval)) { - exp->enabled = false; // The feature is experimental, it will be forcefully turned off if it's incompatible. + TVGERR("LOTTIE", "Failed to dispatch the expressions!"); return jerry_undefined(); } diff --git a/src/loaders/lottie/tvgLottieExpressions.h b/src/loaders/lottie/tvgLottieExpressions.h index 997ce1d8..3338d9c8 100644 --- a/src/loaders/lottie/tvgLottieExpressions.h +++ b/src/loaders/lottie/tvgLottieExpressions.h @@ -42,14 +42,12 @@ public: bool result(float frameNo, NumType& out, LottieExpression* exp) { auto bm_rt = evaluate(frameNo, exp); + if (jerry_value_is_undefined(bm_rt)) return false; if (jerry_value_is_number(bm_rt)) { out = (NumType) jerry_value_as_number(bm_rt); } else if (auto prop = static_cast(jerry_object_get_native_ptr(bm_rt, nullptr))) { out = (*prop)(frameNo); - } else { - TVGERR("LOTTIE", "Failed dispatching a Value!"); - return false; } jerry_value_free(bm_rt); return true; @@ -59,6 +57,7 @@ public: bool result(float frameNo, Point& out, LottieExpression* exp) { auto bm_rt = evaluate(frameNo, exp); + if (jerry_value_is_undefined(bm_rt)) return false; if (jerry_value_is_object(bm_rt)) { if (auto prop = static_cast(jerry_object_get_native_ptr(bm_rt, nullptr))) { @@ -71,9 +70,6 @@ public: jerry_value_free(x); jerry_value_free(y); } - } else { - TVGERR("LOTTIE", "Failed dispatching Point!"); - return false; } jerry_value_free(bm_rt); return true; @@ -83,12 +79,10 @@ public: bool result(float frameNo, RGB24& out, LottieExpression* exp) { auto bm_rt = evaluate(frameNo, exp); + if (jerry_value_is_undefined(bm_rt)) return false; if (auto color = static_cast(jerry_object_get_native_ptr(bm_rt, nullptr))) { out = (*color)(frameNo); - } else { - TVGERR("LOTTIE", "Failed dispatching Color!"); - return false; } jerry_value_free(bm_rt); return true; @@ -98,12 +92,10 @@ public: bool result(float frameNo, Fill* fill, LottieExpression* exp) { auto bm_rt = evaluate(frameNo, exp); + if (jerry_value_is_undefined(bm_rt)) return false; if (auto colorStop = static_cast(jerry_object_get_native_ptr(bm_rt, nullptr))) { (*colorStop)(frameNo, fill, this); - } else { - TVGERR("LOTTIE", "Failed dispatching ColorStop!"); - return false; } jerry_value_free(bm_rt); return true; @@ -113,13 +105,11 @@ public: bool result(float frameNo, Array& cmds, Array& pts, Matrix* transform, float roundness, LottieExpression* exp) { auto bm_rt = evaluate(frameNo, exp); + if (jerry_value_is_undefined(bm_rt)) return false; if (auto pathset = static_cast(jerry_object_get_native_ptr(bm_rt, nullptr))) { (*pathset)(frameNo, cmds, pts, transform, roundness); - } else { - TVGERR("LOTTIE", "Failed dispatching PathSet!"); - return false; - } + } jerry_value_free(bm_rt); return true; } diff --git a/src/loaders/lottie/tvgLottieParser.cpp b/src/loaders/lottie/tvgLottieParser.cpp index 525405a0..2328c09a 100644 --- a/src/loaders/lottie/tvgLottieParser.cpp +++ b/src/loaders/lottie/tvgLottieParser.cpp @@ -44,7 +44,6 @@ static LottieExpression* _expression(char* code, LottieComposition* comp, Lottie inst->layer = layer; inst->object = object; inst->property = property; - inst->enabled = true; return inst; } diff --git a/src/loaders/lottie/tvgLottieProperty.h b/src/loaders/lottie/tvgLottieProperty.h index ca022c29..c89614dd 100644 --- a/src/loaders/lottie/tvgLottieProperty.h +++ b/src/loaders/lottie/tvgLottieProperty.h @@ -199,8 +199,6 @@ struct LottieExpression LottieObject* object; LottieProperty* property; - bool enabled; - struct { uint32_t key = 0; //the keyframe number repeating to float in = FLT_MAX; //looping duration in frame number @@ -460,7 +458,7 @@ struct LottieGenericProperty : LottieProperty T operator()(float frameNo, LottieExpressions* exps) { - if (exps && (exp && exp->enabled)) { + if (exps && exp) { T out{}; if (exp->loop.mode != LottieExpression::LoopMode::None) frameNo = _loop(frames, frameNo, exp); if (exps->result>(frameNo, out, exp)) return out; @@ -605,7 +603,7 @@ struct LottiePathSet : LottieProperty bool operator()(float frameNo, Array& cmds, Array& pts, Matrix* transform, float roundness, LottieExpressions* exps) { - if (exps && (exp && exp->enabled)) { + if (exps && exp) { if (exp->loop.mode != LottieExpression::LoopMode::None) frameNo = _loop(frames, frameNo, exp); if (exps->result(frameNo, cmds, pts, transform, roundness, exp)) return true; } @@ -686,7 +684,7 @@ struct LottieColorStop : LottieProperty Result operator()(float frameNo, Fill* fill, LottieExpressions* exps) { - if (exps && (exp && exp->enabled)) { + if (exps && exp) { if (exp->loop.mode != LottieExpression::LoopMode::None) frameNo = _loop(frames, frameNo, exp); if (exps->result(frameNo, fill, exp)) return Result::Success; } @@ -818,7 +816,7 @@ struct LottiePosition : LottieProperty Point operator()(float frameNo, LottieExpressions* exps) { Point out{}; - if (exps && (exp && exp->enabled)) { + if (exps && exp) { if (exp->loop.mode != LottieExpression::LoopMode::None) frameNo = _loop(frames, frameNo, exp); if (exps->result(frameNo, out, exp)) return out; }