From b87bb2b1a0fddc7725f06fda4fb07f96947f6ae5 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 6aa42731..2d9a32a1 100644 --- a/src/loaders/lottie/tvgLottieParser.cpp +++ b/src/loaders/lottie/tvgLottieParser.cpp @@ -950,8 +950,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); + } + } }