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,
pos: Vec2,
bb: Quad,
text: &TextDisplay,
col: Rgba,
);
fn draw_text_effects(
&mut self,
draw: &mut Self::Draw,
pass: PassId,
pos: Vec2,
bb: Quad,
text: &TextDisplay,
effects: &[Effect],
colors: &[Rgba],
);
}
Expand description
Implementation target for DrawShared
This is typically used via SharedState
.
Required Associated Types§
Required Methods§
Sourcefn max_texture_dimension_2d(&self) -> u32
fn max_texture_dimension_2d(&self) -> u32
Get the maximum 2D texture size
Sourcefn set_raster_config(&mut self, config: &RasterConfig)
fn set_raster_config(&mut self, config: &RasterConfig)
Set font raster config
Sourcefn image_alloc(&mut self, size: (u32, u32)) -> Result<ImageId, AllocError>
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.
Sourcefn image_upload(&mut self, id: ImageId, data: &[u8], format: ImageFormat)
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.
Sourcefn image_free(&mut self, id: ImageId)
fn image_free(&mut self, id: ImageId)
Free an image allocation
Sourcefn draw_image(
&self,
draw: &mut Self::Draw,
pass: PassId,
id: ImageId,
rect: Quad,
)
fn draw_image( &self, draw: &mut Self::Draw, pass: PassId, id: ImageId, rect: Quad, )
Draw the image in the given rect
Sourcefn draw_text(
&mut self,
draw: &mut Self::Draw,
pass: PassId,
pos: Vec2,
bb: Quad,
text: &TextDisplay,
col: Rgba,
)
fn draw_text( &mut self, draw: &mut Self::Draw, pass: PassId, pos: Vec2, bb: Quad, text: &TextDisplay, col: Rgba, )
Draw text with a colour
Sourcefn draw_text_effects(
&mut self,
draw: &mut Self::Draw,
pass: PassId,
pos: Vec2,
bb: Quad,
text: &TextDisplay,
effects: &[Effect],
colors: &[Rgba],
)
fn draw_text_effects( &mut self, draw: &mut Self::Draw, pass: PassId, pos: Vec2, bb: Quad, text: &TextDisplay, effects: &[Effect], colors: &[Rgba], )
Draw text with effects
The effects
list provides underlining/strikethrough information via
Effect::flags
and an index Effect::e
. If effects
is empty,
this is equivalent to Self::draw_text
.
Text colour lookup uses index e
and is essentially:
colors.get(e).unwrap_or(Rgba::BLACK)
.