diff options
author | 2023-03-07 06:09:51 +0100 | |
---|---|---|
committer | 2023-03-07 06:09:51 +0100 | |
commit | 5b3977daf6df624ca5d5e1a21ce282161234b22d (patch) | |
tree | c0efb1cda1dde399b60b89a2d57dc39feecca2cd /tiny_skia/src/backend.rs | |
parent | bb49e17cabd45f3a21af98b4c5ecdddd507fd427 (diff) | |
download | iced-5b3977daf6df624ca5d5e1a21ce282161234b22d.tar.gz iced-5b3977daf6df624ca5d5e1a21ce282161234b22d.tar.bz2 iced-5b3977daf6df624ca5d5e1a21ce282161234b22d.zip |
Implement `vector` pipeline in `iced_tiny_skia`
Diffstat (limited to 'tiny_skia/src/backend.rs')
-rw-r--r-- | tiny_skia/src/backend.rs | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/tiny_skia/src/backend.rs b/tiny_skia/src/backend.rs index d894ab95..3c2a97b9 100644 --- a/tiny_skia/src/backend.rs +++ b/tiny_skia/src/backend.rs @@ -14,6 +14,9 @@ pub struct Backend { #[cfg(feature = "image")] raster_pipeline: crate::raster::Pipeline, + + #[cfg(feature = "svg")] + vector_pipeline: crate::vector::Pipeline, } impl Backend { @@ -25,6 +28,9 @@ impl Backend { #[cfg(feature = "image")] raster_pipeline: crate::raster::Pipeline::new(), + + #[cfg(feature = "svg")] + vector_pipeline: crate::vector::Pipeline::new(), } } @@ -78,7 +84,10 @@ impl Backend { ); } - self.text_pipeline.end_frame(); + self.text_pipeline.trim_cache(); + + #[cfg(feature = "svg")] + self.vector_pipeline.trim_cache(); } fn draw_primitive( @@ -181,8 +190,18 @@ impl Backend { clip_bounds.map(|_| clip_mask as &_), ); } - Primitive::Svg { .. } => { - // TODO + #[cfg(feature = "svg")] + Primitive::Svg { + handle, + bounds, + color: _, // TODO: Implement color filter + } => { + self.vector_pipeline.draw( + handle, + (*bounds + translation) * scale_factor, + pixels, + clip_bounds.map(|_| clip_mask as &_), + ); } Primitive::Fill { path, @@ -518,9 +537,8 @@ impl backend::Image for Backend { impl backend::Svg for Backend { fn viewport_dimensions( &self, - _handle: &crate::core::svg::Handle, + handle: &crate::core::svg::Handle, ) -> Size<u32> { - // TODO - Size::new(0, 0) + self.vector_pipeline.viewport_dimensions(handle) } } |