pub struct WgpuRenderer { /* private fields */ }Expand description
自研轻量级 wgpu 2D SDF 渲染管线核心(绑定任意目标 TextureView 即可渲染)。
Implementations§
Source§impl WgpuRenderer
impl WgpuRenderer
Sourcepub fn new(device: &Device, target_format: TextureFormat) -> Self
pub fn new(device: &Device, target_format: TextureFormat) -> Self
基于已有 wgpu::Device 与目标表面像素格式创建 2D SDF 渲染管线。
Sourcepub fn last_primitive_count(&self) -> usize
pub fn last_primitive_count(&self) -> usize
返回最近一帧合批提交的 GpuPrimitive 实例数量。
Sourcepub const fn atlas_sizes(&self) -> (u32, u32)
pub const fn atlas_sizes(&self) -> (u32, u32)
返回当前字形图集与精灵图集的物理像素边长 (glyph_size, sprite_size)。
Sourcepub const fn sprite_cache_hits(&self) -> u64
pub const fn sprite_cache_hits(&self) -> u64
返回静态精灵跨帧驻留缓存累计命中次数。
Sourcepub const fn text_layout_cache_hits(&self) -> u64
pub const fn text_layout_cache_hits(&self) -> u64
返回跨帧文本行排版缓存(TextLayoutCache)累计命中次数。
Sourcepub fn text_layout_cache_len(&self) -> usize
pub fn text_layout_cache_len(&self) -> usize
返回跨帧文本行排版缓存当前驻留条目数。
Sourcepub fn register_external_texture(
&mut self,
view: TextureView,
sampler: Option<Sampler>,
) -> ExternalTextureId
pub fn register_external_texture( &mut self, view: TextureView, sampler: Option<Sampler>, ) -> ExternalTextureId
注册一张外部零拷贝 GPU 纹理(如海图、雷达、视频解码器或 3D 视口产出的 wgpu::TextureView),
返回可供 div().external_texture(id) 或 SurfaceCanvas 引用的句柄 ID。
Sourcepub fn register_external_texture_with_id(
&mut self,
id: ExternalTextureId,
view: TextureView,
sampler: Option<Sampler>,
)
pub fn register_external_texture_with_id( &mut self, id: ExternalTextureId, view: TextureView, sampler: Option<Sampler>, )
按显式 ID 注册或替换外部零拷贝 GPU 纹理(便于固定槽位号与跨语言 FFI 绑定)。
Sourcepub fn update_external_texture(
&mut self,
id: ExternalTextureId,
view: TextureView,
) -> bool
pub fn update_external_texture( &mut self, id: ExternalTextureId, view: TextureView, ) -> bool
原地更新已注册外部纹理的 wgpu::TextureView(如外部引擎 Resize 或双缓冲翻页时调用)。
Sourcepub fn unregister_external_texture(&mut self, id: ExternalTextureId) -> bool
pub fn unregister_external_texture(&mut self, id: ExternalTextureId) -> bool
注销外部零拷贝纹理槽位并释放 TextureView 引用。
Sourcepub fn external_texture_count(&self) -> usize
pub fn external_texture_count(&self) -> usize
返回当前已注册的外部零拷贝 GPU 纹理数量。
Sourcepub fn render_to_view(
&mut self,
device: &Device,
queue: &Queue,
ops: &[DrawOp<'_>],
viewport: Region,
scale_factor: f32,
target_view: &TextureView,
phys_width: u32,
phys_height: u32,
clear_color: Color,
)
pub fn render_to_view( &mut self, device: &Device, queue: &Queue, ops: &[DrawOp<'_>], viewport: Region, scale_factor: f32, target_view: &TextureView, phys_width: u32, phys_height: u32, clear_color: Color, )
将当前帧 ops 直接渲染至目标 target_view:
- 无图层/混合模式时走单 RenderPass / 单 Draw Call 直出快路径(0 离屏拷贝);
- 含
PushLayer/ 混合 / 毛玻璃 / 滤镜时自动通过GpuEffectsEngine在单CommandEncoder内完成多 Pass 离屏合成。
Auto Trait Implementations§
impl !RefUnwindSafe for WgpuRenderer
impl !UnwindSafe for WgpuRenderer
impl Forget for WgpuRenderer
impl Freeze for WgpuRenderer
impl Move for WgpuRenderer
impl Send for WgpuRenderer
impl Sync for WgpuRenderer
impl Unpin for WgpuRenderer
impl UnsafeUnpin for WgpuRenderer
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) 时执行闭包修饰自身,否则原样返回。