Donner SVG main
0.8.0 · 382bd0190.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::svg::RendererGeode Class Reference

Geode rendering backend - GPU-native via the Slug algorithm. More...

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

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

Public Member Functions

 RendererGeode (bool verbose=false)
 Construct the renderer.
 RendererGeode (std::shared_ptr< geode::GeodeDevice > device, bool verbose=false)
 Construct the renderer with an externally-owned GeodeDevice.
 RendererGeode (const RendererGeode &)=delete
RendererGeode & operator= (const RendererGeode &)=delete
 RendererGeode (RendererGeode &&) noexcept
 Move constructor.
RendererGeode & operator= (RendererGeode &&) noexcept
 Move assignment operator.
void setTargetTexture (const gpu::Texture &texture)
 Set a texture this renderer's device already names as the render target for subsequent frames.
void clearTargetTexture ()
 Clear a previously set target texture, reverting to internal offscreen targets allocated per-frame by beginFrame().
void setPreserveTargetOnBeginFrame (bool preserve) override
 Preserve the host-owned target contents when the next frame begins.
void setAntialias (bool antialias)
 Enable analytic edge anti-aliasing. Disabled mode emits binary pixel-center coverage for deterministic ASCII snapshot tests.
void draw (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 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
 A new frame retires any layer, filter, or mask scope left open by an unfinished frame.
void endFrame () override
 Open layer, filter, and mask scopes are dropped without compositing their offscreen content.
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 ResolvedClip &clip) override
 An unmatched push on the active or pattern-restored stack is a caller error repaired at the frame boundary, so its clip state does not carry into a later frame.
void popClip () override
 Pops the most recent clip from the renderer stack.
void pushIsolatedLayer (double opacity, 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 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 pushMask (const std::optional< Box2d > &maskBounds, MaskType maskType) override
 Begins mask rendering with an explicit coverage mode.
void pushMask (const std::optional< Box2d > &maskBounds, MaskType maskType, ColorInterpolation colorInterpolation) override
 Begins a mask using the specified color space for luminance conversion.
void transitionMaskToContent () override
 Transitions from rendering mask content to rendering masked content.
void popMask () override
 Pops the mask layer stack, compositing the masked content.
bool 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 PaintParams &paint) override
 Sets the active paint parameters used by subsequent draw calls.
void drawPath (const PathShape &path, const StrokeParams &stroke) override
 Draws an arbitrary path using the current paint state.
void drawRect (const Box2d &rect, const StrokeParams &stroke) override
 Convenience helper for drawing axis-aligned rectangles.
void drawEllipse (const Box2d &bounds, const StrokeParams &stroke) override
 Convenience helper for drawing ellipses bounded by the provided box.
void drawImage (const ImageResource &image, const ImageParams &params) override
 Draws an image resource into the given target rectangle.
bool drawTextureSnapshot (const RendererTextureSnapshot &texture, const Box2d &targetRect, double opacity=1.0, bool pixelated=false) override
 Draws a backend-owned texture snapshot into the given target rectangle.
void drawText (Registry &registry, const components::ComputedTextComponent &text, const TextParams &params) override
 Draws pre-shaped text with the provided paint parameters.
RendererFilterPreparationBudget * filterPreparationBudget () override
 Shared driver-side filter preparation budget for this renderer family, when supported.
std::unique_ptr< RendererInterface > createOffscreenInstance () const override
 Creates an independent offscreen renderer instance of the same type as this one.
void setOffscreenCreationHookForTesting (std::function< void()> hook) override
 Install a zero-default hook entered after the new renderer owns its device.
std::uint64_t filterBudgetChunksForTesting () const override
 Number of filter-budget command-buffer chunks submitted by this renderer family.
RendererBitmap takeSnapshot () const override
 Captures a CPU-readable snapshot of the current frame buffer for testing or downstream consumers.
RendererBitmap takeSnapshotInterruptibly (const std::function< bool()> &shouldCancel) const override
 Captures a CPU-readable snapshot while allowing a low-priority caller to abort the readback.
RendererReadbackStats consumeReadbackStats () override
 Consume readback diagnostics accumulated by this renderer backend.
bool deviceLost () const
 True once the GPU device backing this renderer has been declared lost, either by a driver-reported GPU device loss or by a bounded GPU wait exceeding its deadline (for example a snapshot readback map that never completed).
