From b59c7a0beed67518ba8f25754d77185aa8d4c963 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Thu, 26 Dec 2024 13:48:26 +0900 Subject: [PATCH] API: enable users to use an accessor to traverse Scene remove the restriction of targeting only Picture. now, any kind of paints can be adaptable here. --- inc/thorvg.h | 4 ++-- src/renderer/tvgAccessor.cpp | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/inc/thorvg.h b/inc/thorvg.h index ad2c510b..8e3ab4e6 100644 --- a/inc/thorvg.h +++ b/inc/thorvg.h @@ -2113,7 +2113,7 @@ public: /** * @brief Set the access function for traversing the Picture scene tree nodes. * - * @param[in] picture The picture node to traverse the internal scene-tree. + * @param[in] paint The paint node to traverse the internal scene-tree. * @param[in] func The callback function calling for every paint nodes of the Picture. * @param[in] data Data passed to the @p func as its argument. * @@ -2121,7 +2121,7 @@ public: * * @note Experimental API */ - Result set(const Picture* picture, std::function func, void* data) noexcept; + Result set(Paint* paint, std::function func, void* data) noexcept; /** * @brief Generate a unique ID (hash key) from a given name. diff --git a/src/renderer/tvgAccessor.cpp b/src/renderer/tvgAccessor.cpp index a1447268..21caa2c2 100644 --- a/src/renderer/tvgAccessor.cpp +++ b/src/renderer/tvgAccessor.cpp @@ -64,17 +64,17 @@ TVG_DEPRECATED unique_ptr Accessor::set(unique_ptr picture, fu } -Result Accessor::set(const Picture* picture, function func, void* data) noexcept +Result Accessor::set(Paint* paint, function func, void* data) noexcept { - if (!picture || !func) return Result::InvalidArguments; + if (!paint || !func) return Result::InvalidArguments; - //Use the Preorder Tree-Search + //Use the Preorder Tree-Searc //Root - if (!func(picture, data)) return Result::Success; + if (!func(paint, data)) return Result::Success; //Children - if (auto it = IteratorAccessor::iterator(picture)) { + if (auto it = IteratorAccessor::iterator(paint)) { accessChildren(it, func, data); delete(it); }