Donner 0.8.0-pre
Embeddable browser-grade SVG2 engine
Loading...
Searching...
No Matches
donner::editor::OverlayRenderer Class Reference

Static Public Member Functions

static void drawChrome (svg::RendererInterface &renderer, const EditorApp &editor)
 Draw all editor chrome layers for the current state of editor into renderer's active frame. No-op if there is no document or no selection. Pulls the canvasFromDocument transform from the editor's document so chrome lands on the same pixels as the rendered content, regardless of canvas/viewBox aspect mismatch.
static void drawChrome (svg::RendererInterface &renderer, const std::optional< svg::SVGElement > &selection)
 Overload that takes a selection snapshot directly. Single-element back-compat shim — kept so worker-thread callers and existing tests don't have to switch to spans. Identity canvasFromDoc.
static void drawChromeWithTransform (svg::RendererInterface &renderer, const std::optional< svg::SVGElement > &selection, const Transform2d &canvasFromDoc)
 Lower-level single-element entry: draw chrome for selection (or none) using canvasFromDoc. Kept for back-compat with the existing single-select call sites.
static void drawChromeWithTransform (svg::RendererInterface &renderer, std::span< const svg::SVGElement > selection, const std::optional< Box2d > &marqueeRectDoc, const Transform2d &canvasFromDoc, const std::optional< SelectionChromeBoundsPreview > &activeBoundsPreview=std::nullopt, std::span< const svg::SVGElement > sourceHover={}, const std::optional< Box2d > &cullRectDoc=std::nullopt, SelectionChromeDetail selectionDetail=SelectionChromeDetail::Full, const Transform2d &representedDocumentFromLiveDocument=Transform2d())
 Multi-element entry: draw path outlines for every selected element, selection AABBs, and the optional marquee rect into renderer's active frame using canvasFromDoc.
static void drawChromeWithTransform (svg::RendererInterface &renderer, std::span< const svg::SVGElement > selection, const Transform2d &canvasFromDoc)
 Back-compat overload without marquee. Kept for existing callers that don't need a marquee rect (older tests, worker-thread helpers). Path outlines + selection AABBs are still drawn.
static SelectionChromeSnapshot captureChromeSnapshot (std::span< const svg::SVGElement > selection, const std::optional< Box2d > &marqueeRectDoc, const Transform2d &canvasFromDoc, const std::optional< SelectionChromeBoundsPreview > &activeBoundsPreview=std::nullopt, std::span< const svg::SVGElement > sourceHover={}, const std::optional< Box2d > &cullRectDoc=std::nullopt, SelectionChromeDetail selectionDetail=SelectionChromeDetail::Full, const Transform2d &representedDocumentFromLiveDocument=Transform2d())
 Build a SelectionChromeSnapshot for the given selection + marquee + canvas transform. Reads computedSpline, elementFromWorld, and SnapshotSelectionWorldBounds for every selected element — MUST be called when the worker is idle or otherwise not mutating these components on the same registry. When cullRectDoc is present, path outlines, AABBs, and handles fully outside that document-space rect are skipped before draw. CombinedBoundsOnly skips selected path extraction and stores one combined bounds box for low-latency large-selection feedback.
static void drawChromeFromSnapshot (svg::RendererInterface &renderer, const SelectionChromeSnapshot &snapshot)
 Race-free chrome rasterize: reads only the snapshot, never the registry. Safe to call while the async-renderer worker is mid-render.

Member Function Documentation

◆ captureChromeSnapshot()

SelectionChromeSnapshot donner::editor::OverlayRenderer::captureChromeSnapshot ( std::span< const svg::SVGElement > selection,
const std::optional< Box2d > & marqueeRectDoc,
const Transform2d & canvasFromDoc,
const std::optional< SelectionChromeBoundsPreview > & activeBoundsPreview = std::nullopt,
std::span< const svg::SVGElement > sourceHover = {},
const std::optional< Box2d > & cullRectDoc = std::nullopt,
SelectionChromeDetail selectionDetail = SelectionChromeDetail::Full,
const Transform2d & representedDocumentFromLiveDocument = Transform2d() )
staticnodiscard

Build a SelectionChromeSnapshot for the given selection + marquee + canvas transform. Reads computedSpline, elementFromWorld, and SnapshotSelectionWorldBounds for every selected element — MUST be called when the worker is idle or otherwise not mutating these components on the same registry. When cullRectDoc is present, path outlines, AABBs, and handles fully outside that document-space rect are skipped before draw. CombinedBoundsOnly skips selected path extraction and stores one combined bounds box for low-latency large-selection feedback.

Design doc 0033 §M7. Returned snapshot is movable and self- contained: it holds no registry pointers and survives any subsequent registry mutation.

◆ drawChromeFromSnapshot()

void donner::editor::OverlayRenderer::drawChromeFromSnapshot ( svg::RendererInterface & renderer,
const SelectionChromeSnapshot & snapshot )
static

Race-free chrome rasterize: reads only the snapshot, never the registry. Safe to call while the async-renderer worker is mid-render.

Produces byte-identical pixels to drawChromeWithTransform(selection, marqueeRectDoc, canvasFromDoc) given the same input snapshot — pinned by OverlayRendererTest.SnapshotProducesByteIdenticalPixels.

◆ drawChromeWithTransform()

void donner::editor::OverlayRenderer::drawChromeWithTransform ( svg::RendererInterface & renderer,
std::span< const svg::SVGElement > selection,
const std::optional< Box2d > & marqueeRectDoc,
const Transform2d & canvasFromDoc,
const std::optional< SelectionChromeBoundsPreview > & activeBoundsPreview = std::nullopt,
std::span< const svg::SVGElement > sourceHover = {},
const std::optional< Box2d > & cullRectDoc = std::nullopt,
SelectionChromeDetail selectionDetail = SelectionChromeDetail::Full,
const Transform2d & representedDocumentFromLiveDocument = Transform2d() )
static

Multi-element entry: draw path outlines for every selected element, selection AABBs, and the optional marquee rect into renderer's active frame using canvasFromDoc.

This renderer-backed path is kept for pixel tests and non-editor callers. The live editor presentation path captures the same snapshot, then draws it immediately through RenderPanePresenter to avoid allocating and uploading a full overlay texture.

AABBs are computed inline from selection (via SnapshotSelectionWorldBounds) at overlay-draw time so they always match the current DOM snapshot — same source of truth as the per-element path outlines. This avoids the frame-lag-shear that happened when AABBs came from a separately-promoted cache while the path outlines came from the live DOM.

Parameters
selectionSelected elements whose per-element path outlines
  • AABBs should be drawn.
marqueeRectDocOptional marquee rect in document space; drawn as a filled + stroked rectangle matching the prior ImGui chrome style.
canvasFromDocMaps document coordinates into canvas pixels.
cullRectDocOptional document-space cull rect. Chrome fully outside this rect is skipped before draw.
selectionDetailDetail level for selected-element chrome.

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