lottie: introduced LottieProperty base class

this is useful for slot & expression type casting.
This commit is contained in:
Hermet Park 2024-02-21 01:22:31 +09:00
parent c08c11db7d
commit fe6493351a

View file

@ -201,16 +201,22 @@ uint32_t bsearch(T* frames, float frameNo)
} }
template<typename T>
struct LottieProperty struct LottieProperty
{
enum class Type : uint8_t { Point = 0, Float, Opacity, Color, PathSet, ColorStop, Position, TextDoc, Invalid };
};
template<typename T>
struct LottieGenericProperty : LottieProperty
{ {
//Property has an either keyframes or single value. //Property has an either keyframes or single value.
Array<LottieScalarFrame<T>>* frames = nullptr; Array<LottieScalarFrame<T>>* frames = nullptr;
T value; T value;
LottieProperty(T v) : value(v) {} LottieGenericProperty(T v) : value(v) {}
~LottieProperty() ~LottieGenericProperty()
{ {
delete(frames); delete(frames);
} }
@ -248,7 +254,7 @@ struct LottieProperty
}; };
struct LottiePathSet struct LottiePathSet : LottieProperty
{ {
Array<LottieScalarFrame<PathSet>>* frames = nullptr; Array<LottieScalarFrame<PathSet>>* frames = nullptr;
PathSet value; PathSet value;
@ -343,7 +349,7 @@ struct LottiePathSet
}; };
struct LottieColorStop struct LottieColorStop : LottieProperty
{ {
Array<LottieScalarFrame<ColorStop>>* frames = nullptr; Array<LottieScalarFrame<ColorStop>>* frames = nullptr;
ColorStop value; ColorStop value;
@ -431,7 +437,7 @@ struct LottieColorStop
}; };
struct LottiePosition struct LottiePosition : LottieProperty
{ {
Array<LottieVectorFrame<Point>>* frames = nullptr; Array<LottieVectorFrame<Point>>* frames = nullptr;
Point value; Point value;
@ -493,7 +499,7 @@ struct LottiePosition
}; };
struct LottieTextDoc struct LottieTextDoc : LottieProperty
{ {
Array<LottieScalarFrame<TextDocument>>* frames = nullptr; Array<LottieScalarFrame<TextDocument>>* frames = nullptr;
TextDocument value; TextDocument value;
@ -542,9 +548,9 @@ struct LottieTextDoc
}; };
using LottiePoint = LottieProperty<Point>; using LottiePoint = LottieGenericProperty<Point>;
using LottieFloat = LottieProperty<float>; using LottieFloat = LottieGenericProperty<float>;
using LottieOpacity = LottieProperty<uint8_t>; using LottieOpacity = LottieGenericProperty<uint8_t>;
using LottieColor = LottieProperty<RGB24>; using LottieColor = LottieGenericProperty<RGB24>;
#endif //_TVG_LOTTIE_PROPERTY_H_ #endif //_TVG_LOTTIE_PROPERTY_H_