geode::GpuWaitResult waitForSubmittedWork (std::chrono::milliseconds stallBound=geode::kDefaultGpuWaitTimeout)
 Wait, bounded by lack of progress, until the GPU has finished all the work this renderer's device has submitted, such as the frames completed by endFrame().
void enableTimestamps (bool enabled)
 Enable or disable GPU timestamp capture.
void setDebugGeometryOverlay (bool enabled) override
 Enable or disable the Geode geometry debug overlay.
bool debugGeometryOverlay () const override
 Whether the geometry debug overlay is enabled.
void setMaximumGlyphs (std::size_t maximumGlyphs) override
 Sets the glyph cap; see RendererInterface::setMaximumGlyphs. It also caps each document's resident glyph outlines.
std::size_t maximumGlyphs () const override
 The glyph cap set by setMaximumGlyphs.
FrameTimings lastFrameTimings () const
 Returns per-frame instrumentation for the most recently completed beginFrame→endFrame window.
RendererGeodeTexturePoolStats texturePoolStats () const
 Returns retained-memory instrumentation for the transient texture pool.
void setGlyphResidencyBudgetForTesting (size_t maxEntries, uint64_t maxRetainedBytes)
 Shrink the glyph-residency budget so eviction can be exercised without building a font-sized working set.
void setGeometryBudgetForTesting (std::size_t maximumDraws, std::size_t maximumItems, std::uint64_t maximumFrameBytes, std::uint64_t maximumCacheBytes, std::uint64_t maximumResidentBytes)
 Shrink the aggregate geometry budget for boundary tests.
void setSurfaceBudgetForTesting (std::size_t maximumSurfaces, std::uint64_t maximumBytes)
 Shrink the aggregate frame-surface budget for boundary tests.
void setTextMaterializationBudgetForTesting (RendererTextMaterializationBudget::Cost limits, std::size_t maximumGlyphOccurrences)
 Shrink the aggregate text-materialization budget for boundary tests.
void injectDeviceLossForTesting ()
 Inject a sticky device loss so tests can verify renderer recovery and pooled-device disposal.
void injectFilterFrameSuspensionAndRestoreFailureForTesting ()
 Inject transformed-filter suspension and following encoder-restoration failure once.
void injectActiveArenaWriteFailureForTesting ()
 Refuse the next active encoder arena upload without touching the GPU buffer.
void injectTransformedResampleArenaWriteFailureForTesting ()
 Refuse the next transformed-filter resampling arena upload before filter execution.
void injectFrameEncoderCloseFailureForTesting (std::size_t successfulCloses=0)
 Fail one close of the frame's recorded draws, as a backend refusal would, leaving the frame with no encoder exactly as a real handover failure does.
bool submitFilterBudgetChunkForTesting ()
 Run one mid-frame filter-budget split now, without waiting for a budget to ask for one.
size_t failedFilterTextureCountForTesting () const
 Number of filter textures retained outside reusable pools after an uncertain failure.
size_t recoverableArenaTextureCountForTesting () const
 Textures held after a recoverable refused upload until earlier GPU submissions complete.
bool hasActiveDrawingEncoderForTesting () const
 Whether a drawing encoder remains active for the current frame.
bool filterFrameFailureInjectionPendingForTesting () const
 Whether either one-shot transformed-filter failure remains pending.
void injectScenePreparationFailureAfterForTesting (std::size_t successfulPreparations)
 Fail one scene preparation after the requested number of successful preparations.
RendererResourceStats resourceStats () const override
 Return aggregate resource-admission diagnostics for the current frame.
size_t residentGlyphCountForTesting (SVGDocument &document)
 Number of glyph outlines currently resident for document.
std::shared_ptr< const RendererTextureSnapshot > takeTextureSnapshot () override
 Captures the current resolved render target as a directly sampleable GPU runtime texture.
const RendererTextureSnapshot * borrowTextureSnapshot () override
 Borrows the current render target until the next frame mutation.
bool supportsTextureSnapshotCompositing () const override
 Geode composes offscreen snapshots on the same device without reading pixels back.
bool requiresTextureSnapshotPresentation () const override
 GPU frames stay as texture snapshots. Browser clients share one GPU owner and queue.
