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 → scripted on_events → 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 (event → reactive → layout → render → pixels) and is
both the reference Platform impl and a deterministic integration-test harness.
Construct it with the surface size, optionally script input events and a frame count, and optionally
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, no scripted events, one render frame.
Sourcepub fn with_scale_factor(self, scale_factor: f64) -> Self
pub fn with_scale_factor(self, scale_factor: f64) -> Self
Report a HiDPI scale factor to the app (drives logical-vs-physical sizing).
Sourcepub fn with_prefers_dark(self, prefers_dark: Option<bool>) -> Self
pub fn with_prefers_dark(self, prefers_dark: Option<bool>) -> Self
Report an OS light/dark preference (Some(true) = dark) before the tree mounts.
Sourcepub fn with_events(self, events: Vec<Event>) -> Self
pub fn with_events(self, events: Vec<Event>) -> Self
Scripted input events delivered (in order) after on_resume, each as its own loop iteration.
Sourcepub fn with_frames(self, frames: u32) -> Self
pub fn with_frames(self, frames: u32) -> Self
How many render frames to drive after the scripted events. 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.