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

Owns the advanced editor's renderer-side orchestration: async rendering, overlay rasterization, composited drag presentation, and selection-bounds cache promotion. More...

#include "donner/editor/RenderCoordinator.h"

Public Member Functions

 RenderCoordinator (std::shared_ptr<::donner::geode::GeodeDevice > geodeDevice=nullptr)
AsyncRendererasyncRenderer ()
const AsyncRendererasyncRenderer () const
svg::Rendererrenderer ()
const SelectionBoundsCacheselectionBoundsCache () const
CompositedPresentationcompositedPresentation ()
const CompositedPresentationcompositedPresentation () const
std::uint64_t displayedDocVersion () const
const FrameCostBreakdownlastFrameCostBreakdown () const
 Latest editor rendering cost counters observed by this coordinator.
std::uint64_t documentCanvasCommitTotal () const
 Document canvas-size commits this coordinator has made since startup.
std::uint64_t overviewInfillRenderTotal () const
 Overview-infill render requests posted since startup.
void requestPresentationRefresh ()
 Request one worker render even when document and viewport epochs are already current.
bool presentationRefreshPending () const
 Whether a renderer-presentation setting still needs a worker frame.
void beginFrameCostTracking ()
 Clear the per-frame cost accumulator before a new UI frame starts.
bool setSourceHoverElements (std::vector< svg::SVGElement > elements)
 Replace transient source-hover chrome elements.
void setLockedRejectionFlash (std::optional< SelectTool::LockedRejectionFlash > flash)
 Update the transient locked-rejection flash to draw on the next overlay capture. The flash fades as SelectTool ticks it; this should be pushed once per frame from the editor's per-frame path with selectTool.lockedRejectionFlash().
bool hasLockedRejectionFlash () const
void setPenLivePreviewElement (std::optional< svg::SVGElement > element)
 Set (or clear) the path element the Pen tool is actively editing. While set, every overlay capture also snapshots the element's live document-space geometry + solid paint into SelectionChromeSnapshot::livePathPreview, so the presented frame shows the edited path from the same DOM capture as the chrome instead of the stale async raster.
const std::optional< svg::SVGElement > & penLivePreviewElement () const
void setPenHoverChrome (std::optional< Path > previewSegmentDoc, std::optional< Vector2d > closeAffordanceDoc)
 Set (or clear) the Pen tool's hover chrome for the next overlay capture: the rubber-band preview of the segment a click would commit, and the close-path affordance point when the pointer is within closing range.
