pub struct HeadlessPlatform { /* private fields */ }Expand description
A first-class, windowless Platform backend: it drives the exact same EventHandler seam as the winit
backend (on_resume → on_redraws → on_suspend) against a HeadlessWindow, with no event loop, GPU
swapchain, or display server. Because the handler builds an offscreen renderer for a headless window, this
routes a real app end-to-end (reactive → layout → render → pixels) and is both the reference Platform
impl and a deterministic integration-test harness.
Construct it with the surface size and optionally a frame count and a sink to capture the final frame’s
pixels; then drive it via [crate::run-style entry points] — e.g.
telar::run_with_platform(HeadlessPlatform::new(w, h).capture_into(sink), …).
Implementations§
Source§impl HeadlessPlatform
impl HeadlessPlatform
Sourcepub fn new(width: u32, height: u32) -> Self
pub fn new(width: u32, height: u32) -> Self
A width×height offscreen surface at scale 1.0, one render frame.
Sourcepub fn with_frames(self, frames: u32) -> Self
pub fn with_frames(self, frames: u32) -> Self
How many render frames to drive. Defaults to 1. Use more to let animations or multi-pass reactive settling converge before the final pixels are captured.
Sourcepub fn capture_into(self, sink: FrameSink) -> Self
pub fn capture_into(self, sink: FrameSink) -> Self
Capture the final frame’s premultiplied RGBA8 pixels into sink, readable after run returns.
Sourcepub fn capture_surfaces_into(self, sink: SurfaceFrameSink) -> Self
pub fn capture_surfaces_into(self, sink: SurfaceFrameSink) -> Self
Capture each surface’s final frame into sink, keyed by SurfaceId, readable after
MultiSurfacePlatform::run_surfaces returns. Only consulted by the multi-surface path.
Trait Implementations§
Source§impl MultiSurfacePlatform for HeadlessPlatform
impl MultiSurfacePlatform for HeadlessPlatform
type Window = HeadlessWindow
Source§fn run_surfaces<H, F>(
self,
surfaces: Vec<(SurfaceId, WindowConfig)>,
factory: F,
) -> Result<(), PlatformError>
fn run_surfaces<H, F>( self, surfaces: Vec<(SurfaceId, WindowConfig)>, factory: F, ) -> Result<(), PlatformError>
surfaces (each an (id, config) pair), building its handler via
factory(id). Blocks until all surfaces have closed.