Trait g2d::Handle

source ·
pub trait Handle: Sized {
    // Required methods
    fn wgpu_device(&self) -> &Device;
    fn wgpu_queue(&self) -> &Queue;

    // Provided methods
    fn make_blank_texture(&self, size: Dimension) -> OwnedTexture<'_, Self> { ... }
    fn make_texture(
        &self,
        size: Dimension,
        data: &[u8]
    ) -> Result<OwnedTexture<'_, Self>, Error> { ... }
}
Expand description

A handle to the G2d API.

Required Methods§

source

fn wgpu_device(&self) -> &Device

The wgpu::Device this Handle uses.

source

fn wgpu_queue(&self) -> &Queue

The wgpu::Queue this Handle uses.

Provided Methods§

source

fn make_blank_texture(&self, size: Dimension) -> OwnedTexture<'_, Self>

Creates a new Texture with the provided size. Leaves the texture blank.

NOTE: G2d textures default to the Rgba8UnormSrgb format.

source

fn make_texture( &self, size: Dimension, data: &[u8] ) -> Result<OwnedTexture<'_, Self>, Error>

Creates a Texture with the provided size and data.

Expects the data to be in Rgba8UnormSrgb.

Fails

Fails if the data is too big or small for the provided size.

Object Safety§

This trait is not object safe.

Implementors§