Donner SVG main
0.8.0 ยท 382bd0190.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::svg::components::RenderingContext Class Reference

Rendering controller, which instantiates and and manages the rendering tree. More...

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

Classes

struct  HitGeometry
 Evaluated pointer-event geometry shared by live queries and immutable frame captures. More...
struct  HitRecord
 Owned geometry and internal target identity in front-to-back paint order. More...
struct  FeImageSubtreeResult
 Result from createFeImageShadowTree. More...

Public Types

using InitialPaintState
 Owned paint state saved and restored under a sub-document's write guard.

Public Member Functions

std::optional< std::vector< HitRecord > > captureHitGeometry (std::size_t maximumRecords=65536, std::size_t maximumPathBytes=32 *1024 *1024)
 Capture bounded hit geometry; nullopt rejects the whole snapshot on budget exhaustion.
 RenderingContext (Registry &registry)
 Constructor.
void instantiateRenderTree (bool verbose, ParseWarningSink &warningSink)
 Create the render tree for the document, optionally returning parse warnings found when parsing deferred parts of the tree.
void ensureComputedComponents (ParseWarningSink &warningSink)
 Create all computed components needed for text/layout/style queries without instantiating render instances.
Entity findIntersecting (const Vector2d &point, HitTestMode mode=HitTestMode::SvgPointerEvents)
 Find the first entity that intersects the given point, using spatial acceleration when the document has enough elements.
std::vector< Entity > findAllIntersecting (const Vector2d &point, HitTestMode mode=HitTestMode::SvgPointerEvents)
 Find all entities that intersect the given point, ordered front-to-back.
std::vector< Entity > findIntersectingRect (const Box2d &rect)
 Find all entities whose world-space bounds intersect the given rectangle, ordered front-to-back.
std::optional< Box2d > getWorldBounds (Entity entity)
 Get the world-space bounding box of an entity (fill bounds only, not including stroke).
void invalidateRenderTree ()
 Invalidate the rendering tree, forcing it to be recreated on the next render.
std::optional< FeImageSubtreeResult > createFeImageShadowTree (Entity hostEntity, Entity targetEntity, bool verbose)
 Create a shadow tree for an feImage fragment reference, allowing elements inside <defs> to be rendered offscreen.
void setInitialContextPaint (const ResolvedPaintServer &fill, const ResolvedPaintServer &stroke)
 Set initial context-fill and context-stroke values for sub-document rendering.
void clearInitialContextPaint ()
 Clear previously set context-fill and context-stroke values.
InitialPaintState initialPaintState () const
 Return the owned context paints for restoration after a scoped external-use render.
void restoreInitialPaintState (InitialPaintState state)
 Restore the state that preceded a scoped external-use occurrence.

Static Public Member Functions

static Entity EventTargetEntity (const Registry &registry, Entity entity)
 Map a rendered entity to the document-tree element that receives its pointer events.

Detailed Description

Rendering controller, which instantiates and and manages the rendering tree.

Used during the rendering phase in combination with the rendering backend.


Class Documentation

◆ donner::svg::components::RenderingContext::HitRecord

struct donner::svg::components::RenderingContext::HitRecord

Owned geometry and internal target identity in front-to-back paint order.

Class Members
Entity entity = entt::null
HitGeometry geometry
Path path

◆ donner::svg::components::RenderingContext::FeImageSubtreeResult

struct donner::svg::components::RenderingContext::FeImageSubtreeResult

Result from createFeImageShadowTree.

Class Members
Entity firstEntity First entity in the shadow subtree.
Entity lastEntity Last entity in the shadow subtree.

Member Typedef Documentation

◆ InitialPaintState

Initial value:
std::pair<std::optional<ResolvedPaintServer>, std::optional<ResolvedPaintServer>>

Owned paint state saved and restored under a sub-document's write guard.

Member Function Documentation

◆ captureHitGeometry()

