Donner
C++20 SVG rendering library
Loading...
Searching...
No Matches
donner::svg::RendererInterface Class Referenceabstract

Backend-agnostic rendering interface consumed by the traversal driver. More...

#include "donner/svg/renderer/RendererInterface.h"

Inheritance diagram for donner::svg::RendererInterface:
[legend]

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 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 setTransform (const Transformd &transform)=0
 Sets the absolute transform on the renderer, replacing the current matrix.
virtual void pushTransform (const Transformd &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)=0
 Pushes an isolated compositing layer with the given opacity.
virtual void popIsolatedLayer ()=0
 Pops the most recent isolated layer, compositing it with the given opacity.
virtual void pushFilterLayer (std::span< const FilterEffect > effects)=0
 Pushes a filter layer that applies the given effect chain to all content drawn within it.
virtual void popFilterLayer ()=0
 Pops the most recent filter layer.
virtual void pushMask (const std::optional< Boxd > &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 void beginPatternTile (const Boxd &tileRect, const Transformd &patternToTarget)=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 Boxd &rect, const StrokeParams &stroke)=0
 Convenience helper for drawing axis-aligned rectangles.
virtual void drawEllipse (const Boxd &bounds, const StrokeParams &stroke)=0
 Convenience helper for drawing ellipses bounded by the provided box.
virtual void drawImage (const ImageResource &image, const ImageParams &params)=0
 Draws an image resource into the given target rectangle.
virtual void drawText (const components::ComputedTextComponent &text, const TextParams &params)=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 std::unique_ptr< RendererInterfacecreateOffscreenInstance () const
 Creates an independent offscreen renderer instance of the same type as this one.

Detailed Description

Backend-agnostic rendering interface consumed by the traversal driver.

Member Function Documentation

◆ beginFrame()

virtual void donner::svg::RendererInterface::beginFrame ( const RenderViewport & viewport)
pure virtual

Begins a render pass with the given viewport.

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

Implemented in donner::svg::RendererSkia, and donner::svg::RendererTinySkia.

◆ beginPatternTile()

virtual void donner::svg::RendererInterface::beginPatternTile ( const Boxd & tileRect,
const Transformd & patternToTarget )
pure virtual

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.
patternToTargetTransform from pattern tile space to target element space.

Implemented in donner::svg::RendererSkia, and donner::svg::RendererTinySkia.

◆ createOffscreenInstance()

virtual std::unique_ptr< RendererInterface > donner::svg::RendererInterface::createOffscreenInstance ( ) const
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. Returns nullptr if offscreen rendering is not supported.

Reimplemented in donner::svg::RendererSkia, and donner::svg::RendererTinySkia.

◆ draw()

virtual void donner::svg::RendererInterface::draw ( SVGDocument & document)
pure virtual

Renders the given SVG document.

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

Implemented in donner::svg::RendererSkia, and donner::svg::RendererTinySkia.

◆ drawEllipse()

virtual void donner::svg::RendererInterface::drawEllipse ( const Boxd & bounds,
const StrokeParams & stroke )
pure virtual

Convenience helper for drawing ellipses bounded by the provided box.

Implemented in donner::svg::RendererSkia, and donner::svg::RendererTinySkia.

◆ drawImage()

virtual void donner::svg::RendererInterface::drawImage ( const ImageResource & image,
const ImageParams & params )
pure virtual

Draws an image resource into the given target rectangle.

Implemented in donner::svg::RendererSkia, and donner::svg::RendererTinySkia.

◆ drawPath()

virtual void donner::svg::RendererInterface::drawPath ( const PathShape & path,
const StrokeParams & stroke )
pure virtual

Draws an arbitrary path using the current paint state.

Implemented in donner::svg::RendererSkia, and donner::svg::RendererTinySkia.

◆ drawRect()

virtual void donner::svg::RendererInterface::drawRect ( const Boxd & rect,
const StrokeParams & stroke )
pure virtual

Convenience helper for drawing axis-aligned rectangles.

Implemented in donner::svg::RendererSkia, and donner::svg::RendererTinySkia.

◆ drawText()

virtual void donner::svg::RendererInterface::drawText ( const components::ComputedTextComponent & text,
const TextParams & params )
pure virtual

Draws pre-shaped text with the provided paint parameters.

Implemented in donner::svg::RendererSkia, and donner::svg::RendererTinySkia.

