Donner 0.5.1
Embeddable browser-grade SVG2 engine
Loading...
Searching...
No Matches
donner::editor::sandbox::PipelinedRenderer Class Reference

A pipelined renderer that moves rasterization off the caller's thread. More...

#include "donner/editor/sandbox/PipelinedRenderer.h"

Public Member Functions

 PipelinedRenderer (RendererFactory factory=&MakeDefaultRenderer)
 Construct the renderer and spawn the worker thread.
 ~PipelinedRenderer ()
 Stop the worker thread and tear down state. Blocks until the worker observes the shutdown flag and exits.
 PipelinedRenderer (const PipelinedRenderer &)=delete
PipelinedRendereroperator= (const PipelinedRenderer &)=delete
uint64_t submit (svg::SVGDocument &document, int width, int height)
 Serializes document on the calling thread and hands the resulting byte stream to the worker. Returns as soon as serialization completes — typically a handful of milliseconds.
std::optional< PipelinedFrameacquireLatestFrame ()
 Returns the most recently completed frame, if any. The frame is moved out of the renderer; subsequent calls return std::nullopt until the worker completes another frame.
std::optional< PipelinedFramewaitForFrame (uint64_t target)
 Blocks until a frame with frameId >= target is available and returns it. Intended for tests and synchronous callers that don't want to spin. Returns std::nullopt on shutdown.

Detailed Description

A pipelined renderer that moves rasterization off the caller's thread.

Thread-safety: submit() and acquireLatestFrame() are main-thread-only. The worker thread is internal and never exposed.

Constructor & Destructor Documentation

◆ PipelinedRenderer()

donner::editor::sandbox::PipelinedRenderer::PipelinedRenderer ( RendererFactory factory = &MakeDefaultRenderer)
explicit

Construct the renderer and spawn the worker thread.

Parameters
factoryCalled on the worker thread to build the real backend the first time a frame is rasterized. Defaults to MakeDefaultRenderer.

Member Function Documentation

◆ submit()

uint64_t donner::editor::sandbox::PipelinedRenderer::submit ( svg::SVGDocument & document,
int width,
int height )

Serializes document on the calling thread and hands the resulting byte stream to the worker. Returns as soon as serialization completes — typically a handful of milliseconds.

Overwrites any previously-queued frame that the worker hasn't started yet. If the worker is already rasterizing, its in-flight frame continues; the next frame it picks up is this one. This is the "newest wins" policy — see the file comment for rationale.

Parameters
documentThe document to render. The caller may mutate or free it immediately after this call returns.
widthViewport width in CSS pixels.
heightViewport height in CSS pixels.
Returns
Frame id assigned to this submission. Pair with the id on the returned PipelinedFrame to detect whether a call to acquireLatestFrame() has produced the frame you care about yet.

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