|
|
Donner 0.8.0-pre
Embeddable browser-grade SVG2 engine
|
Backend-agnostic renderer driver that prepares documents for rendering and emits drawing commands through a RendererInterface implementation. More...
#include "donner/svg/renderer/RendererDriver.h"
Public Member Functions | |
| RendererDriver (RendererInterface &renderer, bool verbose=false) | |
| Create a renderer driver that will forward traversal output to the given backend implementation. | |
| void | draw (SVGDocument &document) |
| Render the given SVGDocument using the configured backend. | |
| void | draw (SVGDocument &document, const RenderViewport &viewport, const Transform2d &surfaceFromCanvas) |
Render the given SVGDocument into viewport after applying surfaceFromCanvas to every canvas-space draw command. | |
| RenderSnapshot | captureRenderSnapshot (SVGDocument &document) |
| Capture an immutable render snapshot from the given SVGDocument. | |
| void | draw (const RenderSnapshot &snapshot) |
| Replay an already-captured render snapshot into the configured backend. | |
| void | drawEntityRange (Registry ®istry, Entity firstEntity, Entity lastEntity, const RenderViewport &viewport, const Transform2d &surfaceFromCanvas) |
| Render a range of entities from an already-prepared document's render tree. | |
| void | drawEntityRangeIntoCurrentFrame (Registry ®istry, Entity firstEntity, Entity lastEntity, const RenderViewport &viewport, const Transform2d &surfaceFromCanvas) |
| Render a range of entities into the renderer's already-active frame. | |
| std::optional< Box2d > | computeEntityRangeBounds (Registry ®istry, Entity firstEntity, Entity lastEntity, const RenderViewport &viewport, const Transform2d &surfaceFromCanvas) |
| Compute the canvas-space bounding box of every pixel a subsequent drawEntityRange(registry, firstEntity, lastEntity, viewport,
baseTransform) call would write to. | |
| RendererBitmap | takeSnapshot () const |
| Capture a snapshot from the underlying backend after rendering. | |
Backend-agnostic renderer driver that prepares documents for rendering and emits drawing commands through a RendererInterface implementation.
|
nodiscard |
Capture an immutable render snapshot from the given SVGDocument.
Snapshot capture prepares the live render tree under document access, then records backend-agnostic draw commands that can be replayed after access is released.
| document | Document to snapshot. |
|
nodiscard |
Compute the canvas-space bounding box of every pixel a subsequent drawEntityRange(registry, firstEntity, lastEntity, viewport, baseTransform) call would write to.
Runs the same entity traversal as drawEntityRange but with a bounds-accumulating visitor; no side effects on the renderer or registry.
The bounds include the effect of:
Returns std::nullopt when:
Safe to call on a RendererDriver whose renderer holds persistent state — the traversal never invokes renderer methods.
| void donner::svg::RendererDriver::draw | ( | const RenderSnapshot & | snapshot | ) |
Replay an already-captured render snapshot into the configured backend.
| snapshot | Snapshot to render. |
| void donner::svg::RendererDriver::draw | ( | SVGDocument & | document, |
| const RenderViewport & | viewport, | ||
| const Transform2d & | surfaceFromCanvas ) |
Render the given SVGDocument into viewport after applying surfaceFromCanvas to every canvas-space draw command.
This is used by editor-style camera rendering: SVG layout can still use the document's semantic full canvas, while the backend only allocates the visible output surface.
| document | Document to render. |
| viewport | Output viewport for the backend frame. |
| surfaceFromCanvas | Transform from document canvas coordinates to the output surface. |
| void donner::svg::RendererDriver::drawEntityRange | ( | Registry & | registry, |
| Entity | firstEntity, | ||
| Entity | lastEntity, | ||
| const RenderViewport & | viewport, | ||
| const Transform2d & | surfaceFromCanvas ) |
Render a range of entities from an already-prepared document's render tree.
The document must have been prepared via RendererUtils::prepareDocumentForRendering() before calling this method.
| registry | The registry containing the prepared render tree. |
| firstEntity | First entity in the range to render (inclusive). |
| lastEntity | Last entity in the range to render (inclusive). |
| viewport | Viewport for the render pass. |
| surfaceFromCanvas | Transform that maps canvas coords to the render surface (Translate(-topLeft) for tight-bounded compositor segments, identity for full-canvas layers/segments). Named with destFromSource convention; composed with each entity's worldFromEntityTransform as worldFromEntityTransform * surfaceFromCanvas (donner's left-first operator*: "apply entity-to-canvas, then canvas-to-surface"). |
| void donner::svg::RendererDriver::drawEntityRangeIntoCurrentFrame | ( | Registry & | registry, |
| Entity | firstEntity, | ||
| Entity | lastEntity, | ||
| const RenderViewport & | viewport, | ||
| const Transform2d & | surfaceFromCanvas ) |
Render a range of entities into the renderer's already-active frame.
This is the current-frame form of drawEntityRange: the caller owns RendererInterface::beginFrame() / endFrame(), and this method only emits the entity-range draw commands. It is used by the compositor when an immediate-mode span should be drawn directly into the composition render target instead of first being rasterized into an offscreen tile.
| registry | The registry containing the prepared render tree. |
| firstEntity | First entity in the range to render (inclusive). |
| lastEntity | Last entity in the range to render (inclusive). |
| viewport | Viewport for the active render pass. |
| surfaceFromCanvas | Transform that maps canvas coords to the active render surface. |