pub trait Renderer {
type Scene: SceneBuilder;
// Required methods
fn scene(&mut self) -> &mut Self::Scene;
fn render_to_buffer(
&mut self,
width: u32,
height: u32,
background: Color,
out: &mut [u8],
) -> Result<(), BackendError>;
}Expand description
Owns backend resources (GPU device, pipelines, etc.) and rasterizes a scene to an RGBA8 buffer.
SceneBuilder is the authoring surface; this trait is the “produce output”
step. Split into two traits because authoring is pure CPU/infallible and
rasterization is fallible/resource-owning — and the recording backend only
needs SceneBuilder.
Required Associated Types§
Sourcetype Scene: SceneBuilder
type Scene: SceneBuilder
Concrete scene type for this backend. Implements SceneBuilder.
Required Methods§
Sourcefn scene(&mut self) -> &mut Self::Scene
fn scene(&mut self) -> &mut Self::Scene
Mutable access to the scene being built. Issue draw calls against this.
Sourcefn render_to_buffer(
&mut self,
width: u32,
height: u32,
background: Color,
out: &mut [u8],
) -> Result<(), BackendError>
fn render_to_buffer( &mut self, width: u32, height: u32, background: Color, out: &mut [u8], ) -> Result<(), BackendError>
Render the current scene into out, which must be exactly
width * height * 4 bytes.
Pixels are RGBA8 with straight (un-premultiplied) alpha — the convention PNG and most CPU-side image libraries expect. Callers feeding the buffer to a compositor that assumes premultiplied alpha (CoreGraphics, Skia, Cairo, a SrcOver blend on the GPU) must premultiply first.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
Source§impl Renderer for HybridRenderer
Available on crate feature vello-hybrid and (crate features vello-hybrid or webgl) only.
impl Renderer for HybridRenderer
vello-hybrid and (crate features vello-hybrid or webgl) only.type Scene = HybridScene
Source§impl Renderer for VelloRenderer
Available on crate feature vello only.
impl Renderer for VelloRenderer
vello only.