1 #ifndef _RIVE_PATH_HPP_
2 #define _RIVE_PATH_HPP_
3 #include "rive/command_path.hpp"
4 #include "rive/generated/shapes/path_base.hpp"
5 #include "rive/math/mat2d.hpp"
12 #ifdef ENABLE_QUERY_FLAT_VERTICES
13 /// Optionally compiled in for tools that need to compute per frame world
14 /// transformed path vertices. These should not be used at runtime as it's
15 /// not optimized for performance (it does a lot of memory allocation).
17 /// A flattened path is composed of only linear
18 /// and cubic vertices. No corner vertices and it's entirely in world space.
19 /// This is helpful for getting a close to identical representation of the
20 /// vertices used to issue the high level path draw commands.
23 std::vector<PathVertex*> m_Vertices;
28 const std::vector<PathVertex*>& vertices() const { return m_Vertices; }
29 void addVertex(PathVertex* vertex, const Mat2D& transform);
33 class Path : public PathBase {
35 Shape* m_Shape = nullptr;
36 std::unique_ptr<CommandPath> m_CommandPath;
37 std::vector<PathVertex*> m_Vertices;
40 Shape* shape() const { return m_Shape; }
41 StatusCode onAddedClean(CoreContext* context) override;
42 void buildDependencies() override;
43 virtual const Mat2D& pathTransform() const;
44 CommandPath* commandPath() const { return m_CommandPath.get(); }
45 void update(ComponentDirt value) override;
47 void addVertex(PathVertex* vertex);
49 virtual void markPathDirty();
50 virtual bool isPathClosed() const { return true; }
51 void onDirty(ComponentDirt dirt) override;
52 #ifdef ENABLE_QUERY_FLAT_VERTICES
53 FlattenedPath* makeFlat(bool transformToParent);
57 std::vector<PathVertex*>& vertices() { return m_Vertices; }
60 // pour ourselves into a command-path
61 void buildPath(CommandPath&) const;