Donner SVG 0.8.0
0.8.0 ยท ebf353960.8.0 main
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)
 Construct rendering and presentation coordination for the selected backend.
AsyncRenderer & asyncRenderer ()
 Expose the background render worker.
const AsyncRenderer & asyncRenderer () const
 Return the background render worker.
void setSchedulingClockForTesting (std::function< std::chrono::steady_clock::time_point()> clock)
 Replace the steady clock behind the coordinator's scheduling windows: the canvas-size commit throttle, the raster-viewport settle window, the pixel-capture commit wake and the nothing-to-present retry pacing.
svg::Renderer & renderer ()
 Expose the renderer owned by the worker bundle.
const SelectionBoundsCache & selectionBoundsCache () const
 Return cached selection bounds and their document versions.
CompositedPresentation & compositedPresentation ()
 Expose composited presentation state for the UI thread.
const CompositedPresentation & compositedPresentation () const
 Return composited presentation state.
std::uint64_t displayedDocVersion () const
 Return the document version last accepted for visible presentation.
const FrameCostBreakdown & lastFrameCostBreakdown () 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. The request is a new one even if an identical earlier request is being held back.
void setDocumentPixelCaptureEnabled (bool enabled)
 Arm or disarm the worker-owned document pixel capture.
void setPointerTargetCaptureEnabled (bool enabled)
 Include immutable mouse targets in subsequent Preview renders.
bool documentPixelCaptureEnabled () const
 Whether an editor session currently retains or requests document pixels.
const DocumentPixelCapture * documentPixelCaptureFor (const EditorApp &app, const ViewportState &viewport) const
 Current capture, or null when the worker result has not matched the live presentation.
bool documentPixelCaptureUnavailable () const
 True when the current capture attempt completed without a usable bitmap.
std::optional< float > nextPixelCaptureCanvasCommitWakeSeconds () const
 Wake deadline for an armed picker waiting on a delayed semantic canvas-size commit.
std::optional< float > nextViewportSettleWakeSeconds ()
 Seconds until deferred viewport work is eligible, absent while its worker is busy. Registers a completion wake before hiding a deadline behind speculative warmup.
bool hasPendingViewportSettle () const
 Pure pending-work observation, including deadlines hidden behind a busy worker.
std::optional< float > nextNothingToPresentRetryWakeSeconds () const
 Wake deadline for the paced re-render of a request whose result had nothing to present.
bool presentationRefreshPending () const
 Whether a renderer-presentation setting still needs a worker frame.
bool frameRepairPending () const
 Request a missing coherent frame without invalidating already-running work.
bool frameRepresentsCurrentIntent () const
 Whether the sealed frame represents the input considered by the latest UI 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.
void setPenLivePreviewGeometry (std::shared_ptr< const Path > geometry)
 Latest owning element-space path, consumed with the cached pen paint and selection identity.
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< CapturedPresentation::TextEditing > text)
 Retain a text annotation together with the exact layout state used to measure it.
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)
 Refresh selected-element bounds from the live document, or clear them if no document exists.
void promoteSelectionBoundsIfReady ()
 Promote pending selection bounds once their document version is displayed.
void requestSelectionGeometryRefresh ()
 Request annotation geometry from the next safe state matching the accepted raster.
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, bool pendingCanvasSelectionPress=false)
 Post a worker render when document, viewport, and presentation state require one.
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.
std::shared_ptr< const FramePresentation > buildFramePresentation (EditorApp &app, SelectTool &tool, const ViewportState &viewport, const Box2d &paneClipRect, SelectionChromeDetail detail, bool includeChrome=true, FramePresentationAdmission admit={})
 Seal the resource, object-pose and selection decision used by every draw pass this frame.
std::shared_ptr< const FramePresentation > framePresentation () const
 Last installed immutable frame, retained for diagnostics and render callbacks.
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 nothingToPresentResultTotalForDiagnostics () const
 Cumulative count of worker results that had nothing to present. Diagnostics only: a count that keeps rising under a frozen canvas names a renderer that produces nothing, not a stalled worker.
Entity selectedCompositedEntityForDiagnostics (EditorApp &app) const
 Selected entity eligible for composited presentation for replay diagnostics.

Friends

class EditorShellTestAccess
struct RenderCoordinatorTestAccess

Detailed Description

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

Constructor & Destructor Documentation

◆ RenderCoordinator()

donner::editor::RenderCoordinator::RenderCoordinator ( std::shared_ptr<::donner::geode::GeodeDevice > geodeDevice = nullptr)
explicit

Construct rendering and presentation coordination for the selected backend.

Parameters
geodeDeviceShared Geode device, or null for a non-Geode renderer.

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()

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.

◆ maybeRequestRender()

bool donner::editor::RenderCoordinator::maybeRequestRender ( EditorApp & app,
SelectTool & selectTool,
const ViewportState & viewport,
GlTextureCache * textures = nullptr,
bool supersedeInFlight = false,
SelectionChromeDetail directSurfaceSelectionDetail = SelectionChromeDetail::Full,
bool pendingCanvasSelectionPress = false )

Post a worker render when document, viewport, and presentation state require one.

Parameters
appEditor application and current document.
selectToolActive drag and selection preview source.
viewportDesired canvas and raster viewport.
texturesOptional cache for viewport-coverage diagnostics.
supersedeInFlightWhether an in-flight worker render may be replaced.
directSurfaceSelectionDetailReserved; scheduling currently ignores this value.
pendingCanvasSelectionPressBuffered canvas selection input not yet consumed by the tool.
Returns
True only when a new worker request was posted.

◆ 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.

◆ refreshSelectionBoundsCache()

void donner::editor::RenderCoordinator::refreshSelectionBoundsCache ( EditorApp & app)

Refresh selected-element bounds from the live document, or clear them if no document exists.

Parameters
appEditor application holding the current selection.

◆ 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.

◆ setPenLivePreviewGeometry()

void donner::editor::RenderCoordinator::setPenLivePreviewGeometry ( std::shared_ptr< const Path > geometry)
inline

Latest owning element-space path, consumed with the cached pen paint and selection identity.

Parameters
geometryOwning path geometry, or nullptr to retire the current preview.

◆ setPointerTargetCaptureEnabled()

void donner::editor::RenderCoordinator::setPointerTargetCaptureEnabled ( bool enabled)
inline

Include immutable mouse targets in subsequent Preview renders.

Parameters
enabledWhether to capture hit geometry alongside document pixels.

◆ setSchedulingClockForTesting()

void donner::editor::RenderCoordinator::setSchedulingClockForTesting ( std::function< std::chrono::steady_clock::time_point()> clock)
inline

Replace the steady clock behind the coordinator's scheduling windows: the canvas-size commit throttle, the raster-viewport settle window, the pixel-capture commit wake and the nothing-to-present retry pacing.

A deterministic replay drives it from recorded frame time so those windows close on the same frame on every run, however fast the host runs the frames. Install it before the coordinator schedules anything: time points already recorded on one clock are not rebased onto the other.

Parameters
clockClock to read, or an empty function to restore the steady clock.

◆ 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.

◆ setTextEditingChrome()

void donner::editor::RenderCoordinator::setTextEditingChrome ( std::optional< CapturedPresentation::TextEditing > text)
inline

Retain a text annotation together with the exact layout state used to measure it.

Parameters
textCaptured text geometry, or null to end the editing annotation.

◆ 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: