carnelian::render::generic

Trait Context

Source
pub trait Context<B: Backend> {
    // Required methods
    fn pixel_format(&self) -> PixelFormat;
    fn path_builder(&self) -> Option<B::PathBuilder>;
    fn raster_builder(&self) -> Option<B::RasterBuilder>;
    fn new_image(&mut self, size: Size2D<u32>) -> B::Image;
    fn new_image_from_png<R: Read>(
        &mut self,
        reader: &mut Reader<R>,
    ) -> Result<B::Image, Error>;
    fn get_image(&mut self, image_index: u32) -> B::Image;
    fn get_current_image(&mut self, context: &ViewAssistantContext) -> B::Image;
    fn render_with_clip(
        &mut self,
        composition: &mut B::Composition,
        clip: Rect<u32>,
        image: B::Image,
        ext: &RenderExt<B>,
    );

    // Provided method
    fn render(
        &mut self,
        composition: &mut B::Composition,
        clip: Option<Rect<u32>>,
        image: B::Image,
        ext: &RenderExt<B>,
    ) { ... }
}
Expand description

Rendering context and API start point.

Required Methods§

Source

fn pixel_format(&self) -> PixelFormat

Returns the context’s pixel format.

Source

fn path_builder(&self) -> Option<B::PathBuilder>

Optionally returns a PathBuilder. May return None of old builder is still alive.

Source

fn raster_builder(&self) -> Option<B::RasterBuilder>

Optionally returns a RasterBuilder. May return None of old builder is still alive.

Source

fn new_image(&mut self, size: Size2D<u32>) -> B::Image

Creates a new image with size.

Source

fn new_image_from_png<R: Read>( &mut self, reader: &mut Reader<R>, ) -> Result<B::Image, Error>

Creates a new image from PNG reader.

Source

fn get_image(&mut self, image_index: u32) -> B::Image

Returns the image at image_index.

Source

fn get_current_image(&mut self, context: &ViewAssistantContext) -> B::Image

Returns the context’s current image.

Source

fn render_with_clip( &mut self, composition: &mut B::Composition, clip: Rect<u32>, image: B::Image, ext: &RenderExt<B>, )

Renders the composition with a clip to the image.

Provided Methods§

Source

fn render( &mut self, composition: &mut B::Composition, clip: Option<Rect<u32>>, image: B::Image, ext: &RenderExt<B>, )

Renders the composition with an optional clip to the image.

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.

Implementors§