Public Member Functions inherited from donner::svg::RendererInterface
virtual void drawBitmap (const RendererBitmap &bitmap, const ImageParams &params)
 Draws a CPU bitmap (typically a compositor layer/segment raster) into the given target rectangle.
virtual void injectFilterLocalRasterAllocationFailureForTesting ()
 Cause the next local filter raster allocation to fail in a boundary test.

Static Public Member Functions

static bool sceneBatchingEnabledForTesting ()
 Whether cross-entity ordered batching is compiled into this build.

Detailed Description

Geode rendering backend - GPU-native via the Slug algorithm.

RendererGeode implements RendererInterface by translating draw calls into the lower-level donner::geode::GeoEncoder API.

Construction modes

Mode Constructor Device ownership
Headless RendererGeode(verbose) Geode leases an exclusive pooled device
Shared RendererGeode(shared_ptr<GeodeDevice>) Caller shares ownership

In all modes, Geode creates its own offscreen render target each frame unless a host-owned target is set via setTargetTexture().

Embedded rendering

Host applications select a native Geode root for their platform surface, create a context with GeodeDevice::CreateOverSelectedRoot(), and may create sibling contexts with CreateOverPhysicalDeviceOwner(). setTargetTexture() renders into a runtime texture owned by that context, including an acquired native surface frame. Draw with draw() or the beginFrame()/endFrame() lifecycle as usual.

If GeodeDevice::CreateHeadless() fails (no GPU available), all draw operations become no-ops and takeSnapshot() returns an empty bitmap.

Examples
geode_embed.cc.

Constructor & Destructor Documentation

◆ RendererGeode() [1/2]

donner::svg::RendererGeode::RendererGeode ( bool verbose = false)
explicit

Construct the renderer.

Acquires an exclusive lease on a pooled headless GeodeDevice; if device creation fails, the renderer enters a "no-op" state and all subsequent draw calls do nothing. Pooling avoids repeated physical-device creation and keeps the device's pipelines warm for sequential renderer instances, while concurrently live renderers receive independent devices. Callers that intentionally share a device should use the explicit-device constructor.

Parameters
verboseIf true, emit warnings to stderr for unsupported features the first time they are encountered.

◆ RendererGeode() [2/2]

donner::svg::RendererGeode::RendererGeode ( std::shared_ptr< geode::GeodeDevice > device,
bool verbose = false )
explicit

Construct the renderer with an externally-owned GeodeDevice.

The caller retains shared ownership of the device; it must outlive every frame rendered through this renderer. This overload avoids opening a GPU device per renderer, which is important in test fixtures that construct thousands of short-lived renderers - Mesa llvmpipe (and some Intel ANV configurations) accumulate driver state across device creations and eventually deadlock.

Parameters
deviceShared device. A null device leaves the renderer in the no-op state, where draw calls do nothing.
verboseIf true, emit warnings for unsupported features.

Member Function Documentation

◆ beginFrame()

void donner::svg::RendererGeode::beginFrame ( const RenderViewport & viewport)
overridevirtual

A new frame retires any layer, filter, or mask scope left open by an unfinished frame.

Implements donner::svg::RendererInterface.

◆ beginFrameResourceScope()

void donner::svg::RendererGeode::beginFrameResourceScope ( )
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.

◆ beginPatternTile()

bool donner::svg::RendererGeode::beginPatternTile ( const Box2d & tileRect,
const Transform2d & targetFromPattern )
nodiscardoverridevirtual

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.
Returns
True when recording started. False rejects the tile without allocating resources.

Implements donner::svg::RendererInterface.

◆ borrowTextureSnapshot()

const RendererTextureSnapshot * donner::svg::RendererGeode::borrowTextureSnapshot ( )
nodiscardoverridevirtual

Borrows the current render target until the next frame mutation.

Reimplemented from donner::svg::RendererInterface.

◆ consumeReadbackStats()

RendererReadbackStats donner::svg::RendererGeode::consumeReadbackStats ( )
nodiscardoverridevirtual

Consume readback diagnostics accumulated by this renderer backend.

Backends without asynchronous GPU readback return zeroed stats.

Reimplemented from donner::svg::RendererInterface.

◆ createOffscreenInstance()

