From e0826020642e739a7b4d3a984d8b21f003662fa4 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Sat, 6 Jul 2024 12:04:56 +0900 Subject: [PATCH] API: introduce a Paint ID member as a reserved field The "id" is a reserved field to specify a paint instance in a scene. in this change, it assigns the layer id to the lottie scene as well. --- inc/thorvg.h | 9 +++++++++ src/loaders/lottie/tvgLottieBuilder.cpp | 1 + 2 files changed, 10 insertions(+) diff --git a/inc/thorvg.h b/inc/thorvg.h index 54d9d6e0..3f43fe08 100644 --- a/inc/thorvg.h +++ b/inc/thorvg.h @@ -430,6 +430,15 @@ public: */ uint32_t identifier() const noexcept; + /** + * @brief Unique ID of this instance. + * + * This is reserved to specify an paint instance in a scene. + * + * @since Experimental API + */ + uint32_t id = 0; + _TVG_DECLARE_PRIVATE(Paint); }; diff --git a/src/loaders/lottie/tvgLottieBuilder.cpp b/src/loaders/lottie/tvgLottieBuilder.cpp index 1023fdee..de0b0642 100644 --- a/src/loaders/lottie/tvgLottieBuilder.cpp +++ b/src/loaders/lottie/tvgLottieBuilder.cpp @@ -1270,6 +1270,7 @@ static void _updateLayer(LottieComposition* comp, Scene* scene, LottieLayer* lay //Prepare render data layer->scene = Scene::gen().release(); + layer->scene->id = layer->id; //ignore opacity when Null layer? if (layer->type != LottieLayer::Null) layer->scene->opacity(layer->cache.opacity);