Donner 0.5.1
Embeddable browser-grade SVG2 engine
Loading...
Searching...
No Matches
donner::editor::sandbox::SerializingRenderer Class Referencefinal
Inheritance diagram for donner::editor::sandbox::SerializingRenderer:
[legend]
Collaboration diagram for donner::editor::sandbox::SerializingRenderer:
[legend]

Public Member Functions

 SerializingRenderer (const SerializingRenderer &)=delete
SerializingRenderer & operator= (const SerializingRenderer &)=delete
std::size_t unsupportedCount () const
 Number of kUnsupported messages emitted so far. A value of 0 means the stream is faithful to the original call sequence; any other value means the replay renderer will miss at least one draw call.
bool hasUnsupported () const
 True iff unsupportedCount() > 0.
std::vector< uint8_t > takeBuffer () &&
 Move the accumulated wire bytes out of the writer. Invalidates the renderer; call exactly once, after draw() returns.
std::span< const uint8_t > data () const
 View of the accumulated wire bytes without transferring ownership.
RendererInterface
void draw (svg::SVGDocument &document) override
 Renders the given SVG document.
int width () const override
 Returns the rendered width in device pixels.
int height () const override
 Returns the rendered height in device pixels.
void beginFrame (const svg::RenderViewport &viewport) override
 Begins a render pass with the given viewport.
void endFrame () override
 Completes the current render pass, flushing any pending work.
void setTransform (const Transform2d &transform) override
 Sets the absolute transform on the renderer, replacing the current matrix.
void pushTransform (const Transform2d &transform) override
 Pushes a transform onto the renderer stack, composing with the current transform.
void popTransform () override
 Pops the most recent transform from the renderer stack.
void pushClip (const svg::ResolvedClip &clip) override
 Pushes a clip path/mask onto the renderer stack.
void popClip () override
 Pops the most recent clip from the renderer stack.
void pushIsolatedLayer (double opacity, svg::MixBlendMode blendMode) override
 Pushes an isolated compositing layer with the given opacity and blend mode.
void popIsolatedLayer () override
 Pops the most recent isolated layer, compositing it with the given opacity.
void pushFilterLayer (const svg::components::FilterGraph &filterGraph, const std::optional< Box2d > &filterRegion) override
 Pushes a filter layer that applies the given filter graph to all content drawn within it.
void popFilterLayer () override
 Pops the most recent filter layer.
void pushMask (const std::optional< Box2d > &maskBounds) override
 Begins mask rendering.
void transitionMaskToContent () override
 Transitions from rendering mask content to rendering masked content.
void popMask () override
 Pops the mask layer stack, compositing the masked content.
void beginPatternTile (const Box2d &tileRect, const Transform2d &targetFromPattern) override
 Begins recording content into a pattern tile.
void endPatternTile (bool forStroke) override
 Ends pattern tile recording and sets the resulting tiled shader as the current fill or stroke paint.
void setPaint (const svg::PaintParams &paint) override
 Sets the active paint parameters used by subsequent draw calls.
void drawPath (const svg::PathShape &path, const svg::StrokeParams &stroke) override
 Draws an arbitrary path using the current paint state.
void drawRect (const Box2d &rect, const svg::StrokeParams &stroke) override
 Convenience helper for drawing axis-aligned rectangles.
void drawEllipse (const Box2d &bounds, const svg::StrokeParams &stroke) override
 Convenience helper for drawing ellipses bounded by the provided box.
void drawImage (const svg::ImageResource &image, const svg::ImageParams &params) override
 Draws an image resource into the given target rectangle.
void drawText (Registry &registry, const svg::components::ComputedTextComponent &text, const svg::TextParams &params) override
 Draws pre-shaped text with the provided paint parameters.
svg::RendererBitmap takeSnapshot () const override
 Captures a CPU-readable snapshot of the current frame buffer for testing or downstream consumers.
std::unique_ptr< svg::RendererInterfacecreateOffscreenInstance () const override
 Creates an independent offscreen renderer instance of the same type as this one.

Member Function Documentation

◆ beginFrame()

void donner::editor::sandbox::SerializingRenderer::beginFrame ( const svg::RenderViewport & viewport)
overridevirtual

Begins a render pass with the given viewport.

Implementations may allocate or reset backend-specific frame resources here.

Implements donner::svg::RendererInterface.

◆ beginPatternTile()

void donner::editor::sandbox::SerializingRenderer::beginPatternTile ( const Box2d & tileRect,
const Transform2d & targetFromPattern )
overridevirtual

Begins recording content into a pattern tile.

Content drawn between beginPatternTile and endPatternTile is captured as a repeating pattern.

Parameters
tileRectThe tile rectangle in pattern coordinate space.
targetFromPatternTransform from pattern tile space to target element space.

Implements donner::svg::RendererInterface.

◆ createOffscreenInstance()

std::unique_ptr< svg::RendererInterface > donner::editor::sandbox::SerializingRenderer::createOffscreenInstance ( ) const
nodiscardoverridevirtual

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 from donner::svg::RendererInterface.

◆ draw()

void donner::editor::sandbox::SerializingRenderer::draw ( svg::SVGDocument & document)
overridevirtual

Renders the given SVG document.

Implementations prepare the document, traverse the render tree, and emit drawing commands.

Implements donner::svg::RendererInterface.

◆ drawEllipse()

void donner::editor::sandbox::SerializingRenderer::drawEllipse ( const Box2d & bounds,
const svg::StrokeParams & stroke )
overridevirtual

Convenience helper for drawing ellipses bounded by the provided box.

Implements donner::svg::RendererInterface.

◆ drawImage()

void donner::editor::sandbox::SerializingRenderer::drawImage ( const svg::ImageResource & image,
const svg::ImageParams & params )
overridevirtual