std::unique_ptr< RendererInterface > donner::svg::RendererGeode::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.

◆ debugGeometryOverlay()

bool donner::svg::RendererGeode::debugGeometryOverlay ( ) const
nodiscardoverridevirtual

Whether the geometry debug overlay is enabled.

Reimplemented from donner::svg::RendererInterface.

◆ deviceLost()

bool donner::svg::RendererGeode::deviceLost ( ) const
nodiscard

True once the GPU device backing this renderer has been declared lost, either by a driver-reported GPU device loss or by a bounded GPU wait exceeding its deadline (for example a snapshot readback map that never completed).

The condition is sticky.

Once lost: draw calls may produce no usable output, and snapshots return empty bitmaps promptly instead of waiting out the readback deadline. Destroying this renderer and its GeodeDevice skips the context's queue-idle waits; a Vulkan runtime device still waits, bounded by queue progress, to prove its submissions complete before it frees native objects, and retains them until process exit when it cannot. Callers should treat a lost device as fatal for this renderer instance: destroy it and recreate the renderer before resuming GPU rendering.

◆ draw()

void donner::svg::RendererGeode::draw ( SVGDocument & document)
overridevirtual

Renders the given SVG document.

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

Implements donner::svg::RendererInterface.

Examples
geode_embed.cc.

◆ drawEllipse()

void donner::svg::RendererGeode::drawEllipse ( const Box2d & bounds,
const StrokeParams & stroke )
overridevirtual

Convenience helper for drawing ellipses bounded by the provided box.

Implements donner::svg::RendererInterface.

◆ drawImage()

void donner::svg::RendererGeode::drawImage ( const ImageResource & image,
const ImageParams & params )
overridevirtual

Draws an image resource into the given target rectangle.

Implements donner::svg::RendererInterface.

◆ drawPath()

void donner::svg::RendererGeode::drawPath ( const PathShape & path,
const StrokeParams & stroke )
overridevirtual

Draws an arbitrary path using the current paint state.

Implements donner::svg::RendererInterface.

◆ drawRect()

void donner::svg::RendererGeode::drawRect ( const Box2d & rect,
const StrokeParams & stroke )
overridevirtual

Convenience helper for drawing axis-aligned rectangles.

Implements donner::svg::RendererInterface.

◆ drawText()

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

Draws pre-shaped text with the provided paint parameters.

Implements donner::svg::RendererInterface.

◆ drawTextureSnapshot()

bool donner::svg::RendererGeode::drawTextureSnapshot ( const RendererTextureSnapshot & texture,
const Box2d & targetRect,
double opacity = 1.0,
bool pixelated = false )
overridevirtual

Draws a backend-owned texture snapshot into the given target rectangle.

Backends that cannot consume texture directly return false. GPU presentation must preserve a usable frame or report that failure; it must not read pixels back as a fallback.

Reimplemented from donner::svg::RendererInterface.

◆ enableTimestamps()

void donner::svg::RendererGeode::enableTimestamps ( bool enabled)

Enable or disable GPU timestamp capture.

No-op today; reserved for future work. When wired up, this will drive the renderPassNs / totalGpuNs fields of lastFrameTimings(). Counters (the primary regression signal) are always on regardless of this flag.

Parameters
enabledWhether to capture GPU timestamps; currently ignored.

◆ endFrame()

void donner::svg::RendererGeode::endFrame ( )
overridevirtual

Open layer, filter, and mask scopes are dropped without compositing their offscreen content.

Implements donner::svg::RendererInterface.

◆ endFrameResourceScope()

void donner::svg::RendererGeode::endFrameResourceScope ( )
overridevirtual

Completes a scope opened by beginFrameResourceScope.

Reimplemented from donner::svg::RendererInterface.

◆ endPatternTile()

void donner::svg::RendererGeode::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.

◆ filterBudgetChunksForTesting()

std::uint64_t donner::svg::RendererGeode::filterBudgetChunksForTesting ( ) const
nodiscardoverridevirtual

Number of filter-budget command-buffer chunks submitted by this renderer family.

Reimplemented from donner::svg::RendererInterface.

◆ filterPreparationBudget()

RendererFilterPreparationBudget * donner::svg::RendererGeode::filterPreparationBudget ( )
nodiscardoverridevirtual

