Skip to main content

DrawSink

Trait DrawSink 

Source
pub trait DrawSink {
    // Required methods
    fn upload(&mut self, commands: &[DrawCommand]);
    fn present(&mut self) -> Result<(), DrawError>;
    fn resize(&mut self, size: (u32, u32));
    fn set_scale_factor(&mut self, scale_factor: f64);
}
Expand description

A destination for one window’s draw commands.

Callers produce commands with DrawCommand and hand them over; the sink decides when and how they reach a display.

upload only records, and present submits, so a caller may feed several command sets before showing anything — or record without ever presenting, which is what the offscreen sinks do.

Required Methods§

Source

fn upload(&mut self, commands: &[DrawCommand])

Records and uploads commands for the next frame.

Source

fn present(&mut self) -> Result<(), DrawError>

Draws and presents whatever upload recorded.

Source

fn resize(&mut self, size: (u32, u32))

Notifies the sink that its drawable changed size, in physical pixels.

Source

fn set_scale_factor(&mut self, scale_factor: f64)

Notifies the sink that the display scale factor changed.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl DrawSink for GpuRenderer

Presents through a wgpu surface bound to an OS window.

This is the shell’s default DrawSink. Callers above the seam only ever see the trait, so the fact that presentation is tied to a window surface stays contained here.