Skip to main content

Renderer

Trait Renderer 

Source
pub trait Renderer: Send + 'static {
    // Required methods
    fn attach(&mut self, target: FrameTarget) -> Result<(), RenderError>;
    fn resize(&mut self, width: u32, height: u32) -> bool;
    fn wants_present(
        &mut self,
        render_world: &mut World,
        request: FrameRequest,
    ) -> bool;
    fn present(&mut self, render_world: &mut World) -> Result<(), RenderError>;
    fn detach(&mut self);
}
Expand description

A render backend’s renderer: everything between the retained scene and the pixels.

The renderer owns scene assembly, encoding caches, damage tracking, and whatever its target needs (a swap chain, a window buffer, an offscreen image). No graphics-API type crosses the boundary, so a caller compiles without naming one. Frames are driven from the render world, which already holds the retained scene, the viewport, the text shaper, and the screenshot channel.

Construction does no work. Self::attach binds the renderer to a FrameTarget: a window backend attaches a window once it exists, and a headless launch attaches an offscreen image and hands the renderer to crate::render_backend::install_offscreen, whose render-world system drives it each frame. A pending crate::render_world::SurfaceCapture request is answered from the frame Self::present puts up, on either kind of target.

Required Methods§

Source

fn attach(&mut self, target: FrameTarget) -> Result<(), RenderError>

Bind to target. Calling it again rebinds the renderer. A RenderError::Init failure is what lets a launch try the next backend.

Source

fn resize(&mut self, width: u32, height: u32) -> bool

Reconfigure for a new physical size. Returns true when the size actually changed, so callers can drop the relayout and repaint a duplicate resize event would otherwise force.

Source

fn wants_present( &mut self, render_world: &mut World, request: FrameRequest, ) -> bool

Whether Self::present would put anything new up. The renderer answers, because only it knows what its buffers still hold and how precisely it can compare this scene against the last one it painted.

Source

fn present(&mut self, render_world: &mut World) -> Result<(), RenderError>

Paint, submit, and present one frame from the render world.

Source

fn detach(&mut self)

Release the target and everything behind it. A window backend calls this while the platform connection is still alive, because tearing a surface down after the display connection closes crashes some drivers.

Implementations on Foreign Types§

Source§

impl<R: Renderer + ?Sized> Renderer for Box<R>

A boxed renderer is a renderer, so a launch can hand the one the registry built to anything generic over Renderer.

Source§

fn attach(&mut self, target: FrameTarget) -> Result<(), RenderError>

Source§

fn resize(&mut self, width: u32, height: u32) -> bool

Source§

fn wants_present( &mut self, render_world: &mut World, request: FrameRequest, ) -> bool

Source§

fn present(&mut self, render_world: &mut World) -> Result<(), RenderError>

Source§

fn detach(&mut self)

Implementors§