Skip to main content

HeadlessApp

Struct HeadlessApp 

Source
pub struct HeadlessApp { /* private fields */ }
Expand description

无窗口应用宿主:命名 scene + 确定性时钟 + 软件光栅化。

复用已 mount 的树(重复 render 不再 remount),便于未来 P0b 的逐帧回放。

Implementations§

Source§

impl HeadlessApp

Source

pub fn new(width: f32, height: f32, registry: SceneRegistry) -> Self

Source

pub fn render(&mut self, name: &str, time_ms: u64) -> Result<(), String>

渲染指定场景到给定逻辑时间(ms)。同一 scene 重复调用复用已 mount 的树。

Source

pub fn run_script( &mut self, name: &str, script: &Script, frame_ms: u64, frames: usize, ) -> Result<Vec<TraceFrame>, String>

逐帧回放输入脚本,返回每帧的确定性 motion trace。

时序契约(与真实窗口帧循环一致):

  1. 虚拟时钟从第 0 帧的 0ms 起,每帧 advance(frame_ms);
  2. 当帧脚本事件在 paint 之前注入,走 ShellEvent 同源管线;
  3. trace 读 frame_with_stats() 的真实 FrameStats 与刚产出的 FramePaint。

不使用 render() 的 set_time(绝对毫秒):回放必须以固定步长推进, 否则脚本帧号与逻辑时间的关系会随调用方式漂移。

Source

pub fn save_trace(&self, path: &str, trace: &[TraceFrame]) -> Result<(), String>

写出 motion trace JSON。

Source

pub fn save_png(&self, path: &str) -> Result<(), String>

把最近一帧软件光栅化结果写出为 PNG。

Source

pub fn save_tree(&self, path: &str) -> Result<(), String>

把当前语义树写出为 JSON(稳定 index id)。

Source

pub fn shell(&self) -> &HeadlessShell

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.