void setTextEditingChrome (std::optional< SelectionChromeSnapshot::TextCaret > caretDoc, std::optional< std::array< Vector2d, 4 > > frameCornersDoc, float frameOpacity=1.0f, std::vector< std::array< Vector2d, 4 > > selectionQuadsDoc={})
 Set (or clear) the text tool's editing chrome for the next overlay capture: the caret bar and the session frame's oriented corners (local TL, TR, BR, BL mapped through the text's transform), in document space.
void setTextBoxDragPreview (std::optional< SelectionChromeSnapshot::TextBoxDragPreview > previewDoc)
 Set (or clear) the text tool's drag-to-create preview chrome for the next overlay capture: the live box being dragged out plus its first baseline and I-beam marker, in document space.
void resetForLoadedDocument (std::uint64_t documentGeneration)
 Reset presentation state after loading a different document.
void refreshSelectionBoundsCache (EditorApp &app)
void promoteSelectionBoundsIfReady ()
bool rasterizeOverlayForCurrentSelection (EditorApp &app, const ViewportState &viewport, const std::optional< Box2d > &marqueeRectDoc, std::optional< SelectTool::ActiveDragPreview > representedDragPreview=std::nullopt, std::optional< SelectTool::ActiveTransformBoundsPreview > activeBoundsPreview=std::nullopt, std::optional< SelectionChromeDetail > selectionDetail=std::nullopt, std::optional< SelectTool::ActiveDragPreview > documentDragPreview=std::nullopt)
 Capture the editor chrome (path outlines, selection AABBs, marquee) for immediate presentation. marqueeRectDoc is the active marquee rectangle in document space (nullopt when the user isn't marquee-dragging). The snapshot remains vector geometry until the presentation layer rasterizes it into the ordered Geode overlay texture.
bool rasterizeOverlayForPresentation (EditorApp &app, SelectTool &selectTool, const ViewportState &viewport, GlTextureCache &textures, std::optional< SelectTool::ActiveDragPreview > activeDragPreview, std::optional< SelectTool::ActiveDragPreview > representedDragPreview, std::optional< SelectionChromeDetail > selectionDetail=std::nullopt, bool allowLiveGeometryOverlay=false)
 Rasterize the current UI-frame overlay immediately before presentation.
void pollRenderResult (EditorApp &app, const ViewportState &viewport, GlTextureCache &textures, FrameHistory *frameHistory=nullptr)
 Drain the latest async-render result into the editor's UI state. If a frameHistory is supplied, its latest slot is stamped with the backend (worker) ms reported by AsyncRenderer so the frame graph can plot backend time alongside ImGui frame time. nullptr is allowed for callers that don't care about backend timing.
bool maybeRequestRender (EditorApp &app, SelectTool &selectTool, const ViewportState &viewport, GlTextureCache *textures=nullptr, bool supersedeInFlight=false, SelectionChromeDetail directSurfaceSelectionDetail=SelectionChromeDetail::Full)
void invalidatePresentationAfterDocumentFlush (const AsyncSVGDocument::FlushResult &flushResult)
 Record that a document mutation requires a current-version presentation handoff.
void invalidatePresentationAfterDocumentFlush (EditorApp &app, const AsyncSVGDocument::FlushResult &flushResult)
 Record document-flush invalidation that depends on the live selected element.
Entity suppressedCompositedLayerEntity (EditorApp &app)
 Return the selected layer whose cached pixels should be hidden while editor chrome remains visible.
bool selectedElementIsDisplayNone (EditorApp &app) const
 Return true when the live selected graphics element is hidden by display:none.
const std::optional< SelectionChromeSnapshot > & immediateOverlaySnapshot () const
 Latest race-free overlay chrome snapshot for immediate screen-space presentation.
std::optional< std::uint64_t > immediateOverlayDocumentVersionForDiagnostics () const
 Document version represented by immediateOverlaySnapshot, if one is currently cached.
Entity pendingSelectedLayerRasterizationEntityForDiagnostics () const
 Pending selected-layer rasterization entity for replay diagnostics.
std::uint64_t pendingSelectedLayerRasterizationVersionForDiagnostics () const
 Pending selected-layer rasterization document version for replay diagnostics.
std::uint64_t displayedDocVersionForDiagnostics () const
 Last document version published to the visible presentation for replay diagnostics.
std::uint64_t overlayVersionGateSuppressionTotalForDiagnostics () const
 Cumulative count of overlay refreshes suppressed because the live document version ran ahead of the displayed presentation. Diagnostics only: lets a browser probe distinguish "selection chrome intentionally hidden" from "selection chrome lost".
Entity selectedCompositedEntityForDiagnostics (EditorApp &app) const
 Selected entity eligible for composited presentation for replay diagnostics.

Detailed Description

Owns the advanced editor's renderer-side orchestration: async rendering, overlay rasterization, composited drag presentation, and selection-bounds cache promotion.

Member Function Documentation

◆ documentCanvasCommitTotal()

std::uint64_t donner::editor::RenderCoordinator::documentCanvasCommitTotal ( ) const
inlinenodiscard

Document canvas-size commits this coordinator has made since startup.

Cumulative, unlike the per-frame counter in FrameCostBreakdown. A commit invalidates the render tree, so it forces a document render that no interaction asked for; the browser suites need to tell that render apart from one an interaction caused before they can assert on render counts, and the commit is evaluated inside a rendered frame, so a commit still pending when the demand-driven loop parks lands on whatever frame the next interaction wakes.

◆ hasLockedRejectionFlash()

bool donner::editor::RenderCoordinator::hasLockedRejectionFlash ( ) const
inlinenodiscard
Returns
true when a locked-rejection flash is currently stored (still fading).

◆ invalidatePresentationAfterDocumentFlush() [1/2]

void donner::editor::RenderCoordinator::invalidatePresentationAfterDocumentFlush ( const AsyncSVGDocument::FlushResult & flushResult)

Record that a document mutation requires a current-version presentation handoff.

Parameters
flushResultMetadata from the just-flushed editor command batch.

◆ invalidatePresentationAfterDocumentFlush() [2/2]

void donner::editor::RenderCoordinator::invalidatePresentationAfterDocumentFlush ( EditorApp & app,
const AsyncSVGDocument::FlushResult & flushResult )

Record document-flush invalidation that depends on the live selected element.

Parameters
appEditor application state containing the live selection.
flushResultMetadata from the just-flushed editor command batch.

◆ overviewInfillRenderTotal()

std::uint64_t donner::editor::RenderCoordinator::overviewInfillRenderTotal ( ) const
inlinenodiscard

Overview-infill render requests posted since startup.

An overview-infill request carries no selection prewarm and no drag: it exists to restore whole-document coverage the presenter is missing, so like a canvas-size commit it is a render the editor owes itself rather than one an interaction asked for. Whether the previous coverage survives an interaction is cache- and timing-dependent, which is why a suite that counts an interaction's renders has to be able to name this one.

◆ penLivePreviewElement()

const std::optional< svg::SVGElement > & donner::editor::RenderCoordinator::penLivePreviewElement ( ) const
inlinenodiscard
Returns
the active pen live-preview element, if any.

◆ rasterizeOverlayForPresentation()

bool donner::editor::RenderCoordinator::rasterizeOverlayForPresentation ( EditorApp & app,
SelectTool & selectTool,
const ViewportState & viewport,
GlTextureCache & textures,
std::optional< SelectTool::ActiveDragPreview > activeDragPreview,
std::optional< SelectTool::ActiveDragPreview > representedDragPreview,
std::optional< SelectionChromeDetail > selectionDetail = std::nullopt,
bool allowLiveGeometryOverlay = false )

Rasterize the current UI-frame overlay immediately before presentation.

Unlike content render scheduling, overlay chrome is intentionally not gated on worker availability: drag, zoom, and marquee feedback must track the viewport used by the presented frame.

◆ resetForLoadedDocument()

void donner::editor::RenderCoordinator::resetForLoadedDocument ( std::uint64_t documentGeneration)

Reset presentation state after loading a different document.

Parameters
documentGenerationGeneration of the newly loaded document.

◆ setLockedRejectionFlash()

void donner::editor::RenderCoordinator::setLockedRejectionFlash ( std::optional< SelectTool::LockedRejectionFlash > flash)

Update the transient locked-rejection flash to draw on the next overlay capture. The flash fades as SelectTool ticks it; this should be pushed once per frame from the editor's per-frame path with selectTool.lockedRejectionFlash().

Parameters
flashActive flash (element + intensity), or nullopt when no element is being rejected.

◆ setSourceHoverElements()

bool donner::editor::RenderCoordinator::setSourceHoverElements ( std::vector< svg::SVGElement > elements)

Replace transient source-hover chrome elements.

Parameters
elementsElements to highlight as source-hover preview chrome.
Returns
true if the hover preview changed.

◆ suppressedCompositedLayerEntity()

Entity donner::editor::RenderCoordinator::suppressedCompositedLayerEntity ( EditorApp & app)
nodiscard

Return the selected layer whose cached pixels should be hidden while editor chrome remains visible.

This is used when the live selected element is display:none: hit-testing and the next render already treat it as non-rendering, so the presenter must not keep drawing a stale promoted texture for that entity. If a source reparse remapped the selected element to a new entity, this returns the currently cached pre-reparse entity so that stale texture is hidden. Deleted selected layers are also suppressed while the next render catches up so detached cached tiles cannot remain visible.

Parameters
appEditor application state containing the live selection.
Returns
Entity whose cached layer should be suppressed, or entt::null if no suppression is needed.

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