From 7aa8f07946f8d49ac242446c834f0d5d61a6219c Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Wed, 15 Nov 2023 20:20:23 +0900 Subject: [PATCH] lottie/parser: Fix the shapes parsing logic. Currently, it assumes "ty":"gr" for the related shapes children, which can be skipped since the children will be in the "it" scope. Some Lottie data is missing the "ty":"gr" field, and ThorVG couldn't display the content properly. It can ignore it with the context understanding. --- src/loaders/lottie/tvgLottieParser.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/loaders/lottie/tvgLottieParser.cpp b/src/loaders/lottie/tvgLottieParser.cpp index d7931015..10cba904 100644 --- a/src/loaders/lottie/tvgLottieParser.cpp +++ b/src/loaders/lottie/tvgLottieParser.cpp @@ -932,8 +932,19 @@ void LottieParser::parseShapes(LottieLayer* layer) { enterArray(); while (nextArrayValue()) { - parseObject(layer); - } + enterObject(); + while (auto key = nextObjectKey()) { + if (!strcmp(key, "it")) { + enterArray(); + while (nextArrayValue()) parseObject(layer); + } else if (!strcmp(key, "ty")) { + if (auto child = parseObject()) { + if (child->hidden) delete(child); + else layer->children.push(child); + } + } else skip(key); + } + } }