Trait kas::draw::DrawShared
source · pub trait DrawShared {
// Required methods
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§
sourcefn image_alloc(&mut self, size: (u32, u32)) -> Result<ImageHandle, AllocError>
fn image_alloc(&mut self, size: (u32, u32)) -> 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],
format: ImageFormat
)
fn image_upload( &mut self, handle: &ImageHandle, 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.
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.
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