|
|
Donner SVG 0.8.0-pre
SVG editor and embeddable C++20 engine.
|
Rendering backend using tiny-skia-cpp. More...
#include "donner/svg/renderer/RendererTinySkia.h"
Public Member Functions | |
| RendererTinySkia (bool verbose=false) | |
| Creates the tiny-skia renderer. | |
| ~RendererTinySkia () | |
| Destructor. | |
| RendererTinySkia (RendererTinySkia &&) noexcept | |
| Move constructor. | |
| RendererTinySkia & | operator= (RendererTinySkia &&) noexcept |
| Move assignment operator. | |
| RendererTinySkia (const RendererTinySkia &)=delete | |
| RendererTinySkia & | operator= (const RendererTinySkia &)=delete |
| void | draw (SVGDocument &document) override |
| Draws the SVG document using the renderer. | |
| void | beginFrameResourceScope () override |
| Begins one aggregate resource-budget scope around a controller-managed frame. | |
| void | endFrameResourceScope () override |
| Completes a scope opened by beginFrameResourceScope. | |
| void | beginFrame (const RenderViewport &viewport) override |
| Begins a render pass for the given viewport. | |
| void | endFrame () override |
| Completes the current render pass. | |
| void | setTransform (const Transform2d &transform) override |
| Sets the absolute transform, replacing the current matrix. | |
| void | pushTransform (const Transform2d &transform) override |
| Pushes a relative transform. | |
| void | popTransform () override |
| Pops the most recent transform. | |
| void | pushClip (const ResolvedClip &clip) override |
| Pushes a clip rect or clip path. | |
| void | popClip () override |
| Pops the most recent clip. | |
| void | pushIsolatedLayer (double opacity, MixBlendMode blendMode) override |
| Pushes an isolated compositing layer. | |
| void | popIsolatedLayer () override |
| Pops the most recent isolated layer. | |
| void | pushFilterLayer (const components::FilterGraph &filterGraph, const std::optional< Box2d > &filterRegion) override |
| Pushes a filter layer. | |
| void | popFilterLayer () override |
| Pops the most recent filter layer. | |
| void | pushMask (const std::optional< Box2d > &maskBounds) override |
| Begins mask rendering. | |
| void | pushMask (const std::optional< Box2d > &maskBounds, MaskType maskType) override |
| Begins mask rendering with an explicit coverage mode. | |
| void | transitionMaskToContent () override |
| Switches from mask rendering to masked content rendering. | |
| void | popMask () override |
| Pops the current mask and composites the masked content. | |
| bool | beginPatternTile (const Box2d &tileRect, const Transform2d &targetFromPattern) override |
| Begins pattern tile recording. | |
| void | endPatternTile (bool forStroke) override |
| Ends pattern recording and stores the resulting pattern paint. | |
| void | setPaint (const PaintParams &paint) override |
| Sets the active paint parameters for subsequent draw calls. | |
| void | drawPath (const PathShape &path, const StrokeParams &stroke) override |
| Draws an arbitrary path. | |
| void | drawRect (const Box2d &rect, const StrokeParams &stroke) override |
| Draws an axis-aligned rectangle. | |
| void | drawEllipse (const Box2d &bounds, const StrokeParams &stroke) override |
| Draws an ellipse. | |
| void | drawImage (const ImageResource &image, const ImageParams ¶ms) override |
| Draws an image resource. | |
| void | drawBitmap (const RendererBitmap &bitmap, const ImageParams ¶ms) override |
| Zero-copy compose blit for premultiplied CPU bitmaps. | |
| void | drawText (Registry ®istry, const components::ComputedTextComponent &text, const TextParams ¶ms) override |
| Draws shaped text. | |
| RendererBitmap | takeSnapshot () const override |
| Captures a CPU-readable snapshot of the current frame. | |
| std::unique_ptr< RendererInterface > | createOffscreenInstance () const override |
| Creates an independent offscreen renderer instance of the same type as this one. | |
| RendererResourceStats | resourceStats () const override |
| Return resource-admission diagnostics for the current frame. | |
| RendererFilterPreparationBudget * | filterPreparationBudget () override |
| Shared driver-side filter preparation budget for this renderer family, when supported. | |
| void | setDashWorkBudgetForTesting (std::size_t maximumWorkUnits) |
| Reduce generated-dash work for a boundary test. | |
| void | setGradientStopBudgetForTesting (std::size_t maximumStops) |
| Reduce materialized gradient stops for a boundary test. | |
| void | setTextGlyphBudgetForTesting (std::size_t maximumGlyphs) |
| Reduce admitted text glyphs for a boundary test. | |
| void | setTextMaterializationBudgetForTesting (RendererTextMaterializationBudget::Cost limits) |
| Reduce decoded-outline and path-copy ceilings for a boundary test. | |
| bool | save (const char *filename) |
| Saves the last rendered frame to a PNG file. | |
| void | setAntialias (bool antialias) |
| Enables or disables anti-aliasing. | |
| bool | antialias () const |
| Returns whether anti-aliasing is enabled. | |
| void | setRetainedSpansEnabled (bool enabled) |
| Enables or disables retained rasterization. | |
| bool | retainedSpansEnabled () const |
| Returns whether retained rasterization is enabled. | |
| void | setRetainedSpanBudgetBytes (std::size_t bytes) |
| Sets the per-document ceiling on retained coverage. | |
| const RetainedSpanStats & | retainedSpanStats () const |
| Returns what retained rasterization did during the most recent frame. | |
| int | width () const override |
| Returns the rendered width in pixels. | |
| int | height () const override |
| Returns the rendered height in pixels. | |
| const RendererTinySkiaFrameCounters & | frameCounters () const |
| Conversions performed during the most recent frame. | |
| Public Member Functions inherited from donner::svg::RendererInterface | |
| virtual void | setPreserveTargetOnBeginFrame (bool preserve) |
| Preserve the current render target when the next frame begins. | |
| 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 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 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 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. | |
Rendering backend using tiny-skia-cpp.
This backend provides a lightweight software rasterizer implementation of RendererInterface. It currently targets shape, image, gradient, clip, mask, pattern, and opacity-layer rendering. Text rendering is not yet implemented.
|
explicit |
Creates the tiny-skia renderer.
| verbose | If true, emit diagnostic logging for unsupported features. |
|
overridevirtual |
Begins a render pass for the given viewport.
| viewport | The viewport dimensions for the render pass. |
Implements donner::svg::RendererInterface.
|
overridevirtual |
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 from donner::svg::RendererInterface.
|
nodiscardoverridevirtual |
Begins pattern tile recording.
| tileRect | Tile bounds in pattern space. |
| targetFromPattern | Transform from pattern tile space to target 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 (e.g., for feImage with SVG content). Returns nullptr if offscreen rendering is not supported.
Reimplemented from donner::svg::RendererInterface.
|
overridevirtual |
Draws the SVG document using the renderer.
| document | The SVG document to render. |
Implements donner::svg::RendererInterface.
|
overridevirtual |
Zero-copy compose blit for premultiplied CPU bitmaps.
tiny-skia consumes premultiplied RGBA natively, so a tightly-packed premultiplied RendererBitmap is drawn through a borrowed PixmapView with no pixel-buffer conversion or copy. Padded and non-premultiplied bitmaps are packed into draw scratch before creating the view.
| bitmap | The bitmap to draw. |
| params | Image placement parameters. |
Reimplemented from donner::svg::RendererInterface.
|
overridevirtual |
Draws an ellipse.
| bounds | The ellipse bounds. |
| stroke | Stroke configuration for the ellipse. |
Implements donner::svg::RendererInterface.
|
overridevirtual |
Draws an image resource.
| image | The image resource to draw. |
| params | Image placement parameters. |
Implements donner::svg::RendererInterface.
|
overridevirtual |
Draws an arbitrary path.
| path | The path to draw. |
| stroke | Stroke configuration for the path. |
Implements donner::svg::RendererInterface.
|
overridevirtual |
Draws an axis-aligned rectangle.
| rect | The rectangle bounds. |
| stroke | Stroke configuration for the rectangle. |
Implements donner::svg::RendererInterface.
|
overridevirtual |
Draws shaped text.
| registry | ECS registry used for resolving paint references. |
| text | The shaped text runs. |
| params | Text styling parameters. |
Implements donner::svg::RendererInterface.
|
overridevirtual |
Completes the current render pass.
Implements donner::svg::RendererInterface.
|
overridevirtual |
Completes a scope opened by beginFrameResourceScope.
Reimplemented from donner::svg::RendererInterface.
|
overridevirtual |
Ends pattern recording and stores the resulting pattern paint.
| forStroke | If true, store as stroke paint, otherwise fill paint. |
Implements donner::svg::RendererInterface.
|
nodiscardoverridevirtual |
Shared driver-side filter preparation budget for this renderer family, when supported.
Reimplemented from donner::svg::RendererInterface.
|
inlinenodiscard |
Conversions performed during the most recent frame.
|
overridevirtual |
Returns the rendered height in pixels.
Implements donner::svg::RendererInterface.
|
overridevirtual |
Pops the most recent 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 current mask and composites the masked content.
Implements donner::svg::RendererInterface.
|
overridevirtual |
Pops the most recent transform.
Implements donner::svg::RendererInterface.
|
overridevirtual |
Pushes a clip rect or clip path.
| clip | The resolved clip to apply. |
Implements donner::svg::RendererInterface.
|
overridevirtual |
Pushes a filter layer.
| filterGraph | The filter graph to apply when the layer is popped. |
| filterRegion | Optional filter region bounds in user space. |
Implements donner::svg::RendererInterface.
|
overridevirtual |
Pushes an isolated compositing layer.
| opacity | Group opacity applied when the layer is composited back. |
| blendMode | Mix-blend-mode applied when the layer is composited back. |
Implements donner::svg::RendererInterface.
|
inlineoverridevirtual |
Begins mask rendering.
| maskBounds | Optional mask bounds clip. |
| maskType | Whether mask coverage comes from luminance or alpha. |
Implements donner::svg::RendererInterface.
|
overridevirtual |
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 from donner::svg::RendererInterface.
|
overridevirtual |
Pushes a relative transform.
| transform | The transform to compose with the current matrix. |
Implements donner::svg::RendererInterface.
|
nodiscardoverridevirtual |
Return resource-admission diagnostics for the current frame.
Reimplemented from donner::svg::RendererInterface.
| bool donner::svg::RendererTinySkia::save | ( | const char * | filename | ) |
Saves the last rendered frame to a PNG file.
| filename | The output PNG filename. |
|
overridevirtual |
Sets the active paint parameters for subsequent draw calls.
| paint | The resolved paint state. |
Implements donner::svg::RendererInterface.
|
inline |
Sets the per-document ceiling on retained coverage.
Exceeding it evicts the coldest shapes; a working set that does not fit at all turns retention off for that document.
| bytes | Ceiling in bytes. |
|
inline |
Enables or disables retained rasterization.
When enabled, each shape's coverage is recorded the first time it is rasterized and replayed on later frames for as long as every input that coverage depended on is unchanged, which turns a redraw of an unchanged document into blits. Output is byte-identical either way; the cost is the memory the recordings occupy, bounded by setRetainedSpanBudgetBytes.
Off by default, because a renderer that draws each document once pays the recording cost with nothing to replay it onto.
| enabled | Whether to retain and replay per-shape coverage. |
|
overridevirtual |
Sets the absolute transform, replacing the current matrix.
| transform | The transform to apply. |
Implements donner::svg::RendererInterface.
|
nodiscardoverridevirtual |
Captures a CPU-readable snapshot of the current frame.
Implements donner::svg::RendererInterface.
|
overridevirtual |
Switches from mask rendering to masked content rendering.
Implements donner::svg::RendererInterface.
|
overridevirtual |
Returns the rendered width in pixels.
Implements donner::svg::RendererInterface.