|
|
Donner SVG 0.8.0-pre
SVG editor and embeddable C++20 engine.
|
Backend-agnostic rendering interface consumed by RendererDriver during document traversal. More...
#include "donner/svg/renderer/RendererInterface.h"
Public Member Functions | |
| virtual void | draw (SVGDocument &document)=0 |
| Renders the given SVG document. | |
| virtual int | width () const =0 |
| Returns the rendered width in device pixels. | |
| virtual int | height () const =0 |
| Returns the rendered height in device pixels. | |
| virtual void | beginFrameResourceScope () |
| Begins one aggregate resource-budget scope around a controller-managed frame. | |
| virtual void | endFrameResourceScope () |
| Completes a scope opened by beginFrameResourceScope. | |
| virtual void | beginFrame (const RenderViewport &viewport)=0 |
| Begins a render pass with the given viewport. | |
| virtual void | endFrame ()=0 |
| Completes the current render pass, flushing any pending work. | |
| virtual void | setPreserveTargetOnBeginFrame (bool preserve) |
| Preserve the current render target when the next frame begins. | |
| virtual void | setTransform (const Transform2d &transform)=0 |
| Sets the absolute transform on the renderer, replacing the current matrix. | |
| virtual void | pushTransform (const Transform2d &transform)=0 |
| Pushes a transform onto the renderer stack, composing with the current transform. | |
| virtual void | popTransform ()=0 |
| Pops the most recent transform from the renderer stack. | |
| virtual void | pushClip (const ResolvedClip &clip)=0 |
| Pushes a clip path/mask onto the renderer stack. | |
| virtual void | popClip ()=0 |
| Pops the most recent clip from the renderer stack. | |
| virtual void | pushIsolatedLayer (double opacity, MixBlendMode blendMode)=0 |
| Pushes an isolated compositing layer with the given opacity and blend mode. | |
| virtual void | popIsolatedLayer ()=0 |
| Pops the most recent isolated layer, compositing it with the given opacity. | |
| virtual void | pushFilterLayer (const components::FilterGraph &filterGraph, const std::optional< Box2d > &filterRegion)=0 |
| Pushes a filter layer that applies the given filter graph to all content drawn within it. | |
| virtual void | popFilterLayer ()=0 |
| Pops the most recent filter layer. | |
| virtual void | pushMask (const std::optional< Box2d > &maskBounds)=0 |
| Begins mask rendering. | |
| virtual void | transitionMaskToContent ()=0 |
| Transitions from rendering mask content to rendering masked content. | |
| virtual void | popMask ()=0 |
| Pops the mask layer stack, compositing the masked content. | |
| virtual bool | beginPatternTile (const Box2d &tileRect, const Transform2d &targetFromPattern)=0 |
| Begins recording content into a pattern tile. | |
| virtual void | endPatternTile (bool forStroke)=0 |
| Ends pattern tile recording and sets the resulting tiled shader as the current fill or stroke paint. | |
| virtual void | setPaint (const PaintParams &paint)=0 |
| Sets the active paint parameters used by subsequent draw calls. | |
| virtual void | drawPath (const PathShape &path, const StrokeParams &stroke)=0 |
| Draws an arbitrary path using the current paint state. | |
| virtual void | drawRect (const Box2d &rect, const StrokeParams &stroke)=0 |
| Convenience helper for drawing axis-aligned rectangles. | |
| virtual void | drawEllipse (const Box2d &bounds, const StrokeParams &stroke)=0 |
| Convenience helper for drawing ellipses bounded by the provided box. | |
| virtual void | drawImage (const ImageResource &image, const ImageParams ¶ms)=0 |
| Draws an image resource into the given target rectangle. | |
| virtual void | drawBitmap (const RendererBitmap &bitmap, const ImageParams ¶ms) |
| Draws a CPU bitmap (typically a compositor layer/segment raster) into the given target rectangle. | |
| virtual bool | drawTextureSnapshot (const RendererTextureSnapshot &texture, const Box2d &targetRect, double opacity=1.0, bool pixelated=false) |
| Draws a backend-owned texture snapshot into the given target rectangle. | |
| virtual void | drawText (Registry ®istry, const components::ComputedTextComponent &text, const TextParams ¶ms)=0 |
| Draws pre-shaped text with the provided paint parameters. | |
| virtual RendererBitmap | takeSnapshot () const =0 |
| Captures a CPU-readable snapshot of the current frame buffer for testing or downstream consumers. | |
| virtual RendererBitmap | takeSnapshotInterruptibly (const std::function< bool()> &shouldCancel) const |
| Captures a CPU-readable snapshot while allowing a low-priority caller to abort the readback. | |
| virtual RendererReadbackStats | consumeReadbackStats () |
| Consume readback diagnostics accumulated by this renderer backend. | |
| virtual RendererResourceStats | resourceStats () const |
| Return resource-admission diagnostics for the current frame. | |
| virtual RendererFilterPreparationBudget * | filterPreparationBudget () |
| Shared driver-side filter preparation budget for this renderer family, when supported. | |
| virtual void | injectFilterLocalRasterAllocationFailureForTesting () |
| Cause the next local filter raster allocation to fail in a boundary test. | |
| virtual std::shared_ptr< const RendererTextureSnapshot > | takeTextureSnapshot () |
| Captures the current frame buffer as a backend-owned GPU texture. | |
| virtual const RendererTextureSnapshot * | borrowTextureSnapshot () UTILS_LIFETIME_BOUND |
| Borrows the current backend-owned GPU texture for a synchronous presentation operation. | |
| virtual bool | requiresTextureSnapshotPresentation () const |
| Returns true when presentation callers must use takeTextureSnapshot and must not fall back to CPU bitmap readback for normal frame handoff. | |
| virtual std::unique_ptr< RendererInterface > | createOffscreenInstance () const |
| Creates an independent offscreen renderer instance of the same type as this one. | |
| virtual void | setOffscreenCreationHookForTesting (std::function< void()>) |
| Install a zero-default hook entered from inside offscreen backend construction. | |
| virtual std::uint64_t | filterBudgetChunksForTesting () const |
| Number of filter-budget command-buffer chunks submitted by this renderer family. | |
| virtual void | setDebugGeometryOverlay (bool) |
| Enable or disable the backend's geometry debug overlay. | |
| virtual bool | debugGeometryOverlay () const |
| Whether the backend's geometry debug overlay is enabled. Backends without an overlay always report false. | |
| virtual void | pushMask (const std::optional< Box2d > &maskBounds, MaskType maskType) |
| Begins mask rendering with an explicit coverage mode. | |
Backend-agnostic rendering interface consumed by RendererDriver during document traversal.
Implement this interface to create a custom rendering backend. The driver calls methods in the following order:
Coordinates flow through three spaces: SVG user units → document coordinates (after viewBox mapping) → device pixels (after devicePixelRatio scaling in RenderViewport).
|
pure virtual |
Begins a render pass with the given viewport.
Implementations may allocate or reset backend-specific frame resources here.
Implemented in donner::svg::Renderer, donner::svg::RendererGeode, donner::svg::RendererTinySkia, and donner::svg::RenderSnapshotRecorder.
|
inlinevirtual |
Begins one aggregate resource-budget scope around a controller-managed frame.
A controller may render several offscreen passes before the root render pass. Backends that share frame budgets with their offscreen instances override this pair so every pass consumes one budget epoch instead of resetting independently. Ordinary single-pass callers may omit the scope and continue to rely on beginFrame.
Reimplemented in donner::svg::Renderer, donner::svg::RendererGeode, and donner::svg::RendererTinySkia.
|
nodiscardpure virtual |
Begins recording content into a pattern tile.
Content drawn between beginPatternTile and endPatternTile is captured as a repeating pattern.
| tileRect | The tile rectangle in pattern coordinate space. |
| targetFromPattern | Transform from pattern tile space to target element space. |
Implemented in donner::svg::Renderer, donner::svg::RendererGeode, donner::svg::RendererTinySkia, and donner::svg::RenderSnapshotRecorder.
|
inlinenodiscardvirtual |
Borrows the current backend-owned GPU texture for a synchronous presentation operation.
The returned view is invalidated by the next frame, by takeTextureSnapshot, or by renderer destruction. Callers that retain the texture after returning must use takeTextureSnapshot instead.
Reimplemented in donner::svg::Renderer, and donner::svg::RendererGeode.
|
inlinenodiscardvirtual |
Consume readback diagnostics accumulated by this renderer backend.
Backends without asynchronous GPU readback return zeroed stats.
Reimplemented in donner::svg::Renderer, and donner::svg::RendererGeode.
|
inlinenodiscardvirtual |
Creates an independent offscreen renderer instance of the same type as this one.
Used for rendering sub-documents into intermediate pixmaps when a backend needs an isolated offscreen pass (e.g., for feImage with SVG content). Returns nullptr if offscreen rendering is not supported.
Reimplemented in donner::svg::Renderer, donner::svg::RendererGeode, donner::svg::RendererTinySkia, and donner::svg::RenderSnapshotRecorder.
|
inlinenodiscardvirtual |
Whether the backend's geometry debug overlay is enabled. Backends without an overlay always report false.
Reimplemented in donner::svg::Renderer, and donner::svg::RendererGeode.
|
pure virtual |
Renders the given SVG document.
Implementations prepare the document, traverse the render tree, and emit drawing commands.
Implemented in donner::svg::Renderer, donner::svg::RendererGeode, donner::svg::RendererTinySkia, and donner::svg::RenderSnapshotRecorder.
|
inlinevirtual |
Draws a CPU bitmap (typically a compositor layer/segment raster) into the given target rectangle.
The ImageResource contract is unpremultiplied RGBA, while renderer snapshots are premultiplied - routing a per-frame compose through drawImage costs an unpremultiply + repremultiply round trip (two full pixel-buffer conversions and three allocations per layer per frame). Backends that can consume premultiplied pixels directly should override this with a zero-copy path; the default converts and delegates so every backend stays correct.
| bitmap | The bitmap to draw. |
| params | Image placement parameters. |
Reimplemented in donner::svg::Renderer, and donner::svg::RendererTinySkia.
|
pure virtual |
Convenience helper for drawing ellipses bounded by the provided box.
Implemented in donner::svg::Renderer, donner::svg::RendererGeode, donner::svg::RendererTinySkia, and donner::svg::RenderSnapshotRecorder.
|
pure virtual |
Draws an image resource into the given target rectangle.
Implemented in donner::svg::Renderer, donner::svg::RendererGeode, donner::svg::RendererTinySkia, and donner::svg::RenderSnapshotRecorder.
|
pure virtual |
Draws an arbitrary path using the current paint state.
Implemented in donner::svg::Renderer, donner::svg::RendererGeode, donner::svg::RendererTinySkia, and donner::svg::RenderSnapshotRecorder.
|
pure virtual |
Convenience helper for drawing axis-aligned rectangles.
Implemented in donner::svg::Renderer, donner::svg::RendererGeode, donner::svg::RendererTinySkia, and donner::svg::RenderSnapshotRecorder.
|
pure virtual |
Draws pre-shaped text with the provided paint parameters.
Implemented in donner::svg::Renderer, donner::svg::RendererGeode, donner::svg::RendererTinySkia, and donner::svg::RenderSnapshotRecorder.
|
inlinevirtual |
Draws a backend-owned texture snapshot into the given target rectangle.
Backends that cannot consume texture directly return false. Callers should retain a CPU bitmap fallback when cross-backend composition is required.
Reimplemented in donner::svg::Renderer, and donner::svg::RendererGeode.
|
pure virtual |
Completes the current render pass, flushing any pending work.
Implemented in donner::svg::Renderer, donner::svg::RendererGeode, donner::svg::RendererTinySkia, and donner::svg::RenderSnapshotRecorder.
|
inlinevirtual |
Completes a scope opened by beginFrameResourceScope.
Reimplemented in donner::svg::Renderer, donner::svg::RendererGeode, and donner::svg::RendererTinySkia.
|
pure virtual |
Ends pattern tile recording and sets the resulting tiled shader as the current fill or stroke paint.
| forStroke | If true, set the pattern as the stroke paint; otherwise as the fill paint. |
Implemented in donner::svg::Renderer, donner::svg::RendererGeode, donner::svg::RendererTinySkia, and donner::svg::RenderSnapshotRecorder.
|
inlinenodiscardvirtual |
Number of filter-budget command-buffer chunks submitted by this renderer family.
Reimplemented in donner::svg::Renderer, and donner::svg::RendererGeode.
|
inlinenodiscardvirtual |
Shared driver-side filter preparation budget for this renderer family, when supported.
Reimplemented in donner::svg::Renderer, donner::svg::RendererGeode, donner::svg::RendererTinySkia, and donner::svg::RenderSnapshotRecorder.
|
nodiscardpure virtual |
Returns the rendered height in device pixels.
Implemented in donner::svg::Renderer, donner::svg::RendererGeode, donner::svg::RendererTinySkia, and donner::svg::RenderSnapshotRecorder.
|
pure virtual |
Pops the most recent clip from the renderer stack.
Implemented in donner::svg::Renderer, donner::svg::RendererGeode, donner::svg::RendererTinySkia, and donner::svg::RenderSnapshotRecorder.
|
pure virtual |
Pops the most recent filter layer.
Implemented in donner::svg::Renderer, donner::svg::RendererGeode, donner::svg::RendererTinySkia, and donner::svg::RenderSnapshotRecorder.
|
pure virtual |
Pops the most recent isolated layer, compositing it with the given opacity.
Implemented in donner::svg::Renderer, donner::svg::RendererGeode, donner::svg::RendererTinySkia, and donner::svg::RenderSnapshotRecorder.
|
pure virtual |
Pops the mask layer stack, compositing the masked content.
Implemented in donner::svg::Renderer, donner::svg::RendererGeode, donner::svg::RendererTinySkia, and donner::svg::RenderSnapshotRecorder.
|
pure virtual |
Pops the most recent transform from the renderer stack.
Implemented in donner::svg::Renderer, donner::svg::RendererGeode, donner::svg::RendererTinySkia, and donner::svg::RenderSnapshotRecorder.
|
pure virtual |
Pushes a clip path/mask onto the renderer stack.
Implemented in donner::svg::Renderer, donner::svg::RendererGeode, donner::svg::RendererTinySkia, and donner::svg::RenderSnapshotRecorder.
|
pure virtual |
Pushes a filter layer that applies the given filter graph to all content drawn within it.
| filterGraph | The filter graph describing primitives and their connections. |
| filterRegion | The filter region bounds in local coordinates, used to clip the filter output. If nullopt, the filter operates on the full surface. |
Implemented in donner::svg::Renderer, donner::svg::RendererGeode, donner::svg::RendererTinySkia, and donner::svg::RenderSnapshotRecorder.
|
pure virtual |
Pushes an isolated compositing layer with the given opacity and blend mode.
Content drawn between pushIsolatedLayer and popIsolatedLayer is composited as a group at the specified opacity using the specified blend mode.
Implemented in donner::svg::Renderer, donner::svg::RendererGeode, donner::svg::RendererTinySkia, and donner::svg::RenderSnapshotRecorder.
|
pure virtual |
Begins mask rendering.
The driver renders the mask content between pushMask and transitionMaskToContent, then renders the actual content between transitionMaskToContent and popMask.
This compatibility entry point begins a luminance mask. Existing embedders that implement this pure virtual remain source-compatible. Override the typed overload to support alpha masks.
| maskBounds | Optional clip rect for the mask region. |
Implemented in donner::svg::Renderer, donner::svg::RendererGeode, donner::svg::RendererTinySkia, and donner::svg::RenderSnapshotRecorder.
|
inlinevirtual |
Begins mask rendering with an explicit coverage mode.
Appended after the legacy virtual surface to preserve existing vtable slot order. The default compatibility implementation delegates to the one-argument luminance entry point. Backends that support MaskType::Alpha override this overload.
| maskBounds | Optional clip rect for the mask region. |
| maskType | Whether mask coverage comes from luminance or alpha. |
Reimplemented in donner::svg::Renderer, donner::svg::RendererGeode, donner::svg::RendererTinySkia, and donner::svg::RenderSnapshotRecorder.
|
pure virtual |
Pushes a transform onto the renderer stack, composing with the current transform.
Implemented in donner::svg::Renderer, donner::svg::RendererGeode, donner::svg::RendererTinySkia, and donner::svg::RenderSnapshotRecorder.
|
inlinenodiscardvirtual |
Returns true when presentation callers must use takeTextureSnapshot and must not fall back to CPU bitmap readback for normal frame handoff.
Reimplemented in donner::svg::Renderer, and donner::svg::RendererGeode.
|
inlinenodiscardvirtual |
Return resource-admission diagnostics for the current frame.
Reimplemented in donner::svg::RendererGeode, and donner::svg::RendererTinySkia.
|
inlinevirtual |
Enable or disable the backend's geometry debug overlay.
Geode observes geometry at the actual Slug GPU submission boundary and renders the dynamically-dilated post-vertex convex fan represented by each EncodedPath::boundingVertices array as one frame-final root-target wireframe pass. Default off. Backends without a debug overlay ignore the call.
Reimplemented in donner::svg::Renderer, and donner::svg::RendererGeode.
|
inlinevirtual |
Install a zero-default hook entered from inside offscreen backend construction.
Reimplemented in donner::svg::Renderer, and donner::svg::RendererGeode.
|
pure virtual |
Sets the active paint parameters used by subsequent draw calls.
Implemented in donner::svg::Renderer, donner::svg::RendererGeode, donner::svg::RendererTinySkia, and donner::svg::RenderSnapshotRecorder.
|
inlinevirtual |
Preserve the current render target when the next frame begins.
Backends that support append passes override this to use a load operation instead of clearing. Other backends may ignore the request.
Reimplemented in donner::svg::Renderer, and donner::svg::RendererGeode.
|
pure virtual |
Sets the absolute transform on the renderer, replacing the current matrix.
Unlike pushTransform, this does not interact with the save/restore stack.
Implemented in donner::svg::Renderer, donner::svg::RendererGeode, donner::svg::RendererTinySkia, and donner::svg::RenderSnapshotRecorder.
|
nodiscardpure virtual |
Captures a CPU-readable snapshot of the current frame buffer for testing or downstream consumers.
The snapshot must remain valid after the render pass completes.
Implemented in donner::svg::Renderer, donner::svg::RendererGeode, donner::svg::RendererTinySkia, and donner::svg::RenderSnapshotRecorder.
|
inlinenodiscardvirtual |
Captures a CPU-readable snapshot while allowing a low-priority caller to abort the readback.
Backends whose snapshots are already bounded may inherit this default. GPU backends should override it and poll shouldCancel while waiting for mapped readback data.
Reimplemented in donner::svg::Renderer, and donner::svg::RendererGeode.
|
inlinenodiscardvirtual |
Captures the current frame buffer as a backend-owned GPU texture.
Returns nullptr for backends that cannot expose a directly-sampleable texture. When non-null, the returned snapshot owns the texture lifetime needed by downstream presentation code.
Reimplemented in donner::svg::Renderer, and donner::svg::RendererGeode.
|
pure virtual |
Transitions from rendering mask content to rendering masked content.
Must be called between pushMask and popMask.
Implemented in donner::svg::Renderer, donner::svg::RendererGeode, donner::svg::RendererTinySkia, and donner::svg::RenderSnapshotRecorder.
|
nodiscardpure virtual |
Returns the rendered width in device pixels.
Implemented in donner::svg::Renderer, donner::svg::RendererGeode, donner::svg::RendererTinySkia, and donner::svg::RenderSnapshotRecorder.