mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 21:53:41 +00:00
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:
parent
31e7d44a92
commit
c1c51fbc10
2 changed files with 12 additions and 10 deletions
|
@ -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;
|
int i = 0;
|
||||||
auto ptr = (float*)(&pt);
|
auto ptr = (float*)(&pt);
|
||||||
|
|
||||||
if (peekType() == kArrayType) enterArray();
|
if (type == kArrayType) enterArray();
|
||||||
|
|
||||||
while (nextArrayValue()) {
|
while (nextArrayValue()) {
|
||||||
auto val = getFloat();
|
auto val = getFloat();
|
||||||
if (i < 2) ptr[i++] = val;
|
if (i < 2) ptr[i++] = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -370,14 +375,11 @@ void LottieParser::parseSlotProperty(T& prop)
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool LottieParser::parseTangent(const char *key, LottieVectorFrame<T>& value)
|
bool LottieParser::parseTangent(const char *key, LottieVectorFrame<T>& value)
|
||||||
{
|
{
|
||||||
if (KEY_AS("ti")) {
|
if (KEY_AS("ti") && getValue(value.inTangent)) ;
|
||||||
value.hasTangent = true;
|
else if (KEY_AS("to") && getValue(value.outTangent)) ;
|
||||||
getValue(value.inTangent);
|
else return false;
|
||||||
} else if (KEY_AS("to")) {
|
|
||||||
value.hasTangent = true;
|
|
||||||
getValue(value.outTangent);
|
|
||||||
} else return false;
|
|
||||||
|
|
||||||
|
value.hasTangent = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,8 +61,8 @@ private:
|
||||||
void getValue(ColorStop& color);
|
void getValue(ColorStop& color);
|
||||||
void getValue(float& val);
|
void getValue(float& val);
|
||||||
void getValue(uint8_t& val);
|
void getValue(uint8_t& val);
|
||||||
void getValue(Point& pt);
|
|
||||||
void getValue(RGB24& color);
|
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, LottieVectorFrame<T>& value);
|
||||||
template<typename T> bool parseTangent(const char *key, LottieScalarFrame<T>& value);
|
template<typename T> bool parseTangent(const char *key, LottieScalarFrame<T>& value);
|
||||||
|
|
Loading…
Add table
Reference in a new issue