pub struct WinitPlatform { /* private fields */ }Expand description
基于 winit + softbuffer 的跨平台桌面窗口平台(支持 Linux Wayland、Windows、macOS)。
实现 Platform 与 PlatformSurface 特征。
Implementations§
Source§impl WinitPlatform
impl WinitPlatform
Sourcepub fn new(title: impl Into<String>, width: usize, height: usize) -> Self
pub fn new(title: impl Into<String>, width: usize, height: usize) -> Self
创建指定标题与逻辑尺寸 (width, height) 的跨平台 WinitPlatform 窗口运行器。
Sourcepub fn with_dpi_scale(self, scale: usize) -> Self
pub fn with_dpi_scale(self, scale: usize) -> Self
设置 HiDPI 缩放倍数(1 为原始像素,2 为 2× 高清矢量光栅化)。
Sourcepub fn with_backend(self, backend: DesktopRenderBackend) -> Self
pub fn with_backend(self, backend: DesktopRenderBackend) -> Self
配置桌面渲染后端类型(默认采用 super::DesktopRenderBackend::default_desktop,即优先 Wgpu 2D SDF GPU 后端)。
Sourcepub fn set_backend(&mut self, backend: DesktopRenderBackend)
pub fn set_backend(&mut self, backend: DesktopRenderBackend)
动态切换桌面渲染后端类型。
Sourcepub const fn backend(&self) -> DesktopRenderBackend
pub const fn backend(&self) -> DesktopRenderBackend
返回当前激活的桌面渲染后端类型。
Sourcepub const fn driver(&self) -> &SoftwareSurfaceDriver
pub const fn driver(&self) -> &SoftwareSurfaceDriver
返回内部表面驱动器只读引用(用于检查单槽原位复用与局部光栅化脏矩形)。
Sourcepub fn run(self, core: VeloxEngine, scroll_list_id: Option<u32>)
pub fn run(self, core: VeloxEngine, scroll_list_id: Option<u32>)
启动基于 winit::event_loop::EventLoop + softbuffer 的原生跨平台窗口事件循环。
Sourcepub fn run_headless(&self, core: &mut VeloxEngine, frames: usize)
pub fn run_headless(&self, core: &mut VeloxEngine, frames: usize)
无头模式运行指定帧数(用于 CI 或无显示服务器环境验证)。
Sourcepub fn render_to_png(&self, core: &mut VeloxEngine, path: &str) -> Result<()>
pub fn render_to_png(&self, core: &mut VeloxEngine, path: &str) -> Result<()>
渲染一帧并将前台 Xrgb8888 像素缓冲保存为无损 PNG 图像文件。
Trait Implementations§
Source§impl Platform for WinitPlatform
impl Platform for WinitPlatform
Source§fn duration_since_start(&self) -> Duration
fn duration_since_start(&self) -> Duration
返回自平台启动以来的单调递增时长(桌面端默认由
Instant 提供)。Source§fn step_platform(
&mut self,
engine: &mut VeloxEngine,
dt_ms: u16,
) -> PlatformControlFlow
fn step_platform( &mut self, engine: &mut VeloxEngine, dt_ms: u16, ) -> PlatformControlFlow
单步执行一次平台事件采集、状态更新与按需脏区刷屏,返回下一次循环的
PlatformControlFlow 调度策略。Source§fn run_event_loop(self, engine: VeloxEngine)
fn run_event_loop(self, engine: VeloxEngine)
启动平台主事件循环,接管
VeloxEngine 直至收到 PlatformControlFlow::Exit。Source§impl PlatformSurface for WinitPlatform
impl PlatformSurface for WinitPlatform
Source§fn surface_size(&self) -> (i16, i16)
fn surface_size(&self) -> (i16, i16)
获取当前显示表面的逻辑宽高
(width, height)。Source§fn flush_frame_dt(
&mut self,
engine: &mut VeloxEngine,
dt_ms: u16,
) -> FlushReport
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
fn flush_frame(&mut self, engine: &mut VeloxEngine) -> FlushReport
以默认 60FPS(
16ms)步长执行一帧刷新。Auto Trait Implementations§
impl Forget for WinitPlatform
impl Freeze for WinitPlatform
impl Move for WinitPlatform
impl RefUnwindSafe for WinitPlatform
impl Send for WinitPlatform
impl Sync for WinitPlatform
impl Unpin for WinitPlatform
impl UnsafeUnpin for WinitPlatform
impl UnwindSafe for WinitPlatform
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FluentBuilder for T
impl<T> FluentBuilder for T
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
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
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
fn when_some<O>( self, option: Option<O>, then: impl FnOnce(Self, O) -> Self, ) -> Self
当
option 为 Some(value) 时执行闭包修饰自身,否则原样返回。