Donner SVG 0.8.0-pre
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::svg::PathShape Struct Reference

A path to draw, along with its fill rule and the entity it came from. More...

#include "donner/svg/renderer/RendererInterface.h"

Public Member Functions

const PathpathOrEmpty () const
 Geometry to draw, with a null path reading as the empty path. The returned reference is not bound to this PathShape: it names either the pointee or a shared empty path with static storage, so it stays valid after the view itself goes away.

Public Attributes

const Pathpath = nullptr
 Geometry to draw. Non-owning: the pointee must outlive the draw call, and must not be erased from its storage while borrowed (see the note above this struct). Null is treated as an empty path so a default-constructed PathShape draws nothing.
FillRule fillRule = FillRule::NonZero
EntityHandle sourceEntity
 Source entity this path was derived from. Set by the driver at the drawPath call site (RendererDriver::traverseRange). Backends that cache per-entity state key off this (see GeodePathCacheComponent). A null EntityHandle (the default) means "no associated entity" - non-driver callers (overlay drawing, test harnesses) leave it null and backends fall back to the un-cached path.

Detailed Description

A path to draw, along with its fill rule and the entity it came from.

This is a borrowed view, not an owner: path points at geometry the caller keeps alive. Draw calls take it by const reference and must not retain it past the call, unless the backend has separately established that the pointee stays valid and stays the same geometry for as long as it is retained.

When the geometry lives on a component, "stays valid" is stricter than it looks. Component storage is paged, so inserting other components never moves an existing one, but ERASING one is swap-and-pop: the last element is moved into the erased slot. A pointer into a component that is erased while borrowed therefore does not dangle into freed memory, it silently starts naming a different entity's geometry. That renders the wrong shape with no crash, and neither ASAN nor a sanitizer build will flag it. The precondition for any borrow held across statements is therefore: no component of that type is erased between the borrow and its last use. Draw traversal satisfies this because every removal site runs outside it.

Passing a borrowed path instead of a copy is what keeps a steady-state frame free of per-drawable path allocations: the driver hands every backend a pointer straight at the entity's resolved geometry.


The documentation for this struct was generated from the following file: