blob: 966206bdf068656dcff12427810ff1d4e7a15cdb [file] [log] [blame]
#ifndef _RIVE_PATH_HPP_
#define _RIVE_PATH_HPP_
#include "rive/command_path.hpp"
#include "rive/generated/shapes/path_base.hpp"
#include "rive/math/mat2d.hpp"
#include <vector>
namespace rive {
class Shape;
class PathVertex;
/// Optionally compiled in for tools that need to compute per frame world
/// transformed path vertices. These should not be used at runtime as it's
/// not optimized for performance (it does a lot of memory allocation).
/// A flattened path is composed of only linear
/// and cubic vertices. No corner vertices and it's entirely in world space.
/// This is helpful for getting a close to identical representation of the
/// vertices used to issue the high level path draw commands.
class FlattenedPath {
std::vector<PathVertex*> m_Vertices;
const std::vector<PathVertex*>& vertices() const { return m_Vertices; }
void addVertex(PathVertex* vertex, const Mat2D& transform);
class Path : public PathBase {
Shape* m_Shape = nullptr;
std::unique_ptr<CommandPath> m_CommandPath;
std::vector<PathVertex*> m_Vertices;
Shape* shape() const { return m_Shape; }
StatusCode onAddedClean(CoreContext* context) override;
void buildDependencies() override;
virtual const Mat2D& pathTransform() const;
CommandPath* commandPath() const { return m_CommandPath.get(); }
void update(ComponentDirt value) override;
void addVertex(PathVertex* vertex);
virtual void markPathDirty();
virtual bool isPathClosed() const { return true; }
void onDirty(ComponentDirt dirt) override;
FlattenedPath* makeFlat(bool transformToParent);
#ifdef TESTING
std::vector<PathVertex*>& vertices() { return m_Vertices; }
// pour ourselves into a command-path
void buildPath(CommandPath&) const;
} // namespace rive