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

Public Member Functions

 AsyncRenderer (const AsyncRenderer &)=delete
AsyncRenderer & operator= (const AsyncRenderer &)=delete
 AsyncRenderer (AsyncRenderer &&)=delete
AsyncRenderer & operator= (AsyncRenderer &&)=delete
bool isBusy () const
 Returns true while a render is in flight on the worker thread. The UI thread must not touch the Renderer or mutate the SVGDocument while this returns true.
void requestRender (const RenderRequest &request)
 Post a render request to the worker. Non-blocking. Transitions the worker from idle → busy. Caller must have checked !isBusy() first; calling while busy is a programmer error.
std::optional< RenderResultpollResult ()
 If a render has completed since the last call, returns the resulting bitmap and transitions the worker back to idle. Returns std::nullopt if no render is pending-ready (either still busy or idle with nothing to hand off).
void setWakeCallback (std::function< void()> callback)
 Install a callback that the worker thread invokes when a render transitions to Done. Used by the editor's on-demand render loop to wake the UI thread (e.g. via glfwPostEmptyEvent) so the fresh result gets picked up without continuous polling.
void setTightBoundedSegmentsEnabled (bool enabled)
 Toggle whether the compositor uses tight-bounded segment rasterization (design doc 0027). The change applies at the start of the next worker iteration — renderFrame calls CompositorController::setTightBoundedSegmentsEnabled before compositing, which marks all cached segments dirty so the flip takes full effect that frame.
bool tightBoundedSegmentsEnabled () const
 Mirror of the current toggle state. UI reads this to render the correct check state in the View menu without racing the worker.
std::uint64_t compositorResetCountForTesting () const
 Number of times the worker has called CompositorController::resetAllLayers() since construction. Exposed for regression tests that want to assert the compositor is NOT torn down on every mutation — the bug that made drag- frame version bumps masquerade as document replacements in the pre-documentGeneration_ design.
svg::compositor::CompositorController::FastPathCounters compositorFastPathCountersForTesting () const
 Snapshot of the compositor's fast-path counters. Read-only — the worker writes them under the mutex when transitioning to Done. Returns zeros before the compositor is constructed (first render not yet requested). UI-thread safe.

Member Function Documentation

◆ compositorResetCountForTesting()

std::uint64_t donner::editor::AsyncRenderer::compositorResetCountForTesting ( ) const
inlinenodiscard

Number of times the worker has called CompositorController::resetAllLayers() since construction. Exposed for regression tests that want to assert the compositor is NOT torn down on every mutation — the bug that made drag- frame version bumps masquerade as document replacements in the pre-documentGeneration_ design.

Counts only resets driven by a request.documentGeneration mismatch; not the implicit reset performed on first compositor construction.

Safe to read from the UI thread; incremented under the internal mutex on the worker.

◆ setTightBoundedSegmentsEnabled()

void donner::editor::AsyncRenderer::setTightBoundedSegmentsEnabled ( bool enabled)
inline

Toggle whether the compositor uses tight-bounded segment rasterization (design doc 0027). The change applies at the start of the next worker iteration — renderFrame calls CompositorController::setTightBoundedSegmentsEnabled before compositing, which marks all cached segments dirty so the flip takes full effect that frame.

Safe to call from the UI thread while a render is in flight; the flag is stored in an std::atomic<bool>, and the worker reads it at a well-defined point in each iteration.

◆ setWakeCallback()

void donner::editor::AsyncRenderer::setWakeCallback ( std::function< void()> callback)

Install a callback that the worker thread invokes when a render transitions to Done. Used by the editor's on-demand render loop to wake the UI thread (e.g. via glfwPostEmptyEvent) so the fresh result gets picked up without continuous polling.

Callers that never set a callback are unaffected — the default behavior (worker stores result in result_, UI thread polls in its own cadence) remains exactly as before.

The callback runs on the worker thread. It must be thread-safe and must NOT re-enter the renderer — a simple wake-up post into the window's event queue is the intended use.


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