pub trait DrawShared {
// Required methods
fn image_alloc(
&mut self,
format: ImageFormat,
size: Size,
) -> Result<ImageHandle, AllocError>;
fn image_upload(
&mut self,
handle: &ImageHandle,
data: &[u8],
) -> Result<ActionRedraw, UploadError>;
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§
Sourcefn image_alloc(
&mut self,
format: ImageFormat,
size: Size,
) -> Result<ImageHandle, AllocError>
fn image_alloc( &mut self, format: ImageFormat, size: Size, ) -> Result<ImageHandle, AllocError>
Allocate an image
Use SharedState::image_upload to set contents of the new image.
Sourcefn image_upload(
&mut self,
handle: &ImageHandle,
data: &[u8],
) -> Result<ActionRedraw, UploadError>
fn image_upload( &mut self, handle: &ImageHandle, data: &[u8], ) -> Result<ActionRedraw, UploadError>
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.
The handle must point to an existing allocation of size (w, h) and
with image format format with b bytes-per-pixel such that
data.len() == b * w * h. Data must be in row-major order.
On success, this returns an ActionRedraw to indicate that any
widgets using this image will require a redraw.
Sourcefn image_free(&mut self, handle: ImageHandle)
fn image_free(&mut self, handle: ImageHandle)
Potentially free an image
The input handle is consumed. If this reduces its reference count to
zero, then the image is freed.
Sourcefn image_size(&self, handle: &ImageHandle) -> Option<Size>
fn image_size(&self, handle: &ImageHandle) -> Option<Size>
Get the size of an image