pub struct WgpuWindowRenderer { /* private fields */ }Expand description
面向桌面(winit)与移动端(ANativeWindow / CAMetalLayer / OHNativeWindow)的统一轻量级
wgpu Swapchain 窗口渲染器。
直接渲染至 Swapchain 纹理,无中间全屏纹理与 Blit 开销。
Implementations§
Source§impl WgpuWindowRenderer
impl WgpuWindowRenderer
Sourcepub fn from_prepared<T>(
prepared: PreparedWgpuContext,
target: T,
width: u32,
height: u32,
) -> Option<Self>where
T: Into<SurfaceTarget<'static>>,
pub fn from_prepared<T>(
prepared: PreparedWgpuContext,
target: T,
width: u32,
height: u32,
) -> Option<Self>where
T: Into<SurfaceTarget<'static>>,
将后台线程预热完毕的 PreparedWgpuContext 在主线程快速绑定至目标窗口 target(仅耗时 ~10ms)。
Sourcepub fn new<T>(target: T, width: u32, height: u32) -> Option<Self>
pub fn new<T>(target: T, width: u32, height: u32) -> Option<Self>
初始化窗口 GPU 渲染表面;若宿主无可用硬件 GPU 或创建失败则返回 None 以便优雅回退至软件光栅。
Sourcepub fn adapter_name(&self) -> &str
pub fn adapter_name(&self) -> &str
返回当前选中的显卡适配器名称。
Sourcepub const fn backend_name(&self) -> &'static str
pub const fn backend_name(&self) -> &'static str
返回当前激活的图形 API 后端名称("DX12" / "Vulkan" / "Metal" 等)。
Sourcepub fn last_primitive_count(&self) -> usize
pub fn last_primitive_count(&self) -> usize
返回最近一帧合批渲染的图元总数。
Sourcepub const fn atlas_sizes(&self) -> (u32, u32)
pub const fn atlas_sizes(&self) -> (u32, u32)
返回当前字形图集与精灵图集的物理像素边长 (glyph_size, sprite_size)。
Sourcepub fn render(
&mut self,
ops: &[DrawOp<'_>],
viewport: Region,
dpi_scale: i16,
) -> bool
pub fn render( &mut self, ops: &[DrawOp<'_>], viewport: Region, dpi_scale: i16, ) -> bool
直接在 Swapchain 上执行单 Pass 2D SDF 渲染并提交显示(整数 DPI 兼容入口)。
Sourcepub fn render_scaled(
&mut self,
ops: &[DrawOp<'_>],
viewport: Region,
scale_factor: f32,
) -> bool
pub fn render_scaled( &mut self, ops: &[DrawOp<'_>], viewport: Region, scale_factor: f32, ) -> bool
直接在 Swapchain 上执行单 Pass 2D SDF 渲染并提交显示(原生支持分数 DPI scale_factor 与 Pixel Snapping)。
Sourcepub fn render_scaled_with_clear(
&mut self,
ops: &[DrawOp<'_>],
viewport: Region,
scale_factor: f32,
clear: Color,
) -> bool
pub fn render_scaled_with_clear( &mut self, ops: &[DrawOp<'_>], viewport: Region, scale_factor: f32, clear: Color, ) -> bool
直接在 Swapchain 上以指定背景清屏色 clear 执行单 Pass 2D SDF 渲染并提交显示。
Sourcepub fn flush_and_wait(&self)
pub fn flush_and_wait(&self)
等待已提交至 GPU 队列的渲染指令完成(用于首帧隐身提交后、显窗前的零白屏同步栅栏)。
Auto Trait Implementations§
impl !Freeze for WgpuWindowRenderer
impl !RefUnwindSafe for WgpuWindowRenderer
impl !UnwindSafe for WgpuWindowRenderer
impl Forget for WgpuWindowRenderer
impl Move for WgpuWindowRenderer
impl Send for WgpuWindowRenderer
impl Sync for WgpuWindowRenderer
impl Unpin for WgpuWindowRenderer
impl UnsafeUnpin for WgpuWindowRenderer
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) 时执行闭包修饰自身,否则原样返回。