|
|
Donner 0.5.1
Embeddable browser-grade SVG2 engine
|
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 | |
| PipelinedRenderer & | operator= (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< PipelinedFrame > | acquireLatestFrame () |
| 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< PipelinedFrame > | waitForFrame (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. | |
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.
|
explicit |
Construct the renderer and spawn the worker thread.
| factory | Called on the worker thread to build the real backend the first time a frame is rasterized. Defaults to MakeDefaultRenderer. |
| 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.
| document | The document to render. The caller may mutate or free it immediately after this call returns. |
| width | Viewport width in CSS pixels. |
| height | Viewport height in CSS pixels. |