Shared driver-side filter preparation budget for this renderer family, when supported.

Reimplemented from donner::svg::RendererInterface.

◆ height()

int donner::svg::RendererGeode::height ( ) const
nodiscardoverridevirtual

Returns the rendered height in device pixels.

Implements donner::svg::RendererInterface.

◆ injectFrameEncoderCloseFailureForTesting()

void donner::svg::RendererGeode::injectFrameEncoderCloseFailureForTesting ( std::size_t successfulCloses = 0)

Fail one close of the frame's recorded draws, as a backend refusal would, leaving the frame with no encoder exactly as a real handover failure does.

Parameters
successfulClosesCloses to let through first, counting every close that reaches a live frame encoder, including one whose encoder recorded nothing. A count higher than the closes that follow stays armed rather than firing.

◆ lastFrameTimings()

FrameTimings donner::svg::RendererGeode::lastFrameTimings ( ) const
nodiscard

Returns per-frame instrumentation for the most recently completed beginFrame→endFrame window.

Valid after the first endFrame(); before then all fields are zero.

◆ maximumGlyphs()

std::size_t donner::svg::RendererGeode::maximumGlyphs ( ) const
nodiscardoverridevirtual

The glyph cap set by setMaximumGlyphs.

Reimplemented from donner::svg::RendererInterface.

◆ popClip()

void donner::svg::RendererGeode::popClip ( )
overridevirtual

Pops the most recent clip from the renderer stack.

Implements donner::svg::RendererInterface.

◆ popFilterLayer()

void donner::svg::RendererGeode::popFilterLayer ( )
overridevirtual

Pops the most recent filter layer.

Implements donner::svg::RendererInterface.

◆ popIsolatedLayer()

void donner::svg::RendererGeode::popIsolatedLayer ( )
overridevirtual

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

Implements donner::svg::RendererInterface.

◆ popMask()

void donner::svg::RendererGeode::popMask ( )
overridevirtual

Pops the mask layer stack, compositing the masked content.

Implements donner::svg::RendererInterface.

◆ popTransform()

void donner::svg::RendererGeode::popTransform ( )
overridevirtual

Pops the most recent transform from the renderer stack.

Implements donner::svg::RendererInterface.

◆ pushClip()

void donner::svg::RendererGeode::pushClip ( const ResolvedClip & clip)
overridevirtual

An unmatched push on the active or pattern-restored stack is a caller error repaired at the frame boundary, so its clip state does not carry into a later frame.

Implements donner::svg::RendererInterface.

◆ pushFilterLayer()

