DrawSharedImpl

Trait DrawSharedImpl 

Source
pub trait DrawSharedImpl: Any {
    type Draw: DrawImpl;

    // Required methods
    fn max_texture_dimension_2d(&self) -> u32;
    fn set_raster_config(&mut self, config: &RasterConfig);
    fn image_alloc(&mut self, size: (u32, u32)) -> Result<ImageId, AllocError>;
    fn image_upload(&mut self, id: ImageId, data: &[u8], format: ImageFormat);
    fn image_free(&mut self, id: ImageId);
    fn image_size(&self, id: ImageId) -> Option<(u32, u32)>;
    fn draw_image(
        &self,
        draw: &mut Self::Draw,
        pass: PassId,
        id: ImageId,
        rect: Quad,
    );
    fn draw_text(
        &mut self,
        draw: &mut Self::Draw,
        pass: PassId,
        rect: Rect,
        text: &TextDisplay,
        col: Rgba,
    );
    fn draw_text_effects(
        &mut self,
        draw: &mut Self::Draw,
        pass: PassId,
        rect: Rect,
        text: &TextDisplay,
        col: Rgba,
        effects: &[Effect<()>],
    );
    fn draw_text_effects_rgba(
        &mut self,
        draw: &mut Self::Draw,
        pass: PassId,
        rect: Rect,
        text: &TextDisplay,
        effects: &[Effect<Rgba>],
    );
}
Expand description

Implementation target for DrawShared

This is typically used via SharedState.

Required Associated Types§

Required Methods§

Source

fn max_texture_dimension_2d(&self) -> u32

Get the maximum 2D texture size

Source

fn set_raster_config(&mut self, config: &RasterConfig)

Set font raster config

Source

fn image_alloc(&mut self, size: (u32, u32)) -> Result<ImageId, AllocError>

Allocate an image

Use DrawSharedImpl::image_upload to set contents of the new image.

Source

fn image_upload(&mut self, id: ImageId, data: &[u8], format: ImageFormat)

Upload an image to the GPU

This should be called at least once on each image before display. May be called again to update the image contents.

Source

fn image_free(&mut self, id: ImageId)

Free an image allocation

Source

fn image_size(&self, id: ImageId) -> Option<(u32, u32)>

Query an image’s size

Source

fn draw_image( &self, draw: &mut Self::Draw, pass: PassId, id: ImageId, rect: Quad, )

Draw the image in the given rect

Source

fn draw_text( &mut self, draw: &mut Self::Draw, pass: PassId, rect: Rect, text: &TextDisplay, col: Rgba, )

Draw text with a colour

Source

fn draw_text_effects( &mut self, draw: &mut Self::Draw, pass: PassId, rect: Rect, text: &TextDisplay, col: Rgba, effects: &[Effect<()>], )

Draw text with a colour and effects

The effects list does not contain colour information, but may contain underlining/strikethrough information. It may be empty.

Source

fn draw_text_effects_rgba( &mut self, draw: &mut Self::Draw, pass: PassId, rect: Rect, text: &TextDisplay, effects: &[Effect<Rgba>], )

Draw text with effects

The effects list provides both underlining and colour information. If the effects list is empty or the first entry has start > 0, a default entity will be assumed.

Implementors§