◆ endFrame()

virtual void donner::svg::RendererInterface::endFrame ( )
pure virtual

Completes the current render pass, flushing any pending work.

Implemented in donner::svg::RendererSkia, and donner::svg::RendererTinySkia.

◆ endPatternTile()

virtual void donner::svg::RendererInterface::endPatternTile ( bool forStroke)
pure virtual

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.

Implemented in donner::svg::RendererSkia, and donner::svg::RendererTinySkia.

◆ height()

virtual int donner::svg::RendererInterface::height ( ) const
nodiscardpure virtual

Returns the rendered height in device pixels.

Implemented in donner::svg::RendererSkia, and donner::svg::RendererTinySkia.

◆ popClip()

virtual void donner::svg::RendererInterface::popClip ( )
pure virtual

Pops the most recent clip from the renderer stack.

Implemented in donner::svg::RendererSkia, and donner::svg::RendererTinySkia.

◆ popFilterLayer()

virtual void donner::svg::RendererInterface::popFilterLayer ( )
pure virtual

Pops the most recent filter layer.

Implemented in donner::svg::RendererSkia, and donner::svg::RendererTinySkia.

◆ popIsolatedLayer()

virtual void donner::svg::RendererInterface::popIsolatedLayer ( )
pure virtual

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

Implemented in donner::svg::RendererSkia, and donner::svg::RendererTinySkia.

◆ popMask()

virtual void donner::svg::RendererInterface::popMask ( )
pure virtual

Pops the mask layer stack, compositing the masked content.

Implemented in donner::svg::RendererSkia, and donner::svg::RendererTinySkia.

◆ popTransform()

virtual void donner::svg::RendererInterface::popTransform ( )
pure virtual

Pops the most recent transform from the renderer stack.

Implemented in donner::svg::RendererSkia, and donner::svg::RendererTinySkia.

◆ pushClip()

virtual void donner::svg::RendererInterface::pushClip ( const ResolvedClip & clip)
pure virtual

Pushes a clip path/mask onto the renderer stack.

Implemented in donner::svg::RendererSkia, and donner::svg::RendererTinySkia.

◆ pushFilterLayer()

virtual void donner::svg::RendererInterface::pushFilterLayer ( std::span< const FilterEffect > effects)
pure virtual

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

Implemented in donner::svg::RendererSkia, and donner::svg::RendererTinySkia.

◆ pushIsolatedLayer()

virtual void donner::svg::RendererInterface::pushIsolatedLayer ( double opacity)
pure virtual

Pushes an isolated compositing layer with the given opacity.

Content drawn between pushIsolatedLayer and popIsolatedLayer is composited as a group at the specified opacity.

Implemented in donner::svg::RendererSkia, and donner::svg::RendererTinySkia.

◆ pushMask()

virtual void donner::svg::RendererInterface::pushMask ( const std::optional< Boxd > & maskBounds)
pure virtual

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.

Implemented in donner::svg::RendererSkia, and donner::svg::RendererTinySkia.

◆ pushTransform()

virtual void donner::svg::RendererInterface::pushTransform ( const Transformd & transform)
pure virtual

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

Implemented in donner::svg::RendererSkia, and donner::svg::RendererTinySkia.

◆ setPaint()

virtual void donner::svg::RendererInterface::setPaint ( const PaintParams & paint)
pure virtual

Sets the active paint parameters used by subsequent draw calls.

Implemented in donner::svg::RendererSkia, and donner::svg::RendererTinySkia.

◆ setTransform()

virtual void donner::svg::RendererInterface::setTransform ( const Transformd & transform)
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::RendererSkia, and donner::svg::RendererTinySkia.

◆ takeSnapshot()

virtual RendererBitmap donner::svg::RendererInterface::takeSnapshot ( ) const
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::RendererSkia, and donner::svg::RendererTinySkia.

◆ transitionMaskToContent()

virtual void donner::svg::RendererInterface::transitionMaskToContent ( )
pure virtual

Transitions from rendering mask content to rendering masked content.

Must be called between pushMask and popMask.

Implemented in donner::svg::RendererSkia, and donner::svg::RendererTinySkia.

◆ width()

virtual int donner::svg::RendererInterface::width ( ) const
nodiscardpure virtual

Returns the rendered width in device pixels.

Implemented in donner::svg::RendererSkia, and donner::svg::RendererTinySkia.


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