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

Public Types

enum class  ChromeSquare {
  PathAnchor ,
  PathControlPoint ,
  TransformHandle
}
 Chrome squares whose on-screen size is fixed, and therefore resolved against the transform the chrome is drawn with rather than stored. More...

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(), const std::optional< LockedRejectionFlashInput > &lockedFlash=std::nullopt, double devicePixelRatio=1.0, const std::optional< svg::SVGElement > &livePathPreviewElement=std::nullopt)
 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 interaction feedback. An active scale/rotate preview derives oriented bounds and handles directly from gesture-owned geometry without traversing the selection.
static Box2d ChromeSquareForPoint (const SelectionChromeSnapshot &snapshot, ChromeSquare kind, const Vector2d &pointDoc)
 Document-space square for one chrome point, sized for snapshot's current canvasFromDoc.
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 Enumeration Documentation

◆ ChromeSquare

Chrome squares whose on-screen size is fixed, and therefore resolved against the transform the chrome is drawn with rather than stored.

Enumerator
PathAnchor 

Selected-path vertex anchor square.

PathControlPoint 

Selected-path Bezier control-point square.

TransformHandle 

Selection resize/rotate corner handle square.

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(),
const std::optional< LockedRejectionFlashInput > & lockedFlash = std::nullopt,
double devicePixelRatio = 1.0,
const std::optional< svg::SVGElement > & livePathPreviewElement = std::nullopt )
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 interaction feedback. An active scale/rotate preview derives oriented bounds and handles directly from gesture-owned geometry without traversing the selection.

Parameters
devicePixelRatioViewport framebuffer scale used to convert logical UI stroke widths into device pixels.

The returned snapshot is movable and self- contained: it holds no registry pointers and survives any subsequent registry mutation.

Parameters
livePathPreviewElementWhen set, the element the Pen tool is actively editing: its live document-space geometry and resolved solid paint are captured into SelectionChromeSnapshot::livePathPreview so the draw phase can present the edited path from the same DOM capture as the chrome. Skipped (nullopt in the snapshot) when the element's paint cannot be represented as a solid preview.

◆ ChromeSquareForPoint()

Box2d donner::editor::OverlayRenderer::ChromeSquareForPoint ( const SelectionChromeSnapshot & snapshot,
ChromeSquare kind,
const Vector2d & pointDoc )
staticnodiscard

Document-space square for one chrome point, sized for snapshot's current canvasFromDoc.

Consumers outside the draw path (the SVG viewport export) resolve their geometry through this so it matches the drawn chrome exactly.

Parameters
snapshotSnapshot supplying the transform and device pixel ratio.
kindWhich chrome square to size.
pointDocDocument-space center of the square.

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