lottie/parser: ++ null value handling

Note that, only dealt with a obivous case in practice.

issue: https://github.com/thorvg/thorvg/issues/2703
This commit is contained in:
Hermet Park 2024-09-03 17:21:23 +09:00 committed by Hermet Park
parent 31e7d44a92
commit c1c51fbc10
2 changed files with 12 additions and 10 deletions

View file

@ -318,17 +318,22 @@ void LottieParser::getValue(float& val)
}
void LottieParser::getValue(Point& pt)
bool LottieParser::getValue(Point& pt)
{
auto type = peekType();
if (type == kNullType) return false;
int i = 0;
auto ptr = (float*)(&pt);
if (peekType() == kArrayType) enterArray();
if (type == kArrayType) enterArray();
while (nextArrayValue()) {
auto val = getFloat();
if (i < 2) ptr[i++] = val;
}
return true;
}
@ -370,14 +375,11 @@ void LottieParser::parseSlotProperty(T& prop)
template<typename T>
bool LottieParser::parseTangent(const char *key, LottieVectorFrame<T>& value)
{
if (KEY_AS("ti")) {
value.hasTangent = true;
getValue(value.inTangent);
} else if (KEY_AS("to")) {
value.hasTangent = true;
getValue(value.outTangent);
} else return false;
if (KEY_AS("ti") && getValue(value.inTangent)) ;
else if (KEY_AS("to") && getValue(value.outTangent)) ;
else return false;
value.hasTangent = true;
return true;
}

View file

@ -61,8 +61,8 @@ private:
void getValue(ColorStop& color);
void getValue(float& val);
void getValue(uint8_t& val);
void getValue(Point& pt);
void getValue(RGB24& color);
bool getValue(Point& pt);
template<typename T> bool parseTangent(const char *key, LottieVectorFrame<T>& value);
template<typename T> bool parseTangent(const char *key, LottieScalarFrame<T>& value);