From fe6493351ab63794c0bc4cd6df3fbd7e536a0573 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Wed, 21 Feb 2024 01:22:31 +0900 Subject: [PATCH] lottie: introduced LottieProperty base class this is useful for slot & expression type casting. --- src/loaders/lottie/tvgLottieProperty.h | 28 ++++++++++++++++---------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/loaders/lottie/tvgLottieProperty.h b/src/loaders/lottie/tvgLottieProperty.h index a62957c3..7ee0bad8 100644 --- a/src/loaders/lottie/tvgLottieProperty.h +++ b/src/loaders/lottie/tvgLottieProperty.h @@ -201,16 +201,22 @@ uint32_t bsearch(T* frames, float frameNo) } -template struct LottieProperty +{ + enum class Type : uint8_t { Point = 0, Float, Opacity, Color, PathSet, ColorStop, Position, TextDoc, Invalid }; +}; + + +template +struct LottieGenericProperty : LottieProperty { //Property has an either keyframes or single value. Array>* frames = nullptr; T value; - LottieProperty(T v) : value(v) {} + LottieGenericProperty(T v) : value(v) {} - ~LottieProperty() + ~LottieGenericProperty() { delete(frames); } @@ -248,7 +254,7 @@ struct LottieProperty }; -struct LottiePathSet +struct LottiePathSet : LottieProperty { Array>* frames = nullptr; PathSet value; @@ -343,7 +349,7 @@ struct LottiePathSet }; -struct LottieColorStop +struct LottieColorStop : LottieProperty { Array>* frames = nullptr; ColorStop value; @@ -431,7 +437,7 @@ struct LottieColorStop }; -struct LottiePosition +struct LottiePosition : LottieProperty { Array>* frames = nullptr; Point value; @@ -493,7 +499,7 @@ struct LottiePosition }; -struct LottieTextDoc +struct LottieTextDoc : LottieProperty { Array>* frames = nullptr; TextDocument value; @@ -542,9 +548,9 @@ struct LottieTextDoc }; -using LottiePoint = LottieProperty; -using LottieFloat = LottieProperty; -using LottieOpacity = LottieProperty; -using LottieColor = LottieProperty; +using LottiePoint = LottieGenericProperty; +using LottieFloat = LottieGenericProperty; +using LottieOpacity = LottieGenericProperty; +using LottieColor = LottieGenericProperty; #endif //_TVG_LOTTIE_PROPERTY_H_ \ No newline at end of file