Skip to main content

PlatformRenderer

Trait PlatformRenderer 

Source
pub trait PlatformRenderer: NativeSceneHooks {
    // Required methods
    fn update_drawable_size(&mut self, size: Size<DevicePixels>);
    fn max_texture_size(&self) -> u32;
    fn gpu_specs(&self) -> Option<GpuSpecs>;

    // Provided methods
    fn set_subpixel_layout(&mut self, _is_bgr: bool) { ... }
    fn update_transparency(&mut self, _transparent: bool) { ... }
    fn destroy(&mut self) { ... }
    fn device_lost(&self) -> bool { ... }
    fn needs_redraw(&mut self) -> bool { ... }
    fn recover(&mut self, _target: RendererTarget<'_>) -> Result<()> { ... }
}
Expand description

What a window asks of whatever renders into it.

draw and sprite_atlas come from SceneRenderer; this adds the lifecycle a window drives, which an offscreen renderer has no reason to implement. update_drawable_size and max_texture_size are the two with no default, because a renderer that cannot answer them cannot be a window’s.

Required Methods§

Source

fn update_drawable_size(&mut self, size: Size<DevicePixels>)

The target’s size changed, in device pixels.

Source

fn max_texture_size(&self) -> u32

The largest texture this renderer can allocate, in pixels.

Source

fn gpu_specs(&self) -> Option<GpuSpecs>

What GPU this renderer is on, if it can tell.

Provided Methods§

Source

fn set_subpixel_layout(&mut self, _is_bgr: bool)

Whether glyphs are rasterized with subpixel antialiasing in BGR order.

Source

fn update_transparency(&mut self, _transparent: bool)

The window’s transparency changed.

Source

fn destroy(&mut self)

Release the renderer’s resources, keeping it reconstructible.

Source

fn device_lost(&self) -> bool

Whether the GPU device or its surface has been lost.

Source

fn needs_redraw(&mut self) -> bool

Whether the renderer has work the frame loop should not wait on.

Source

fn recover(&mut self, _target: RendererTarget<'_>) -> Result<()>

Rebuild from the target the renderer was built against, after a lost device or surface.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§