Skip to main content

GPUBackendImpl

Trait GPUBackendImpl 

Source
pub trait GPUBackendImpl {
    type Texture: Texture;

Show 24 methods // Required methods fn begin_frame(&mut self); fn limits(&self) -> &DrawPhaseLimits; fn new_texture( &mut self, size: DeviceSize, format: ColorFormat, ) -> Self::Texture; fn load_alpha_vertices(&mut self, buffers: &VertexBuffers<()>); fn draw_alpha_triangles( &mut self, indices: &Range<u32>, texture: &mut Self::Texture, size_offset: u32, ); fn draw_alpha_triangles_with_scissor( &mut self, indices: &Range<u32>, texture: &mut Self::Texture, scissor: DeviceRect, size_offset: u32, ); fn load_alpha_size(&mut self, size: DeviceSize) -> u32; fn load_textures(&mut self, textures: &[&Self::Texture]); fn load_mask_layers(&mut self, layers: &[MaskLayer]) -> u32; fn load_color_vertices(&mut self, buffers: &VertexBuffers<ColorAttr>); fn load_img_data( &mut self, primitives: &[ImgPrimitive], buffers: &VertexBuffers<ImagePrimIndex>, ) -> u32; fn load_radial_gradient_data( &mut self, primitives: &[RadialGradientPrimitive], stops: &[GradientStopPrimitive], buffers: &VertexBuffers<RadialGradientPrimIndex>, ) -> (u32, u32); fn load_linear_gradient_data( &mut self, primitives: &[LinearGradientPrimitive], stops: &[GradientStopPrimitive], buffers: &VertexBuffers<LinearGradientPrimIndex>, ) -> (u32, u32); fn load_filter_data( &mut self, primitives: &FilterPrimitive, kernel_matrix: &[f32], buffers: &VertexBuffers<()>, ) -> u32; fn draw_color_triangles( &mut self, texture: &mut Self::Texture, indices: Range<u32>, clear: Option<Color>, mask_offset: u32, ); fn draw_img_triangles( &mut self, texture: &mut Self::Texture, indices: Range<u32>, clear: Option<Color>, mask_offset: u32, prims_offset: u32, ); fn draw_filter_triangles( &mut self, texture: &mut Self::Texture, origin: &Self::Texture, indices: Range<u32>, clear: Option<Color>, mask_offset: u32, prims_offset: u32, ); fn draw_radial_gradient_triangles( &mut self, texture: &mut Self::Texture, indices: Range<u32>, clear: Option<Color>, mask_offset: u32, prims_offset: u32, stops_offset: u32, ); fn draw_linear_gradient_triangles( &mut self, texture: &mut Self::Texture, indices: Range<u32>, clear: Option<Color>, mask_offset: u32, prims_offset: u32, stops_offset: u32, ); fn flush_draw_commands(&mut self); fn copy_texture_from_texture( &mut self, dest_tex: &mut Self::Texture, copy_to: DevicePoint, from_tex: &Self::Texture, from_rect: &DeviceRect, ); fn load_texture_data( &mut self, primitives: &[TexturePrimitive], buffers: &VertexBuffers<TexturePrimIndex>, ) -> u32; fn draw_texture_triangles( &mut self, texture: &mut Self::Texture, indices: Range<u32>, clear: Option<Color>, from_texture: &Self::Texture, mask_offset: u32, prims_offset: u32, ); fn end_frame(&mut self);
}
Expand description

Trait to help implement a gpu backend.

The call graph:

– begin_frame()

+—>–––– Draw Phase –––––––––––––+ | | | +->- new_texture()––+ |
| +-<—––<——<––+ | | v | -> load_alpha_vertices() | | | | -> + draw_alpha_triangles_with_scissor()–+ | | ^ v | | ^––<———–<———————+ | | | | -> + draw_alpha_triangles()—————+ | | ^ v | | +––<———–<———————+ | | | | -> load_textures() | | -> load_mask_layers() | | |
| +–––––––––––––+ | | | load_color_vertices() | | | +->| draw_color_triangles() | | | | +–––––––––––––+ | | | | | | +–––––––––––––+ | | | | load_img_primitives() | | | +->| load_image_vertices() | | | | | draw_img_triangles() | | | | +–––––––––––––+ | | | | | -> | +————————————+ | | | | load_radial_gradient_primitives() | v | +->| load_radial_gradient_stops() | | | | | load_radial_gradient_vertices() | | | | | draw_radial_gradient_triangles() | | | | +————————————+ | | | | | | +————————————+ | | | | load_linear_gradient_primitives() | | | +->| load_linear_gradient_stops() | | | | load_linear_gradient_vertices() | | | | draw_linear_gradient_triangles() | | | +————————————+ | +—<–––––––––––––––––––––––+

-+ ->- end_frame()

The coordinate always start from the left-top to right-bottom. Vertices use percent as value, and others use pixel value. Vertices Axis Device axis 0 +––x––+> 1 0 +––x—–+> width | | | |
y | y | | | | | +———+ +–––––+ v v 1 height