std::optional< std::vector< HitRecord > > donner::svg::components::RenderingContext::captureHitGeometry ( std::size_t maximumRecords = 65536,
std::size_t maximumPathBytes = 32 *1024 *1024 )

Capture bounded hit geometry; nullopt rejects the whole snapshot on budget exhaustion.

Parameters
maximumRecordsLowerable instance budget, capped at 65536.
maximumPathBytesLowerable path-storage budget, capped at 32 MiB.

◆ clearInitialContextPaint()

void donner::svg::components::RenderingContext::clearInitialContextPaint ( )

Clear previously set context-fill and context-stroke values.

Call after rendering a sub-document to prevent stale context paint from leaking to subsequent renders of the same cached sub-document handle.

◆ ensureComputedComponents()

void donner::svg::components::RenderingContext::ensureComputedComponents ( ParseWarningSink & warningSink)

Create all computed components needed for text/layout/style queries without instantiating render instances.

Parameters
warningSinkSink to collect warnings.

◆ EventTargetEntity()

Entity donner::svg::components::RenderingContext::EventTargetEntity ( const Registry & registry,
Entity entity )
static

Map a rendered entity to the document-tree element that receives its pointer events.

Content instantiated by <use> lives in a shadow tree that is rebuilt with the render tree. As in SVG 2, events on those instances target the <use> element, the outermost one for nested instances. Offscreen content (patterns, masks, markers and feImage fragments) is painted as part of the element that references it and receives no events.

Parameters
registryRegistry holding entity.
entityRendered entity, such as a hit returned by findIntersecting.
Returns
The document-tree entity, or entt::null for offscreen content.

◆ findAllIntersecting()

std::vector< Entity > donner::svg::components::RenderingContext::findAllIntersecting ( const Vector2d & point,
HitTestMode mode = HitTestMode::SvgPointerEvents )

Find all entities that intersect the given point, ordered front-to-back.

Parameters
pointPoint to find intersecting entities for
modeHit eligibility policy.

◆ findIntersecting()

Entity donner::svg::components::RenderingContext::findIntersecting ( const Vector2d & point,
HitTestMode mode = HitTestMode::SvgPointerEvents )

Find the first entity that intersects the given point, using spatial acceleration when the document has enough elements.

Offscreen content is never hit; a hit on <use> content returns its shadow entity, see EventTargetEntity.

Parameters
pointPoint to find the intersecting entity for
modeHit eligibility policy.

◆ findIntersectingRect()

std::vector< Entity > donner::svg::components::RenderingContext::findIntersectingRect ( const Box2d & rect)

Find all entities whose world-space bounds intersect the given rectangle, ordered front-to-back.

Uses the spatial grid for acceleration when available.

Parameters
rectRectangle in world coordinates to test intersection against

◆ getWorldBounds()

std::optional< Box2d > donner::svg::components::RenderingContext::getWorldBounds ( Entity entity)

Get the world-space bounding box of an entity (fill bounds only, not including stroke).

Parameters
entityEntity to get bounds for
Returns
The world-space AABB, or std::nullopt if the entity has no shape

◆ instantiateRenderTree()

void donner::svg::components::RenderingContext::instantiateRenderTree ( bool verbose,
ParseWarningSink & warningSink )

Create the render tree for the document, optionally returning parse warnings found when parsing deferred parts of the tree.

Parameters
verboseIf true, enable verbose logging.
warningSinkSink to collect warnings.

◆ setInitialContextPaint()

void donner::svg::components::RenderingContext::setInitialContextPaint ( const ResolvedPaintServer & fill,
const ResolvedPaintServer & stroke )

Set initial context-fill and context-stroke values for sub-document rendering.

When a <use> element references an external SVG, the <use> element's resolved fill and stroke become the initial context-fill/context-stroke in the sub-document.

Parameters
fillInitial context-fill value.
strokeInitial context-stroke value.

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