From 5b3977daf6df624ca5d5e1a21ce282161234b22d Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 7 Mar 2023 06:09:51 +0100 Subject: Implement `vector` pipeline in `iced_tiny_skia` --- tiny_skia/src/backend.rs | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'tiny_skia/src/backend.rs') 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 { - // TODO - Size::new(0, 0) + self.vector_pipeline.viewport_dimensions(handle) } } -- cgit