Trait Renderer
pub trait Renderer: Renderer {
type Handle: Clone;
// Required methods
fn load_image(&self, handle: &Self::Handle) -> Result<Allocation, Error>;
fn measure_image(&self, handle: &Self::Handle) -> Option<Size<u32>>;
fn draw_image(
&mut self,
image: Image<Self::Handle>,
bounds: Rectangle,
clip_bounds: Rectangle,
);
}advanced only.Expand description
A Renderer that can render raster graphics.
Required Associated Types§
Required Methods§
fn load_image(&self, handle: &Self::Handle) -> Result<Allocation, Error>
fn load_image(&self, handle: &Self::Handle) -> Result<Allocation, Error>
Loads an image and returns an explicit Allocation to it.
If the image is not already loaded, this method will block! You should generally not use it in drawing logic if you want to avoid frame drops.
fn measure_image(&self, handle: &Self::Handle) -> Option<Size<u32>>
fn measure_image(&self, handle: &Self::Handle) -> Option<Size<u32>>
Returns the dimensions of an image for the given Handle.
If the image is not already loaded, the Renderer may choose to return
None, load the image in the background, and then trigger a relayout.
If you need a measurement right away, consider using Renderer::load_image.
fn draw_image(
&mut self,
image: Image<Self::Handle>,
bounds: Rectangle,
clip_bounds: Rectangle,
)
fn draw_image( &mut self, image: Image<Self::Handle>, bounds: Rectangle, clip_bounds: Rectangle, )
Draws an Image inside the provided bounds.
If the image is not already loaded, the Renderer may choose to render
nothing, load the image in the background, and then trigger a redraw.
If you need to draw an image right away, consider using Renderer::load_image
and hold on to an Allocation first.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.