Draws an image resource into the given target rectangle.

Implements donner::svg::RendererInterface.

◆ drawPath()

void donner::editor::sandbox::SerializingRenderer::drawPath ( const svg::PathShape & path,
const svg::StrokeParams & stroke )
overridevirtual

Draws an arbitrary path using the current paint state.

Implements donner::svg::RendererInterface.

◆ drawRect()

void donner::editor::sandbox::SerializingRenderer::drawRect ( const Box2d & rect,
const svg::StrokeParams & stroke )
overridevirtual

Convenience helper for drawing axis-aligned rectangles.

Implements donner::svg::RendererInterface.

◆ drawText()

void donner::editor::sandbox::SerializingRenderer::drawText ( Registry & registry,
const svg::components::ComputedTextComponent & text,
const svg::TextParams & params )
overridevirtual

Draws pre-shaped text with the provided paint parameters.

Implements donner::svg::RendererInterface.

◆ endFrame()

void donner::editor::sandbox::SerializingRenderer::endFrame ( )
overridevirtual

Completes the current render pass, flushing any pending work.

Implements donner::svg::RendererInterface.

◆ endPatternTile()

void donner::editor::sandbox::SerializingRenderer::endPatternTile ( bool forStroke)
overridevirtual

Ends pattern tile recording and sets the resulting tiled shader as the current fill or stroke paint.

Parameters
forStrokeIf true, set the pattern as the stroke paint; otherwise as the fill paint.

Implements donner::svg::RendererInterface.

◆ height()

int donner::editor::sandbox::SerializingRenderer::height ( ) const
inlinenodiscardoverridevirtual

Returns the rendered height in device pixels.

Implements donner::svg::RendererInterface.

◆ popClip()

void donner::editor::sandbox::SerializingRenderer::popClip ( )
overridevirtual

Pops the most recent clip from the renderer stack.

Implements donner::svg::RendererInterface.

◆ popFilterLayer()

void donner::editor::sandbox::SerializingRenderer::popFilterLayer ( )
overridevirtual

Pops the most recent filter layer.

Implements donner::svg::RendererInterface.

◆ popIsolatedLayer()

void donner::editor::sandbox::SerializingRenderer::popIsolatedLayer ( )
overridevirtual

Pops the most recent isolated layer, compositing it with the given opacity.

Implements donner::svg::RendererInterface.

◆ popMask()

void donner::editor::sandbox::SerializingRenderer::popMask ( )
overridevirtual

Pops the mask layer stack, compositing the masked content.

Implements donner::svg::RendererInterface.

◆ popTransform()

void donner::editor::sandbox::SerializingRenderer::popTransform ( )
overridevirtual

Pops the most recent transform from the renderer stack.

Implements donner::svg::RendererInterface.

◆ pushClip()

void donner::editor::sandbox::SerializingRenderer::pushClip ( const svg::ResolvedClip & clip)
overridevirtual

Pushes a clip path/mask onto the renderer stack.

Implements donner::svg::RendererInterface.

◆ pushFilterLayer()

void donner::editor::sandbox::SerializingRenderer::pushFilterLayer ( const svg::components::FilterGraph & filterGraph,
const std::optional< Box2d > & filterRegion )
overridevirtual

Pushes a filter layer that applies the given filter graph to all content drawn within it.

Parameters
filterGraphThe filter graph describing primitives and their connections.
filterRegionThe filter region bounds in local coordinates, used to clip the filter output. If nullopt, the filter operates on the full surface.

Implements donner::svg::RendererInterface.

◆ pushIsolatedLayer()

void donner::editor::sandbox::SerializingRenderer::pushIsolatedLayer ( double opacity,
svg::MixBlendMode blendMode )
overridevirtual

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.

Implements donner::svg::RendererInterface.

◆ pushMask()

void donner::editor::sandbox::SerializingRenderer::pushMask ( const std::optional< Box2d > & maskBounds)
overridevirtual

Begins mask rendering.

The driver renders the mask content between pushMask and transitionMaskToContent, then renders the actual content between transitionMaskToContent and popMask.

Parameters
maskBoundsOptional clip rect for the mask region.

Implements donner::svg::RendererInterface.

◆ pushTransform()

void donner::editor::sandbox::SerializingRenderer::pushTransform ( const Transform2d & transform)
overridevirtual

Pushes a transform onto the renderer stack, composing with the current transform.

Implements donner::svg::RendererInterface.

◆ setPaint()

void donner::editor::sandbox::SerializingRenderer::setPaint ( const svg::PaintParams & paint)
overridevirtual

Sets the active paint parameters used by subsequent draw calls.

Implements donner::svg::RendererInterface.

◆ setTransform()

void donner::editor::sandbox::SerializingRenderer::setTransform ( const Transform2d & transform)
overridevirtual

Sets the absolute transform on the renderer, replacing the current matrix.

Unlike pushTransform, this does not interact with the save/restore stack.

Implements donner::svg::RendererInterface.

◆ takeSnapshot()

svg::RendererBitmap donner::editor::sandbox::SerializingRenderer::takeSnapshot ( ) const
nodiscardoverridevirtual

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.

Implements donner::svg::RendererInterface.

◆ transitionMaskToContent()

void donner::editor::sandbox::SerializingRenderer::transitionMaskToContent ( )
overridevirtual

Transitions from rendering mask content to rendering masked content.

Must be called between pushMask and popMask.

Implements donner::svg::RendererInterface.

◆ width()

int donner::editor::sandbox::SerializingRenderer::width ( ) const
inlinenodiscardoverridevirtual

Returns the rendered width in device pixels.

Implements donner::svg::RendererInterface.


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