1 #include "shapes/shape.hpp"
2 #include "shapes/clipping_shape.hpp"
3 #include "shapes/paint/blend_mode.hpp"
4 #include "shapes/paint/shape_paint.hpp"
5 #include "shapes/path_composer.hpp"
10 void Shape::addPath(Path* path)
12 // Make sure the path is not already in the shape.
13 assert(std::find(m_Paths.begin(), m_Paths.end(), path) == m_Paths.end());
14 m_Paths.push_back(path);
17 void Shape::update(ComponentDirt value)
21 if (hasDirt(value, ComponentDirt::RenderOpacity))
23 for (auto shapePaint : m_ShapePaints)
25 shapePaint->renderOpacity(renderOpacity());
30 void Shape::pathChanged()
32 m_PathComposer->addDirt(ComponentDirt::Path, true);
33 invalidateStrokeEffects();
36 void Shape::pathComposer(PathComposer* value) { m_PathComposer = value; }
37 void Shape::draw(Renderer* renderer)
39 auto shouldRestore = clip(renderer);
41 for (auto shapePaint : m_ShapePaints)
43 if (!shapePaint->isVisible())
49 (shapePaint->pathSpace() & PathSpace::Local) == PathSpace::Local;
52 const Mat2D& transform = worldTransform();
53 renderer->transform(transform);
55 shapePaint->draw(renderer,
56 paintsInLocal ? m_PathComposer->localPath()
57 : m_PathComposer->worldPath());
67 void Shape::buildDependencies()
69 Super::buildDependencies();
71 // Set the blend mode on all the shape paints. If we ever animate this
72 // property, we'll need to update it in the update cycle/mark dirty when the
73 // blend mode changes.
74 for (auto paint : m_ShapePaints)
76 paint->blendMode((BlendMode)blendModeValue());
80 void Shape::addDefaultPathSpace(PathSpace space)
82 m_DefaultPathSpace |= space;