pub struct WgpuRenderer { /* private fields */ }Implementations§
Source§impl WgpuRenderer
impl WgpuRenderer
Sourcepub fn new<W>(
gpu_context: GpuContext,
window: &W,
config: WgpuSurfaceConfig,
compositor_gpu: Option<CompositorGpuHint>,
) -> Result<Self>
pub fn new<W>( gpu_context: GpuContext, window: &W, config: WgpuSurfaceConfig, compositor_gpu: Option<CompositorGpuHint>, ) -> Result<Self>
从原始窗口句柄创建新的 WgpuRenderer。
gpu_context 是一个共享引用,用于在多个窗口之间协调 GPU 上下文。
第一个创建渲染器的窗口将初始化上下文;后续窗口将共享它。
§安全性
调用者必须确保窗口句柄在返回的渲染器的生命周期内保持有效。
pub fn update_drawable_size(&mut self, size: Size<DevicePixels>)
pub fn set_subpixel_layout(&mut self, is_bgr: bool)
pub fn update_transparency(&mut self, transparent: bool)
pub fn viewport_size(&self) -> Size<DevicePixels>
pub fn sprite_atlas(&self) -> &Arc<WgpuAtlas> ⓘ
pub fn supports_dual_source_blending(&self) -> bool
pub fn gpu_specs(&self) -> GpuSpecs
pub fn max_texture_size(&self) -> u32
pub fn draw(&mut self, scene: &Scene) -> bool
Sourcepub fn unconfigure_surface(&mut self)
pub fn unconfigure_surface(&mut self)
将表面标记为未配置,以便在通过 replace_surface
提供新表面之前跳过渲染。
这不会丢弃渲染器 —— 设备、队列、图集和
管线保持活动状态。当原生窗口被销毁时使用此方法
(例如 Android TerminateWindow),但你打算稍后重新创建
表面而不丢失缓存的图集纹理。
Sourcepub fn replace_surface<W: HasWindowHandle>(
&mut self,
window: &W,
config: WgpuSurfaceConfig,
instance: &Instance,
) -> Result<()>
pub fn replace_surface<W: HasWindowHandle>( &mut self, window: &W, config: WgpuSurfaceConfig, instance: &Instance, ) -> Result<()>
用新表面替换 wgpu 表面(例如在 Android 销毁并
重新创建原生窗口之后)。保持设备、队列、图集和
所有管线完好无损,以便缓存的 AtlasTextureId 保持有效。
instance 必须 是用于创建适配器和设备的
同一个 wgpu::Instance(即来自 WgpuContext)。使用
不同的实例将导致 “Device does not exist” panic,因为
wgpu 设备绑定到其原始实例。
pub fn destroy(&mut self)
Sourcepub fn device_lost(&self) -> bool
pub fn device_lost(&self) -> bool
返回 GPU 设备是否丢失以及是否需要恢复。
Sourcepub fn needs_redraw(&mut self) -> bool
pub fn needs_redraw(&mut self) -> bool
返回是否需要重绘,因为 GPU 状态已被清除。 调用此方法将清除标志。
Auto Trait Implementations§
impl !Freeze for WgpuRenderer
impl !RefUnwindSafe for WgpuRenderer
impl !Send for WgpuRenderer
impl !Sync for WgpuRenderer
impl Unpin for WgpuRenderer
impl UnsafeUnpin for WgpuRenderer
impl !UnwindSafe 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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more