Skip to main content

Presenter

Trait Presenter 

Source
pub trait Presenter {
    // Required methods
    fn resize(&mut self, width: u32, height: u32) -> Result<(), String>;
    fn present(
        &mut self,
        pixels: &[u8],
        width: u32,
        height: u32,
    ) -> Result<(), String>;
}
Expand description

像素呈现器:纯 CPU 后端的统一出口。

为什么是 &[u8] 而不是 Vec<u32>:三个平台的底层都吃字节布局( GDI StretchDIBits / X11 PutImage / CGImage),逐像素类型对接反而多一层转换。 格式约定:BGRA(预乘 alpha),行主序,与 SoftBackend 的缓冲区完全一致。

Required Methods§

Source

fn resize(&mut self, width: u32, height: u32) -> Result<(), String>

调整呈现尺寸(缓冲区重建)。

Source

fn present( &mut self, pixels: &[u8], width: u32, height: u32, ) -> Result<(), String>

把一帧 BGRA 像素贴到窗口客户区。

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§