1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
pub use crate::context::{CompositeOperationState, ImageId, Path, Vertex}; pub use crate::*; #[derive(Debug, Copy, Clone)] pub enum TextureType { RGBA, Alpha, } #[derive(Debug, Copy, Clone)] pub struct Scissor { pub xform: Transform, pub extent: Extent, } pub trait Renderer { fn edge_antialias(&self) -> bool; fn create_texture( &mut self, texture_type: TextureType, width: usize, height: usize, flags: ImageFlags, data: Option<&[u8]>, ) -> anyhow::Result<ImageId>; fn delete_texture(&mut self, handle: ImageId) -> anyhow::Result<()>; fn update_texture( &mut self, handle: ImageId, x: usize, y: usize, width: usize, height: usize, data: &[u8], ) -> anyhow::Result<()>; fn texture_size(&self, handle: ImageId) -> anyhow::Result<(usize, usize)>; fn viewport(&mut self, extent: Extent, device_pixel_ratio: f32) -> anyhow::Result<()>; fn cancel(&mut self) -> anyhow::Result<()>; fn flush(&mut self) -> anyhow::Result<()>; fn fill( &mut self, paint: &Paint, composite_operation: CompositeOperationState, scissor: &Scissor, fringe: f32, bounds: Bounds, paths: &[Path], ) -> anyhow::Result<()>; fn stroke( &mut self, paint: &Paint, composite_operation: CompositeOperationState, scissor: &Scissor, fringe: f32, stroke_width: f32, paths: &[Path], ) -> anyhow::Result<()>; fn triangles( &mut self, paint: &Paint, composite_operation: CompositeOperationState, scissor: &Scissor, vertexes: &[Vertex], ) -> anyhow::Result<()>; }