Required Associated Types§

Required Methods§

Source

fn begin_frame(&mut self)

A frame start, call once per frame

Source

fn limits(&self) -> &DrawPhaseLimits

Returns the limits of the GPU backend.

Source

fn new_texture( &mut self, size: DeviceSize, format: ColorFormat, ) -> Self::Texture

Create a texture.

Source

fn load_alpha_vertices(&mut self, buffers: &VertexBuffers<()>)

Load the vertices and indices buffer that draw_alpha_triangles & draw_alpha_triangles_with_scissor will use.

Source

fn draw_alpha_triangles( &mut self, indices: &Range<u32>, texture: &mut Self::Texture, size_offset: u32, )

Draw triangles only alpha channel with 1.0. Caller guarantee the texture format is ColorFormat::Alpha8, caller will try to batch as much as possible, but also possibly call multi times in a frame.

Source

fn draw_alpha_triangles_with_scissor( &mut self, indices: &Range<u32>, texture: &mut Self::Texture, scissor: DeviceRect, size_offset: u32, )

Same behavior as draw_alpha_triangles, but the Vertex with a offset and gives a clip rectangle for the texture, the path should only painting in the rectangle.

Source

fn load_alpha_size(&mut self, size: DeviceSize) -> u32

Source

fn load_textures(&mut self, textures: &[&Self::Texture])

load textures that will be use in this draw phase

Source

fn load_mask_layers(&mut self, layers: &[MaskLayer]) -> u32

load the mask layers that the current draw phase will use, called at most once per draw phase.

Source

fn load_color_vertices(&mut self, buffers: &VertexBuffers<ColorAttr>)

Load the vertices and indices buffer that draw_color_triangles will use.

Source

fn load_img_data( &mut self, primitives: &[ImgPrimitive], buffers: &VertexBuffers<ImagePrimIndex>, ) -> u32

Load the vertices and indices buffer that draw_img_triangles will use.

Source

fn load_radial_gradient_data( &mut self, primitives: &[RadialGradientPrimitive], stops: &[GradientStopPrimitive], buffers: &VertexBuffers<RadialGradientPrimIndex>, ) -> (u32, u32)

Load the primitives and gradient color stops that draw_radial_gradient_triangles will use.

Source

fn load_linear_gradient_data( &mut self, primitives: &[LinearGradientPrimitive], stops: &[GradientStopPrimitive], buffers: &VertexBuffers<LinearGradientPrimIndex>, ) -> (u32, u32)

Load the primitives and gradient color stops that draw_linear_gradient_triangles will use.

Source

fn load_filter_data( &mut self, primitives: &FilterPrimitive, kernel_matrix: &[f32], buffers: &VertexBuffers<()>, ) -> u32

load the filter

Source

fn draw_color_triangles( &mut self, texture: &mut Self::Texture, indices: Range<u32>, clear: Option<Color>, mask_offset: u32, )

Draw pure color triangles in the texture. And use the clear color clear the texture first if it’s a Some-Value

Source

fn draw_img_triangles( &mut self, texture: &mut Self::Texture, indices: Range<u32>, clear: Option<Color>, mask_offset: u32, prims_offset: u32, )

Draw triangles fill with image. And use the clear color clear the texture first if it’s a Some-Value

Source

fn draw_filter_triangles( &mut self, texture: &mut Self::Texture, origin: &Self::Texture, indices: Range<u32>, clear: Option<Color>, mask_offset: u32, prims_offset: u32, )

Source

fn draw_radial_gradient_triangles( &mut self, texture: &mut Self::Texture, indices: Range<u32>, clear: Option<Color>, mask_offset: u32, prims_offset: u32, stops_offset: u32, )

Draw triangles fill with color radial gradient. And use the clear color clear the texture first if it’s a Some-Value

Source

fn draw_linear_gradient_triangles( &mut self, texture: &mut Self::Texture, indices: Range<u32>, clear: Option<Color>, mask_offset: u32, prims_offset: u32, stops_offset: u32, )

Draw triangles fill with color linear gradient. And use the clear color clear the texture first if it’s a Some-Value

Source

fn flush_draw_commands(&mut self)

Flush any pending draw commands to the queue.

Source

fn copy_texture_from_texture( &mut self, dest_tex: &mut Self::Texture, copy_to: DevicePoint, from_tex: &Self::Texture, from_rect: &DeviceRect, )

Source

fn load_texture_data( &mut self, primitives: &[TexturePrimitive], buffers: &VertexBuffers<TexturePrimIndex>, ) -> u32

Load the primitives and vertices that draw_texture_triangles will use.

Source

fn draw_texture_triangles( &mut self, texture: &mut Self::Texture, indices: Range<u32>, clear: Option<Color>, from_texture: &Self::Texture, mask_offset: u32, prims_offset: u32, )

Draw triangles fill with texture. And use the clear color clear the texture first if it’s a Some-Value

Source

fn end_frame(&mut self)

A frame end, call once per frame

Implementors§