Trait cushy::RenderOperation
source · pub trait RenderOperation:
Send
+ Sync
+ 'static {
type DrawInfo;
type Prepared: Debug + Send + Sync + 'static;
// Required methods
fn new(graphics: &mut Graphics<'_>) -> Self;
fn prepare(
&mut self,
context: Self::DrawInfo,
origin: Point<Px>,
graphics: &mut Graphics<'_>,
) -> Self::Prepared;
fn render(
&self,
prepared: &Self::Prepared,
origin: Point<Px>,
opacity: f32,
graphics: &mut RenderingGraphics<'_, '_>,
);
}
Expand description
A custom wgpu-powered rendering operation.
§How custom rendering ops work
When Graphics::draw
/Graphics::draw_with
are invoked for the first
time for a given RenderOperation
implementor, new()
is
called to create a shared instance of this rendering operation. The new
function is a good location to put any initialization that can be shared
amongst all drawing calls, as it is invoked only once for each surface.
After an existing or newly-created operation is located, prepare()
is
invoked passing through the DrawInfo
provided to the draw call. The result
of this function is stored.
When the graphics is presented, render()
is invoked providing the data
returned from the prepare()
function.
Required Associated Types§
Required Methods§
Object Safety§
This trait is not object safe.