mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-13 19:44:28 +00:00
common: introduce iterator
+++ auto picture = tvg::Picture::gen(); auto func = [](const tvg::Paint* paint, const tvg::Paint* parent, bool hasChildren) -> int { if (paint->identifier() == Shape::identifier()) //TODO: override properties. //return true to continue, return false to stop. return true; }; picture = tvg::Iteratorv::iterate(move(picture), func);
This commit is contained in:
parent
5b3252ecf9
commit
e947fef9a4
4 changed files with 52 additions and 2 deletions
10
inc/thorvg.h
10
inc/thorvg.h
|
@ -1533,6 +1533,14 @@ public:
|
|||
_TVG_DECLARE_PRIVATE(Saver);
|
||||
};
|
||||
|
||||
|
||||
class TVG_EXPORT Iteratorv final
|
||||
{
|
||||
public:
|
||||
static std::unique_ptr<Picture> iterate(std::unique_ptr<Picture> picture, int(*func)(const Paint* paint, const Paint* parent, bool hasChildren)) noexcept;
|
||||
};
|
||||
|
||||
|
||||
/** @}*/
|
||||
|
||||
} //namespace
|
||||
|
@ -1541,4 +1549,4 @@ public:
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif //_THORVG_H_
|
||||
#endif //_THORVG_H_
|
|
@ -30,6 +30,7 @@ source_file = [
|
|||
'tvgFill.cpp',
|
||||
'tvgGlCanvas.cpp',
|
||||
'tvgInitializer.cpp',
|
||||
'tvgIterator.cpp',
|
||||
'tvgLinearGradient.cpp',
|
||||
'tvgLzw.cpp',
|
||||
'tvgLoader.cpp',
|
||||
|
|
|
@ -149,4 +149,4 @@ Result Initializer::term(CanvasEngine engine) noexcept
|
|||
uint16_t THORVG_VERSION_NUMBER()
|
||||
{
|
||||
return _version;
|
||||
}
|
||||
}
|
41
src/lib/tvgIterator.cpp
Normal file
41
src/lib/tvgIterator.cpp
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (c) 2020-2021 Samsung Electronics Co., Ltd. All rights reserved.
|
||||
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "tvgCommon.h"
|
||||
|
||||
/************************************************************************/
|
||||
/* Internal Class Implementation */
|
||||
/************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
/* External Class Implementation */
|
||||
/************************************************************************/
|
||||
|
||||
unique_ptr<Picture> Iteratorv::iterate(unique_ptr<Picture> root, int(*func)(const Paint* paint, const Paint* parent, bool hasChild)) noexcept
|
||||
{
|
||||
//TODO: Preorder traversal
|
||||
|
||||
return nullptr;
|
||||
}
|
Loading…
Add table
Reference in a new issue