Skip to main content

WgpuWindowRenderer

Struct WgpuWindowRenderer 

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

面向桌面(winit)与移动端(ANativeWindow / CAMetalLayer / OHNativeWindow)的统一轻量级 wgpu Swapchain 窗口渲染器。

直接渲染至 Swapchain 纹理,无中间全屏纹理与 Blit 开销。

Implementations§

Source§

impl WgpuWindowRenderer

Source

pub fn from_prepared<T>( prepared: PreparedWgpuContext, target: T, width: u32, height: u32, ) -> Option<Self>
where T: Into<SurfaceTarget<'static>>,

将后台线程预热完毕的 PreparedWgpuContext 在主线程快速绑定至目标窗口 target(仅耗时 ~10ms)。

Source

pub fn new<T>(target: T, width: u32, height: u32) -> Option<Self>
where T: Into<SurfaceTarget<'static>> + Clone,

初始化窗口 GPU 渲染表面;若宿主无可用硬件 GPU 或创建失败则返回 None 以便优雅回退至软件光栅。

Source

pub fn adapter_name(&self) -> &str

返回当前选中的显卡适配器名称。

Source

pub const fn backend_name(&self) -> &'static str

返回当前激活的图形 API 后端名称("DX12" / "Vulkan" / "Metal" 等)。

Source

pub fn last_primitive_count(&self) -> usize

返回最近一帧合批渲染的图元总数。

Source

pub const fn atlas_sizes(&self) -> (u32, u32)

返回当前字形图集与精灵图集的物理像素边长 (glyph_size, sprite_size)。

Source

pub fn resize(&mut self, width: u32, height: u32)

调整 Swapchain 表面物理像素尺寸。

Source

pub fn render( &mut self, ops: &[DrawOp<'_>], viewport: Region, dpi_scale: i16, ) -> bool

直接在 Swapchain 上执行单 Pass 2D SDF 渲染并提交显示(整数 DPI 兼容入口)。

Source

pub fn render_scaled( &mut self, ops: &[DrawOp<'_>], viewport: Region, scale_factor: f32, ) -> bool

直接在 Swapchain 上执行单 Pass 2D SDF 渲染并提交显示(原生支持分数 DPI scale_factor 与 Pixel Snapping)。

Source

pub fn render_scaled_with_clear( &mut self, ops: &[DrawOp<'_>], viewport: Region, scale_factor: f32, clear: Color, ) -> bool

直接在 Swapchain 上以指定背景清屏色 clear 执行单 Pass 2D SDF 渲染并提交显示。

Source

pub fn flush_and_wait(&self)

等待已提交至 GPU 队列的渲染指令完成(用于首帧隐身提交后、显窗前的零白屏同步栅栏)。

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<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,