|
|
Donner
C++20 SVG rendering library
|
Rendering backend using Skia, https://github.com/google/skia. More...
#include "donner/svg/renderer/RendererSkia.h"
Public Member Functions | |
| RendererSkia (bool verbose=false) | |
| Create the Skia renderer. | |
| ~RendererSkia () | |
| Destructor. | |
| RendererSkia (RendererSkia &&) noexcept | |
| Move constructor. | |
| RendererSkia & | operator= (RendererSkia &&) noexcept |
| Move assignment operator. | |
| RendererSkia (const RendererSkia &)=delete | |
| RendererSkia & | operator= (const RendererSkia &)=delete |
| void | draw (SVGDocument &document) override |
| Draw the SVG document using the renderer. | |
| void | beginFrame (const RenderViewport &viewport) override |
| Begins a render pass for the given viewport. | |
| void | endFrame () override |
| Completes the current render pass, flushing any buffered work. | |
| void | setTransform (const Transformd &transform) override |
| Sets the absolute transform, replacing the current matrix. | |
| void | pushTransform (const Transformd &transform) override |
| Pushes a transform onto the Skia canvas stack. | |
| void | popTransform () override |
| Pops the most recently applied transform. | |
| void | pushClip (const ResolvedClip &clip) override |
| Pushes a clip rect or path mask onto the Skia canvas stack. | |
| void | popClip () override |
| Pops the most recently applied clip. | |
| void | pushIsolatedLayer (double opacity) override |
| Pushes an isolated compositing layer with the given opacity. | |
| void | popIsolatedLayer () override |
| Pops the most recent isolated layer. | |
| void | pushFilterLayer (std::span< const FilterEffect > effects) override |
| Pushes a filter layer that applies the given effect chain. | |
| void | popFilterLayer () override |
| Pops the most recent filter layer. | |
| void | pushMask (const std::optional< Boxd > &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 Boxd &tileRect, const Transformd &patternToTarget) 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 PaintParams &paint) override |
| Sets the current paint state for subsequent draw calls. | |
| void | drawPath (const PathShape &path, const StrokeParams &stroke) override |
| Draws a path with fill and stroke derived from the current paint. | |
| void | drawRect (const Boxd &rect, const StrokeParams &stroke) override |
| Draws a rectangle convenience primitive. | |
| void | drawEllipse (const Boxd &bounds, const StrokeParams &stroke) override |
| Draws an ellipse convenience primitive. | |
| void | drawImage (const ImageResource &image, const ImageParams ¶ms) override |
| Draws an image resource. | |
| void | drawText (const components::ComputedTextComponent &text, const TextParams ¶ms) override |
| Draws text runs. | |
| RendererBitmap | takeSnapshot () const override |
| Captures a CPU-readable snapshot of the last-rendered frame. | |
| std::unique_ptr< RendererInterface > | createOffscreenInstance () const override |
| Creates an independent offscreen renderer instance of the same type as this one. | |
| sk_sp< SkPicture > | drawIntoSkPicture (SVGDocument &document) |
| Draw the given SVGDocument into a SkPicture, for offscreen rendering or debugging purposes. | |
| bool | save (const char *filename) |
| Save the rendered image to a PNG file. | |
| std::span< const uint8_t > | pixelData () const |
| Get the pixel data of the rendered image. | |
| int | width () const override |
| Get the width of the rendered image in pixels. | |
| int | height () const override |
| Get the height of the rendered image in pixels. | |
| const SkBitmap & | bitmap () const |
| Get the SkBitmap of the rendered image. | |
| void | setAntialias (bool antialias) |
| Enable or disable antialiasing. | |
Rendering backend using Skia, https://github.com/google/skia.
Skia is a 2D graphics library that powers Chrome, Firefox, Android, and many other projects, and supports all functionality required to implement SVG (as many of these projects also support SVG).
Skia is used as the reference renderer while implementing Donner.
|
explicit |
Create the Skia renderer.
| verbose | If true, print verbose logging. |
|
overridevirtual |
Begins a render pass for the given viewport.
Implements donner::svg::RendererInterface.
|
overridevirtual |
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. |
| patternToTarget | Transform from pattern tile space to target element space. |
Implements donner::svg::RendererInterface.
|
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. Returns nullptr if offscreen rendering is not supported.
Reimplemented from donner::svg::RendererInterface.
|
overridevirtual |
Draw the SVG document using the renderer.
Writes to an internal bitmap, which can be retrieved using the bitmap() method.
| document | The SVG document to render. |
Implements donner::svg::RendererInterface.
|
overridevirtual |
Draws an ellipse convenience primitive.
Implements donner::svg::RendererInterface.
|
overridevirtual |
Draws an image resource.
Implements donner::svg::RendererInterface.
| sk_sp< SkPicture > donner::svg::RendererSkia::drawIntoSkPicture | ( | SVGDocument & | document | ) |
Draw the given SVGDocument into a SkPicture, for offscreen rendering or debugging purposes.
| document | The SVG document to render. |
|
overridevirtual |
Draws a path with fill and stroke derived from the current paint.
Implements donner::svg::RendererInterface.
|
overridevirtual |
Draws a rectangle convenience primitive.
Implements donner::svg::RendererInterface.
|
overridevirtual |
Draws text runs.
Implements donner::svg::RendererInterface.
|
overridevirtual |
Completes the current render pass, flushing any buffered work.
Implements donner::svg::RendererInterface.
|
overridevirtual |
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. |
Implements donner::svg::RendererInterface.
|
inlineoverridevirtual |
Get the height of the rendered image in pixels.
Implements donner::svg::RendererInterface.
| std::span< const uint8_t > donner::svg::RendererSkia::pixelData | ( | ) | const |
|
overridevirtual |
Pops the most recently applied clip.
Implements donner::svg::RendererInterface.
|
overridevirtual |
Pops the most recent filter layer.
Implements donner::svg::RendererInterface.
|
overridevirtual |
Pops the most recent isolated layer.
Implements donner::svg::RendererInterface.
|
overridevirtual |
Pops the mask layer stack, compositing the masked content.
Implements donner::svg::RendererInterface.
|
overridevirtual |
Pops the most recently applied transform.
Implements donner::svg::RendererInterface.
|
overridevirtual |
Pushes a clip rect or path mask onto the Skia canvas stack.
Implements donner::svg::RendererInterface.
|
overridevirtual |
Pushes a filter layer that applies the given effect chain.
Implements donner::svg::RendererInterface.
|
overridevirtual |
Pushes an isolated compositing layer with the given opacity.
Implements donner::svg::RendererInterface.
|
overridevirtual |
Begins mask rendering.
The driver renders the mask content between pushMask and transitionMaskToContent, then renders the actual content between transitionMaskToContent and popMask.
| maskBounds | Optional clip rect for the mask region. |
Implements donner::svg::RendererInterface.
|
overridevirtual |
Pushes a transform onto the Skia canvas stack.
Implements donner::svg::RendererInterface.
| bool donner::svg::RendererSkia::save | ( | const char * | filename | ) |
Save the rendered image to a PNG file.
| filename | The filename to save the PNG to. |
|
inline |
Enable or disable antialiasing.
On by default.
| antialias | Whether to enable antialiasing. |
|
overridevirtual |
Sets the current paint state for subsequent draw calls.
Implements donner::svg::RendererInterface.
|
overridevirtual |
Sets the absolute transform, replacing the current matrix.
Implements donner::svg::RendererInterface.
|
nodiscardoverridevirtual |
Captures a CPU-readable snapshot of the last-rendered frame.
Implements donner::svg::RendererInterface.
|
overridevirtual |
Transitions from rendering mask content to rendering masked content.
Must be called between pushMask and popMask.
Implements donner::svg::RendererInterface.
|
inlineoverridevirtual |
Get the width of the rendered image in pixels.
Implements donner::svg::RendererInterface.