void donner::svg::RendererGeode::pushFilterLayer ( const 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::svg::RendererGeode::pushIsolatedLayer ( double opacity,
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() [1/3]

void donner::svg::RendererGeode::pushMask ( const std::optional< Box2d > & maskBounds)
inlineoverridevirtual

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.

Parameters
maskBoundsOptional clip rect for the mask region.

Implements donner::svg::RendererInterface.

◆ pushMask() [2/3]

void donner::svg::RendererGeode::pushMask ( const std::optional< Box2d > & maskBounds,
MaskType maskType )
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.

Parameters
maskBoundsOptional clip rect for the mask region.
maskTypeWhether mask coverage comes from luminance or alpha.

Reimplemented from donner::svg::RendererInterface.

◆ pushMask() [3/3]

void donner::svg::RendererGeode::pushMask ( const std::optional< Box2d > & maskBounds,
MaskType maskType,
ColorInterpolation colorInterpolation )
overridevirtual

Begins a mask using the specified color space for luminance conversion.

Parameters
maskBoundsOptional mask region in local coordinates.
maskTypeCoverage mode.
colorInterpolationLuminance color space; auto chooses sRGB.

Reimplemented from donner::svg::RendererInterface.

◆ pushTransform()

void donner::svg::RendererGeode::pushTransform ( const Transform2d & transform)
overridevirtual

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

Implements donner::svg::RendererInterface.

◆ requiresTextureSnapshotPresentation()

bool donner::svg::RendererGeode::requiresTextureSnapshotPresentation ( ) const
inlinenodiscardoverridevirtual

GPU frames stay as texture snapshots. Browser clients share one GPU owner and queue.

Reimplemented from donner::svg::RendererInterface.

◆ resourceStats()

RendererResourceStats donner::svg::RendererGeode::resourceStats ( ) const
nodiscardoverridevirtual

Return aggregate resource-admission diagnostics for the current frame.

Reimplemented from donner::svg::RendererInterface.

◆ sceneBatchingEnabledForTesting()

bool donner::svg::RendererGeode::sceneBatchingEnabledForTesting ( )
staticnodiscard

Whether cross-entity ordered batching is compiled into this build.

Batching collapses many draws into one, so any assertion about draw-call counts or about the buffer traffic a batch's records replace has a different right answer in each build state. Tests read this rather than hard-coding one of them.

◆ setAntialias()

void donner::svg::RendererGeode::setAntialias ( bool antialias)

Enable analytic edge anti-aliasing. Disabled mode emits binary pixel-center coverage for deterministic ASCII snapshot tests.

Parameters
antialiasTrue to retain analytic edge coverage.

◆ setDebugGeometryOverlay()

void donner::svg::RendererGeode::setDebugGeometryOverlay ( bool enabled)
overridevirtual

Enable or disable the Geode geometry debug overlay.

When enabled, an observer on every path-capable GeoEncoder records at the four actual Slug GPU submission paths (gradient, mask, resident fill, and transient/instanced fill). For each instance it reconstructs the submitted convex-fan triangles from EncodedPath::boundingVertices, including the shader's dynamic pixel dilation, transform fallbacks, and all submitted transforms. Text, strokes, clips, masks, and instanced paths are therefore included. Pattern-tile resource internals are deliberately excluded; the consuming pattern fill's path submission is captured instead.

endFrame() draws the collected one-device-pixel opaque-magenta edges in one final root-target pass. Normal document pixels between edges remain unchanged, and later SVG paint, filters, masks, or opacity cannot cover or distort the wireframe. Resource and compositor offscreen instances do not inherit the flag.

Default off. The focused regression verifies that explicitly-off output is byte-identical to the default-off renderer. No sink or capture storage is installed; the only hot-path cost is one null-sink branch at each actual Slug submission. Normal batching and <use> instancing remain enabled in debug mode; the observer expands submitted instances for the wireframe and the final overlay contributes one additional draw call.

Reimplemented from donner::svg::RendererInterface.

◆ setGlyphResidencyBudgetForTesting()

void donner::svg::RendererGeode::setGlyphResidencyBudgetForTesting ( size_t maxEntries,
uint64_t maxRetainedBytes )

Shrink the glyph-residency budget so eviction can be exercised without building a font-sized working set.

Parameters
maxEntriesDistinct cached glyph outlines to keep; the glyph cap still applies.
maxRetainedBytesSummed entry, outline, and encode bytes to keep.

◆ setMaximumGlyphs()

void donner::svg::RendererGeode::setMaximumGlyphs ( std::size_t maximumGlyphs)
overridevirtual

Sets the glyph cap; see RendererInterface::setMaximumGlyphs. It also caps each document's resident glyph outlines.

Reimplemented from donner::svg::RendererInterface.

◆ setOffscreenCreationHookForTesting()

void donner::svg::RendererGeode::setOffscreenCreationHookForTesting ( std::function< void()> hook)
overridevirtual

Install a zero-default hook entered after the new renderer owns its device.

Reimplemented from donner::svg::RendererInterface.

◆ setPaint()

void donner::svg::RendererGeode::setPaint ( const PaintParams & paint)
overridevirtual

Sets the active paint parameters used by subsequent draw calls.

Implements donner::svg::RendererInterface.

◆ setPreserveTargetOnBeginFrame()

void donner::svg::RendererGeode::setPreserveTargetOnBeginFrame ( bool preserve)
overridevirtual

Preserve the host-owned target contents when the next frame begins.

This is for embedded append passes: the host has already rendered into the target texture, and Geode should draw additional renderer primitives on top instead of clearing the texture.

Parameters
preserveTrue to use LoadOp::Load for the first render pass.

Reimplemented from donner::svg::RendererInterface.

◆ setTargetTexture()

void donner::svg::RendererGeode::setTargetTexture ( const gpu::Texture & texture)

Set a texture this renderer's device already names as the render target for subsequent frames.

When a target texture is set, beginFrame() renders into it instead of allocating an internal offscreen target. The texture must:

  • Have gpu::TextureUsage::RenderAttachment set.
  • Match the texture format configured on the GeodeDevice (default: RGBA8Unorm).
  • Be at least as large as the viewport (in device pixels).

A readable owned target can be captured through CopySrc or the supported sampled GPU path. A borrowed surface frame returns an empty bitmap: the native runtime refuses its export because the capture queue could read it after presentation recycles the frame.

Only the identity is kept, so the caller retains ownership and the texture must remain live from beginFrame() through endFrame(). A host that holds its target as a backend texture registers it with the device first; this renderer never sees a backend handle. Call clearTargetTexture() to revert to internal offscreen targets.

Parameters
textureLive target texture of this renderer's device.
Examples
geode_embed.cc.

◆ setTransform()

void donner::svg::RendererGeode::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.

◆ submitFilterBudgetChunkForTesting()

bool donner::svg::RendererGeode::submitFilterBudgetChunkForTesting ( )

Run one mid-frame filter-budget split now, without waiting for a budget to ask for one.

Returns
False, always: the split reports whether the budget can begin a chunk after it, and a budget that never rejected anything has nothing to begin. Read the renderer's state to tell a split that failed from one that did its work.

◆ supportsTextureSnapshotCompositing()

bool donner::svg::RendererGeode::supportsTextureSnapshotCompositing ( ) const
inlinenodiscardoverridevirtual

Geode composes offscreen snapshots on the same device without reading pixels back.

Reimplemented from donner::svg::RendererInterface.

◆ takeSnapshot()

RendererBitmap donner::svg::RendererGeode::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.

◆ takeSnapshotInterruptibly()

RendererBitmap donner::svg::RendererGeode::takeSnapshotInterruptibly ( const std::function< bool()> & shouldCancel) const
nodiscardoverridevirtual

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

◆ takeTextureSnapshot()

std::shared_ptr< const RendererTextureSnapshot > donner::svg::RendererGeode::takeTextureSnapshot ( )
nodiscardoverridevirtual

Captures the current resolved render target as a directly sampleable GPU runtime texture.

Only an internally-owned render target can be taken: this transfers its ownership out of the renderer and detaches the current target so a subsequent same-size frame cannot overwrite a texture still being sampled by editor presentation. Returns null while a host target is set with setTargetTexture(), and when there is no owned target to take.

Reimplemented from donner::svg::RendererInterface.

◆ transitionMaskToContent()

void donner::svg::RendererGeode::transitionMaskToContent ( )
overridevirtual

Transitions from rendering mask content to rendering masked content.

Must be called between pushMask and popMask.

Implements donner::svg::RendererInterface.

◆ waitForSubmittedWork()

geode::GpuWaitResult donner::svg::RendererGeode::waitForSubmittedWork ( std::chrono::milliseconds stallBound = geode::kDefaultGpuWaitTimeout)
nodiscard

Wait, bounded by lack of progress, until the GPU has finished all the work this renderer's device has submitted, such as the frames completed by endFrame().

This is the device's own queue-idle wait, exposed so an embedder or benchmark can time work to GPU completion without a snapshot. It reads back no pixels and presents nothing. The wait gives up only when the outstanding work makes no progress for stallBound, so a long but advancing backlog on a slow device is waited out. Giving up is treated as a hung device: the device is declared lost, exactly as an internal queue-idle wait would declare it, and deviceLost() reports true afterwards. Renderers sharing this device through the shared-device constructor observe the same loss. A renderer without a device has submitted nothing and completes at once.

Call it on the thread that drives this renderer, like the other RendererGeode methods. Work recorded in a frame that is still open has not been submitted and is not waited for.

Parameters
stallBoundLongest the outstanding work may go without progress before the wait gives up; defaults to the shared bound for GPU waits.
Returns
Complete once the submitted work has finished (or there was none), TimedOut when it stopped progressing or the backend failed before finishing (the device is now lost), or DeviceLost when the device was already lost and no wait was performed, or a loss was declared while the wait was running.

◆ width()

int donner::svg::RendererGeode::width ( ) const
nodiscardoverridevirtual

Returns the rendered width in device pixels.

Implements donner::svg::RendererInterface.


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