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§
Sourcefn attach(&mut self, target: FrameTarget) -> Result<(), RenderError>
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.
Sourcefn resize(&mut self, width: u32, height: u32) -> bool
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.
Sourcefn wants_present(
&mut self,
render_world: &mut World,
request: FrameRequest,
) -> bool
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.
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.
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.