Trait kas_core::draw::DrawShared

source ·
pub trait DrawShared {
    fn image_alloc(
        &mut self,
        size: (u32, u32)
    ) -> Result<ImageHandle, AllocError>; fn image_upload(
        &mut self,
        handle: &ImageHandle,
        data: &[u8],
        format: ImageFormat
    ); fn image_free(&mut self, handle: ImageHandle); fn image_size(&self, handle: &ImageHandle) -> Option<Size>; }
Expand description

Interface over SharedState

All methods concern management of resources for drawing.

Required Methods§

Allocate an image

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

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.

handle must refer to an allocation of some size (w, h), such that data.len() == b * w * h where b is the number of bytes per pixel, according to format. Data must be in row-major order.

Potentially free an image

The input handle is consumed. If this reduces its reference count to zero, then the image is freed.

Get the size of an image

Implementors§