From 3123e184c83dc2a34e3d9158ce4e0ae7428fe52c Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Mon, 16 Oct 2023 15:22:22 +0900 Subject: [PATCH] lottie: Fixed trimpath to support simultaneous trimpath The previous version omitted support for simultaneous trimpath, but it is now working as intended. --- src/loaders/lottie/tvgLottieBuilder.cpp | 9 ++++----- src/loaders/lottie/tvgLottieModel.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/loaders/lottie/tvgLottieBuilder.cpp b/src/loaders/lottie/tvgLottieBuilder.cpp index 8aa218f6..a64b66e9 100644 --- a/src/loaders/lottie/tvgLottieBuilder.cpp +++ b/src/loaders/lottie/tvgLottieBuilder.cpp @@ -58,6 +58,7 @@ struct RenderContext float roundness = 0.0f; bool stroking = false; //context has been separated by the stroking bool reqFragment = false; //requirment to fragment the render context + bool allowMerging = true; //individual trimpath doesn't allow merging shapes RenderContext() { @@ -304,7 +305,7 @@ static Shape* _updateFill(LottieGradientFill* fill, int32_t frameNo, RenderConte static Shape* _draw(LottieGroup* parent, int32_t frameNo, RenderContext& ctx) { - if (ctx.merging) return ctx.merging; + if (ctx.allowMerging && ctx.merging) return ctx.merging; auto shape = cast(ctx.propagator->duplicate()); ctx.merging = shape.get(); @@ -702,11 +703,9 @@ static void _updateTrimpath(LottieTrimpath* trimpath, int32_t frameNo, RenderCon end = (length * end) + pbegin; } - if (trimpath->type == LottieTrimpath::Individual) { - TVGERR("LOTTIE", "TODO: Individual Trimpath"); - } - P(ctx.propagator)->strokeTrim(begin, end); + + if (trimpath->type == LottieTrimpath::Individual) ctx.allowMerging = false; } diff --git a/src/loaders/lottie/tvgLottieModel.h b/src/loaders/lottie/tvgLottieModel.h index e9ca26e6..3a27664a 100644 --- a/src/loaders/lottie/tvgLottieModel.h +++ b/src/loaders/lottie/tvgLottieModel.h @@ -240,7 +240,7 @@ struct LottieObject struct LottieTrimpath : LottieObject { - enum Type : uint8_t { Simultaneous = 1, Individual = 2 }; + enum Type : uint8_t { Individual = 1, Simultaneous = 2 }; void prepare() {