Donner SVG Editor & Engine
SVG-native editor and embeddable SVG2 + CSS3 engine in C++20, with GPU (WebGPU) and compact CPU renderers, built for correctness, security, and performance.
Loading...
Searching...
No Matches
OverlayRenderer.h File Reference

OverlayRenderer draws editor chrome (currently selection path outlines) directly into the renderer's existing framebuffer using the canvas primitives RendererInterface already exposes. It is not a separate compositing layer and not a fabricated SVG subtree - chrome and document share one render target so there is no subpixel drift between them. More...

#include <array>
#include <optional>
#include <span>
#include <vector>
#include "donner/base/Box.h"
#include "donner/base/FillRule.h"
#include "donner/base/Path.h"
#include "donner/base/Transform.h"
#include "donner/css/Color.h"
#include "donner/svg/SVGElement.h"
Include dependency graph for OverlayRenderer.h:
This graph shows which files directly or indirectly include this file:

Classes

struct  donner::editor::SelectionChromeBoundsPreview
 Active transform bounds chrome. Used while rotating to draw the gesture-start selection box transformed into the current document space. More...
struct  donner::editor::LockedRejectionFlashInput
 Locked-rejection flash input for OverlayRenderer::captureChromeSnapshot. Carries the rejected (locked) element whose outline should flash red plus the current fade intensity. Kept as a dedicated struct (rather than a dependency on SelectTool::LockedRejectionFlash) so the overlay renderer stays decoupled from the tool layer. More...
struct  donner::editor::SelectionChromeSnapshot
 Frozen view of everything OverlayRenderer::drawChromeWithTransform would normally read off the live registry: per-element path splines transformed into document space, per-element AABBs in document space, and the optional marquee rect. More...
struct  donner::editor::SelectionChromeSnapshot::OrientedBox
 Four document-space corners of an oriented selection box. More...
struct  donner::editor::SelectionChromeSnapshot::PathItem
 One entry per renderable geometry leaf in the selection (groups are expanded into their geometry descendants, same as the live path). Empty when nothing's selected. More...
struct  donner::editor::SelectionChromeSnapshot::PathControlLine
 Document-space Bezier handle guide line for selected SVG paths. More...
struct  donner::editor::SelectionChromeSnapshot::LockedFlash
 Transient "this element is locked, you can't select it" feedback. When present, the rejected (locked) element's outline is stroked in red with alpha scaled by intensity (1 → 0 as the flash fades). Captured from SelectTool::lockedRejectionFlash(). More...
struct  donner::editor::SelectionChromeSnapshot::LivePathPreview
 Live document-geometry preview of the path the Pen tool is actively authoring or point-editing. Drawn beneath the selection chrome with the path's own resolved solid paint, so the presented pixels for the edited path come from the same post-flush DOM capture as the chrome - they never wait for the async raster of the new geometry. While this is present the presenter suppresses the path's stale composited layer tile (ShouldPresentCompositedTile), otherwise the old geometry would show through underneath the preview. More...
struct  donner::editor::SelectionChromeSnapshot::TextCaret
 Text-editing caret for the in-canvas text session: document-space endpoints of the caret bar (top, bottom). More...
struct  donner::editor::SelectionChromeSnapshot::TextBoxDragPreview
 Drag-to-create text-box preview: the live rectangle the text tool is dragging out, plus the first baseline it would create and an I-beam marker at the future caret position. Drawn as dedicated text-box chrome (crisp frame + guidance baseline + I-beam), visually distinct from the selection marquee's translucent fill + white outline. More...
struct  donner::editor::SelectionChromeSnapshot::TextBaseline
 One baseline segment of a selected text run, in document space. More...
class  donner::editor::OverlayRenderer

Namespaces

namespace  donner
 Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.
namespace  donner::svg
 Donner SVG library, which can load, manipulate and render SVG files.

Enumerations

enum class  donner::editor::SelectionChromeDetail {
  Full ,
  PathOutlinesOnly ,
  CombinedBoundsOnly ,
  EditingChromeOnly
}
 Detail level used when capturing selection chrome. More...

Detailed Description

OverlayRenderer draws editor chrome (currently selection path outlines) directly into the renderer's existing framebuffer using the canvas primitives RendererInterface already exposes. It is not a separate compositing layer and not a fabricated SVG subtree - chrome and document share one render target so there is no subpixel drift between them.

