summaryrefslogtreecommitdiffstats
path: root/thirdparty/thorvg/src/renderer/tvgAccessor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/thorvg/src/renderer/tvgAccessor.cpp')
-rw-r--r--thirdparty/thorvg/src/renderer/tvgAccessor.cpp41
1 files changed, 31 insertions, 10 deletions
diff --git a/thirdparty/thorvg/src/renderer/tvgAccessor.cpp b/thirdparty/thorvg/src/renderer/tvgAccessor.cpp
index 903437f29d..a144726804 100644
--- a/thirdparty/thorvg/src/renderer/tvgAccessor.cpp
+++ b/thirdparty/thorvg/src/renderer/tvgAccessor.cpp
@@ -21,20 +21,21 @@
*/
#include "tvgIteratorAccessor.h"
+#include "tvgCompressor.h"
/************************************************************************/
/* Internal Class Implementation */
/************************************************************************/
-static bool accessChildren(Iterator* it, function<bool(const Paint* paint)> func)
+static bool accessChildren(Iterator* it, function<bool(const Paint* paint, void* data)> func, void* data)
{
while (auto child = it->next()) {
//Access the child
- if (!func(child)) return false;
+ if (!func(child, data)) return false;
//Access the children of the child
if (auto it2 = IteratorAccessor::iterator(child)) {
- if (!accessChildren(it2, func)) {
+ if (!accessChildren(it2, func, data)) {
delete(it2);
return false;
}
@@ -44,26 +45,46 @@ static bool accessChildren(Iterator* it, function<bool(const Paint* paint)> func
return true;
}
+
/************************************************************************/
/* External Class Implementation */
/************************************************************************/
-unique_ptr<Picture> Accessor::set(unique_ptr<Picture> picture, function<bool(const Paint* paint)> func) noexcept
+TVG_DEPRECATED unique_ptr<Picture> Accessor::set(unique_ptr<Picture> picture, function<bool(const Paint* paint)> func) noexcept
+{
+ auto backward = [](const tvg::Paint* paint, void* data) -> bool
+ {
+ auto func = reinterpret_cast<function<bool(const Paint* paint)>*>(data);
+ if (!(*func)(paint)) return false;
+ return true;
+ };
+
+ set(picture.get(), backward, reinterpret_cast<void*>(&func));
+ return picture;
+}
+
+
+Result Accessor::set(const Picture* picture, function<bool(const Paint* paint, void* data)> func, void* data) noexcept
{
- auto p = picture.get();
- if (!p || !func) return picture;
+ if (!picture || !func) return Result::InvalidArguments;
//Use the Preorder Tree-Search
//Root
- if (!func(p)) return picture;
+ if (!func(picture, data)) return Result::Success;
//Children
- if (auto it = IteratorAccessor::iterator(p)) {
- accessChildren(it, func);
+ if (auto it = IteratorAccessor::iterator(picture)) {
+ accessChildren(it, func, data);
delete(it);
}
- return picture;
+ return Result::Success;
+}
+
+
+uint32_t Accessor::id(const char* name) noexcept
+{
+ return djb2Encode(name);
}