Skip to main content

TestingPlatform

Struct TestingPlatform 

Source
pub struct TestingPlatform<const W: usize = 320, const H: usize = 240, P: PixelFormat = Rgb565> {
    pub framebuffer: [[P; W]; H],
    pub total_frames_rendered: u32,
    /* private fields */
}
Expand description

确定性无头测试平台(支持泛型像素格式 P,默认 320x240 Rgb565)。

同时作为 #![no_std] 固定分辨率移动端(MobilePlatform)与 WebAssembly <canvas>(WebPlatform)的统一底层实现。

Fields§

§framebuffer: [[P; W]; H]§total_frames_rendered: u32

Implementations§

Source§

impl<const W: usize, const H: usize, P: PixelFormat> TestingPlatform<W, H, P>

Source

pub const fn new() -> Self

Source

pub fn send_event(&mut self, event: InputEvent)

注入一条模拟输入事件。

Source

pub fn send_click(&mut self, x: i16, y: i16)

模拟在 (x, y) 处按下并抬起完成一次点击。

Source

pub fn on_pointer_down(&mut self, x: i16, y: i16)

注入浏览器/桌面 pointerdown 事件。

Source

pub fn on_pointer_move(&mut self, x: i16, y: i16)

注入浏览器/桌面 pointermove 事件(自动合并连续移动事件)。

Source

pub fn on_pointer_up(&mut self, x: i16, y: i16)

注入浏览器/桌面 pointerup 事件。

Source

pub fn on_pointer_cancel(&mut self)

注入浏览器/桌面 pointercancel 事件。

Source

pub fn on_wheel(&mut self, x: i16, y: i16, delta_y: i16)

注入滚轮滚动事件。

Source

pub fn on_key_down(&mut self, key: KeyCode)

注入键盘按下事件。

Source

pub fn on_popstate_back(&mut self)

注入浏览器 popstate 后退事件。

Source

pub fn on_touch(&mut self, touch_id: u32, phase: TouchPhase, x: i16, y: i16)

注入移动端单指/多指触控事件(自动锁定主触控点 primary_touch_id 并合并高频 Moved 事件)。

Source

pub fn set_orientation(&mut self, orientation: DeviceOrientation)

切换移动设备屏幕朝向并同步更新默认异形屏安全区域。

Source

pub fn set_safe_area(&mut self, insets: SafeAreaInsets)

更新异形屏安全区域内边距。

Source

pub fn handle_back(&mut self, engine: &mut VeloxEngine) -> bool

触发系统返回导航(Android 返回键 / 边缘右滑返回),返回是否被当前页面消费。

Source

pub fn last_dirty_regions(&self) -> &[Region]

获取最近一帧合并计算的脏矩形切片(Region 格式)。

Source

pub fn dirty_rects(&self) -> &[CDirtyRect]

获取最近一帧合并计算的脏矩形切片(FFI 兼容 CDirtyRect 格式)。

Source

pub fn pixels(&self) -> &[P]

获取展平的只读像素帧缓冲切片。

Source§

impl<const W: usize, const H: usize> TestingPlatform<W, H, Rgba8888>

Source

pub fn rgba_ptr(&self) -> *const u8

获取供 FFI / WebAssembly Uint8ClampedArray 直接引用的 RGBA8888 像素首地址。

Source

pub const fn rgba_byte_len(&self) -> usize

获取 RGBA8888 帧缓冲区的总字节长度(W * H * 4)。

Trait Implementations§

Source§

impl<const W: usize, const H: usize, P: PixelFormat> Default for TestingPlatform<W, H, P>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<const W: usize, const H: usize, P: PixelFormat> Platform for TestingPlatform<W, H, P>

Source§

fn duration_since_start(&self) -> Duration

返回自平台启动以来的单调递增时长(桌面端默认由 Instant 提供)。
Source§

fn step_platform( &mut self, engine: &mut VeloxEngine, dt_ms: u16, ) -> PlatformControlFlow

单步执行一次平台事件采集、状态更新与按需脏区刷屏,返回下一次循环的 PlatformControlFlow 调度策略。
Source§

fn run_event_loop(self, engine: VeloxEngine)
where Self: Sized,

启动平台主事件循环,接管 VeloxEngine 直至收到 PlatformControlFlow::Exit。
Source§

impl<const W: usize, const H: usize, P: PixelFormat> PlatformSurface for TestingPlatform<W, H, P>

Source§

fn surface_size(&self) -> (i16, i16)

获取当前显示表面的逻辑宽高 (width, height)。
Source§

fn flush_frame_dt( &mut self, engine: &mut VeloxEngine, dt_ms: u16, ) -> FlushReport

按给定时间步长 dt_ms(毫秒)推进一帧 VeloxEngine 并刷新所有脏区到显示设备。
Source§

fn flush_frame(&mut self, engine: &mut VeloxEngine) -> FlushReport

以默认 60FPS(16ms)步长执行一帧刷新。

Auto Trait Implementations§

§

impl<const W: usize, const H: usize, P> Forget for TestingPlatform<W, H, P>

§

impl<const W: usize, const H: usize, P> Freeze for TestingPlatform<W, H, P>
where [[P; W]; H]: Freeze,

§

impl<const W: usize, const H: usize, P> Move for TestingPlatform<W, H, P>

§

impl<const W: usize, const H: usize, P> RefUnwindSafe for TestingPlatform<W, H, P>

§

impl<const W: usize, const H: usize, P> Send for TestingPlatform<W, H, P>
where [[P; W]; H]: Send,

§

impl<const W: usize, const H: usize, P> Sync for TestingPlatform<W, H, P>
where [[P; W]; H]: Sync,

§

impl<const W: usize, const H: usize, P> Unpin for TestingPlatform<W, H, P>
where [[P; W]; H]: Unpin,

§

impl<const W: usize, const H: usize, P> UnsafeUnpin for TestingPlatform<W, H, P>
where [[P; W]; H]: UnsafeUnpin,

§

impl<const W: usize, const H: usize, P> UnwindSafe for TestingPlatform<W, H, P>
where [[P; W]; H]: UnwindSafe,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> FluentBuilder for T

Source§

fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self

当 condition 为 true 时执行闭包修饰自身,否则原样返回。
Source§

fn when_else( self, condition: bool, then: impl FnOnce(Self) -> Self, else_fn: impl FnOnce(Self) -> Self, ) -> Self

根据 condition 在两个修饰分支之间二选一。
Source§

fn when_some<O>( self, option: Option<O>, then: impl FnOnce(Self, O) -> Self, ) -> Self

当 option 为 Some(value) 时执行闭包修饰自身,否则原样返回。
Source§

fn when_none<O>( self, option: &Option<O>, then: impl FnOnce(Self) -> Self, ) -> Self

当 option 为 None 时执行闭包修饰自身,否则原样返回。
Source§

fn apply<U>(self, f: impl FnOnce(Self) -> U) -> U

通用管道映射变换(避免与 Iterator::map / Option::map 重名)。
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,