See docs/design_docs/0020-editor.md "OverlayRenderer uses direct canvas- style Renderer calls" for the architectural rationale and the primitive policy.

Usage:

renderer.draw(editor.document().document());
const auto bitmap = renderer.takeSnapshot(); // contains chrome
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....

Must be called after Renderer::draw(document) (which has its own internal beginFrame / endFrame cycle) and before Renderer::takeSnapshot(). The renderer's frame pixmap survives across endFrame so additional canvas commands compose onto it directly.


Class Documentation

◆ donner::editor::SelectionChromeSnapshot::OrientedBox

struct donner::editor::SelectionChromeSnapshot::OrientedBox

Four document-space corners of an oriented selection box.

Class Members
array< Vector2d, 4 > cornersDoc

◆ donner::editor::SelectionChromeSnapshot::PathItem

struct donner::editor::SelectionChromeSnapshot::PathItem

One entry per renderable geometry leaf in the selection (groups are expanded into their geometry descendants, same as the live path). Empty when nothing's selected.

Class Members
bool displayNone = false True when the selected element is hidden by display:none. The path outline still renders as an editable placeholder, but uses a dimmer stroke than visible selections.
Path pathDoc Document-space path data sampled at capture time. Keeping the path in document space lets chrome stroke width depend only on viewport scale, not on the selected element's own scale/rotation transform.

◆ donner::editor::SelectionChromeSnapshot::PathControlLine

struct donner::editor::SelectionChromeSnapshot::PathControlLine

Document-space Bezier handle guide line for selected SVG paths.

Class Members
Vector2d anchorDoc = Vector2d() Anchor endpoint of the control line.
Vector2d controlDoc = Vector2d() Control-point endpoint of the control line.

◆ donner::editor::SelectionChromeSnapshot::LockedFlash

struct donner::editor::SelectionChromeSnapshot::LockedFlash

Transient "this element is locked, you can't select it" feedback. When present, the rejected (locked) element's outline is stroked in red with alpha scaled by intensity (1 → 0 as the flash fades). Captured from SelectTool::lockedRejectionFlash().

Class Members
float intensity = 0.0f Fade intensity in (0, 1]; scales the red stroke's alpha.
Path pathDoc Document-space path of the rejected (locked) element, sampled at capture time - same document-space convention as PathItem::pathDoc.

◆ donner::editor::SelectionChromeSnapshot::LivePathPreview

struct donner::editor::SelectionChromeSnapshot::LivePathPreview

Live document-geometry preview of the path the Pen tool is actively authoring or point-editing. Drawn beneath the selection chrome with the path's own resolved solid paint, so the presented pixels for the edited path come from the same post-flush DOM capture as the chrome - they never wait for the async raster of the new geometry. While this is present the presenter suppresses the path's stale composited layer tile (ShouldPresentCompositedTile), otherwise the old geometry would show through underneath the preview.

Only solid (or none) fill/stroke paints are representable; capture skips the preview (leaving nullopt) for gradients/patterns, currentColor, or elements carrying filter/clip-path/mask, and the presenter then falls back to the normal composited raster. The preview composes above all cached tiles, which matches pen authoring (new paths are appended last in paint order).

Class Members
Entity entity = entt::null Entity of the previewed path - the presenter suppresses this entity's composited layer tile while the preview is drawn.
optional< RGBA > fillColor Resolved solid fill color, or nullopt for fill: none.
double fillOpacity = 1.0 fill-opacity multiplier.
FillRule fillRule = FillRule::NonZero Fill rule for the preview fill.
double opacity = 1.0 opacity (group opacity) multiplier.
Path pathDoc Document-space path geometry sampled at capture time.
optional< RGBA > strokeColor Resolved solid stroke color, or nullopt for stroke: none.
double strokeOpacity = 1.0 stroke-opacity multiplier.
double strokeWidthDoc = 1.0 Stroke width in document units.

Enumeration Type Documentation

◆ SelectionChromeDetail

Detail level used when capturing selection chrome.

Enumerator
Full 

Capture visible path outlines plus selection bounds.

PathOutlinesOnly 

Capture visible path outlines only, skipping selection bounds and transform handles.

CombinedBoundsOnly 

Capture only the combined selection bounds, skipping path extraction.

EditingChromeOnly 

Skip selection geometry entirely. Dedicated editing chrome (for example a text caret and session frame) is attached to the snapshot separately.