From 87a613edd186461f1a8d224394043527a372571c Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 3 Aug 2024 16:23:30 +0200 Subject: Render text on top of images by default --- tiny_skia/src/lib.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'tiny_skia') diff --git a/tiny_skia/src/lib.rs b/tiny_skia/src/lib.rs index 1aabff00..6ec60158 100644 --- a/tiny_skia/src/lib.rs +++ b/tiny_skia/src/lib.rs @@ -178,6 +178,16 @@ impl Renderer { engine::adjust_clip_mask(clip_mask, clip_bounds); } + for image in &layer.images { + self.engine.draw_image( + image, + Transformation::scale(scale_factor), + pixels, + clip_mask, + clip_bounds, + ); + } + for group in &layer.text { for text in group.as_slice() { self.engine.draw_text( @@ -190,16 +200,6 @@ impl Renderer { ); } } - - for image in &layer.images { - self.engine.draw_image( - image, - Transformation::scale(scale_factor), - pixels, - clip_mask, - clip_bounds, - ); - } } if !overlay.is_empty() { -- cgit From 0ceee1cf3ae49f5bd0e3f2b346a4b34076e4523a Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 4 Aug 2024 03:28:43 +0200 Subject: Implement image support for `canvas` widget --- tiny_skia/Cargo.toml | 2 +- tiny_skia/src/engine.rs | 1 + tiny_skia/src/geometry.rs | 86 +++++++++++++++++++++++++++++++++++++++++++++-- tiny_skia/src/layer.rs | 43 ++++++++++++++++++++++++ tiny_skia/src/lib.rs | 11 +++++- 5 files changed, 138 insertions(+), 5 deletions(-) (limited to 'tiny_skia') diff --git a/tiny_skia/Cargo.toml b/tiny_skia/Cargo.toml index 32ead3e0..323233f0 100644 --- a/tiny_skia/Cargo.toml +++ b/tiny_skia/Cargo.toml @@ -15,7 +15,7 @@ workspace = true [features] image = ["iced_graphics/image"] -svg = ["resvg"] +svg = ["iced_graphics/svg", "resvg"] geometry = ["iced_graphics/geometry"] [dependencies] diff --git a/tiny_skia/src/engine.rs b/tiny_skia/src/engine.rs index 898657c8..c5c4d494 100644 --- a/tiny_skia/src/engine.rs +++ b/tiny_skia/src/engine.rs @@ -556,6 +556,7 @@ impl Engine { bounds, rotation, opacity, + snap: _, } => { let physical_bounds = *bounds * _transformation; diff --git a/tiny_skia/src/geometry.rs b/tiny_skia/src/geometry.rs index 02b6e1b9..398b54f7 100644 --- a/tiny_skia/src/geometry.rs +++ b/tiny_skia/src/geometry.rs @@ -1,10 +1,12 @@ +use crate::core::image; +use crate::core::svg; use crate::core::text::LineHeight; -use crate::core::{Pixels, Point, Radians, Rectangle, Size, Vector}; +use crate::core::{Color, Pixels, Point, Radians, Rectangle, Size, Vector}; use crate::graphics::cache::{self, Cached}; use crate::graphics::geometry::fill::{self, Fill}; use crate::graphics::geometry::stroke::{self, Stroke}; use crate::graphics::geometry::{self, Path, Style}; -use crate::graphics::{Gradient, Text}; +use crate::graphics::{Gradient, Image, Text}; use crate::Primitive; use std::rc::Rc; @@ -13,6 +15,7 @@ use std::rc::Rc; pub enum Geometry { Live { text: Vec, + images: Vec, primitives: Vec, clip_bounds: Rectangle, }, @@ -22,6 +25,7 @@ pub enum Geometry { #[derive(Debug, Clone)] pub struct Cache { pub text: Rc<[Text]>, + pub images: Rc<[Image]>, pub primitives: Rc<[Primitive]>, pub clip_bounds: Rectangle, } @@ -37,10 +41,12 @@ impl Cached for Geometry { match self { Self::Live { primitives, + images, text, clip_bounds, } => Cache { primitives: Rc::from(primitives), + images: Rc::from(images), text: Rc::from(text), clip_bounds, }, @@ -55,6 +61,7 @@ pub struct Frame { transform: tiny_skia::Transform, stack: Vec, primitives: Vec, + images: Vec, text: Vec, } @@ -68,6 +75,7 @@ impl Frame { clip_bounds, stack: Vec::new(), primitives: Vec::new(), + images: Vec::new(), text: Vec::new(), transform: tiny_skia::Transform::from_translate( clip_bounds.x, @@ -238,7 +246,7 @@ impl geometry::frame::Backend for Frame { Self::with_clip(clip_bounds) } - fn paste(&mut self, frame: Self, _at: Point) { + fn paste(&mut self, frame: Self) { self.primitives.extend(frame.primitives); self.text.extend(frame.text); } @@ -269,10 +277,82 @@ impl geometry::frame::Backend for Frame { fn into_geometry(self) -> Geometry { Geometry::Live { primitives: self.primitives, + images: self.images, text: self.text, clip_bounds: self.clip_bounds, } } + + fn draw_image( + &mut self, + handle: &image::Handle, + bounds: Rectangle, + filter_method: image::FilterMethod, + rotation: Radians, + opacity: f32, + ) { + let (bounds, external_rotation) = + transform_rectangle(bounds, self.transform); + + self.images.push(Image::Raster { + handle: handle.clone(), + filter_method, + bounds, + rotation: rotation + external_rotation, + opacity, + snap: false, + }); + } + + fn draw_svg( + &mut self, + handle: &svg::Handle, + bounds: Rectangle, + color: Option, + rotation: Radians, + opacity: f32, + ) { + let (bounds, external_rotation) = + transform_rectangle(bounds, self.transform); + + self.images.push(Image::Vector { + handle: handle.clone(), + bounds, + color, + rotation: rotation + external_rotation, + opacity, + }); + } +} + +fn transform_rectangle( + rectangle: Rectangle, + transform: tiny_skia::Transform, +) -> (Rectangle, Radians) { + let mut top_left = tiny_skia::Point { + x: rectangle.x, + y: rectangle.y, + }; + + let mut top_right = tiny_skia::Point { + x: rectangle.x + rectangle.width, + y: rectangle.y, + }; + + let mut bottom_left = tiny_skia::Point { + x: rectangle.x, + y: rectangle.y + rectangle.height, + }; + + transform.map_point(&mut top_left); + transform.map_point(&mut top_right); + transform.map_point(&mut bottom_left); + + Rectangle::with_vertices( + Point::new(top_left.x, top_left.y), + Point::new(top_right.x, top_right.y), + Point::new(bottom_left.x, bottom_left.y), + ) } fn convert_path(path: &Path) -> Option { diff --git a/tiny_skia/src/layer.rs b/tiny_skia/src/layer.rs index 48fca1d8..9a169f46 100644 --- a/tiny_skia/src/layer.rs +++ b/tiny_skia/src/layer.rs @@ -116,6 +116,48 @@ impl Layer { } pub fn draw_image( + &mut self, + image: &Image, + transformation: Transformation, + ) { + match image { + Image::Raster { + handle, + filter_method, + bounds, + rotation, + opacity, + snap: _, + } => { + self.draw_raster( + handle.clone(), + *filter_method, + *bounds, + transformation, + *rotation, + *opacity, + ); + } + Image::Vector { + handle, + color, + bounds, + rotation, + opacity, + } => { + self.draw_svg( + handle.clone(), + *color, + *bounds, + transformation, + *rotation, + *opacity, + ); + } + } + } + + pub fn draw_raster( &mut self, handle: image::Handle, filter_method: image::FilterMethod, @@ -130,6 +172,7 @@ impl Layer { bounds: bounds * transformation, rotation, opacity, + snap: false, }; self.images.push(image); diff --git a/tiny_skia/src/lib.rs b/tiny_skia/src/lib.rs index 6ec60158..f09e5aa3 100644 --- a/tiny_skia/src/lib.rs +++ b/tiny_skia/src/lib.rs @@ -330,6 +330,7 @@ impl graphics::geometry::Renderer for Renderer { match geometry { Geometry::Live { primitives, + images, text, clip_bounds, } => { @@ -339,6 +340,10 @@ impl graphics::geometry::Renderer for Renderer { transformation, ); + for image in images { + layer.draw_image(&image, transformation); + } + layer.draw_text_group(text, clip_bounds, transformation); } Geometry::Cache(cache) => { @@ -348,6 +353,10 @@ impl graphics::geometry::Renderer for Renderer { transformation, ); + for image in cache.images.iter() { + layer.draw_image(image, transformation); + } + layer.draw_text_cache( cache.text, cache.clip_bounds, @@ -381,7 +390,7 @@ impl core::image::Renderer for Renderer { opacity: f32, ) { let (layer, transformation) = self.layers.current_mut(); - layer.draw_image( + layer.draw_raster( handle, filter_method, bounds, -- cgit From 92bd3ecd6b4a6618f0fc725dea3694c3b40e5314 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 4 Aug 2024 04:30:12 +0200 Subject: Introduce `Image` struct in `core::image` --- tiny_skia/src/engine.rs | 17 +++++--------- tiny_skia/src/geometry.rs | 35 ++++++++++------------------- tiny_skia/src/layer.rs | 57 ++++++++++++++--------------------------------- tiny_skia/src/lib.rs | 22 ++++-------------- 4 files changed, 38 insertions(+), 93 deletions(-) (limited to 'tiny_skia') diff --git a/tiny_skia/src/engine.rs b/tiny_skia/src/engine.rs index c5c4d494..88e8a9b1 100644 --- a/tiny_skia/src/engine.rs +++ b/tiny_skia/src/engine.rs @@ -550,14 +550,7 @@ impl Engine { ) { match image { #[cfg(feature = "image")] - Image::Raster { - handle, - filter_method, - bounds, - rotation, - opacity, - snap: _, - } => { + Image::Raster(raster, bounds) => { let physical_bounds = *bounds * _transformation; if !_clip_bounds.intersects(&physical_bounds) { @@ -568,7 +561,7 @@ impl Engine { .then_some(_clip_mask as &_); let center = physical_bounds.center(); - let radians = f32::from(*rotation); + let radians = f32::from(raster.rotation); let transform = into_transform(_transformation).post_rotate_at( radians.to_degrees(), @@ -577,10 +570,10 @@ impl Engine { ); self.raster_pipeline.draw( - handle, - *filter_method, + &raster.handle, + raster.filter_method, *bounds, - *opacity, + raster.opacity, _pixels, transform, clip_mask, diff --git a/tiny_skia/src/geometry.rs b/tiny_skia/src/geometry.rs index 398b54f7..7b0e68f4 100644 --- a/tiny_skia/src/geometry.rs +++ b/tiny_skia/src/geometry.rs @@ -1,12 +1,11 @@ -use crate::core::image; use crate::core::svg; use crate::core::text::LineHeight; use crate::core::{Color, Pixels, Point, Radians, Rectangle, Size, Vector}; use crate::graphics::cache::{self, Cached}; use crate::graphics::geometry::fill::{self, Fill}; use crate::graphics::geometry::stroke::{self, Stroke}; -use crate::graphics::geometry::{self, Path, Style}; -use crate::graphics::{Gradient, Image, Text}; +use crate::graphics::geometry::{self, Image, Path, Style}; +use crate::graphics::{self, Gradient, Text}; use crate::Primitive; use std::rc::Rc; @@ -15,7 +14,7 @@ use std::rc::Rc; pub enum Geometry { Live { text: Vec, - images: Vec, + images: Vec, primitives: Vec, clip_bounds: Rectangle, }, @@ -25,7 +24,7 @@ pub enum Geometry { #[derive(Debug, Clone)] pub struct Cache { pub text: Rc<[Text]>, - pub images: Rc<[Image]>, + pub images: Rc<[graphics::Image]>, pub primitives: Rc<[Primitive]>, pub clip_bounds: Rectangle, } @@ -61,7 +60,7 @@ pub struct Frame { transform: tiny_skia::Transform, stack: Vec, primitives: Vec, - images: Vec, + images: Vec, text: Vec, } @@ -283,25 +282,15 @@ impl geometry::frame::Backend for Frame { } } - fn draw_image( - &mut self, - handle: &image::Handle, - bounds: Rectangle, - filter_method: image::FilterMethod, - rotation: Radians, - opacity: f32, - ) { + fn draw_image(&mut self, bounds: Rectangle, image: impl Into) { + let mut image = image.into(); + let (bounds, external_rotation) = transform_rectangle(bounds, self.transform); - self.images.push(Image::Raster { - handle: handle.clone(), - filter_method, - bounds, - rotation: rotation + external_rotation, - opacity, - snap: false, - }); + image.rotation += external_rotation; + + self.images.push(graphics::Image::Raster(image, bounds)); } fn draw_svg( @@ -315,7 +304,7 @@ impl geometry::frame::Backend for Frame { let (bounds, external_rotation) = transform_rectangle(bounds, self.transform); - self.images.push(Image::Vector { + self.images.push(graphics::Image::Vector { handle: handle.clone(), bounds, color, diff --git a/tiny_skia/src/layer.rs b/tiny_skia/src/layer.rs index 9a169f46..33df0a86 100644 --- a/tiny_skia/src/layer.rs +++ b/tiny_skia/src/layer.rs @@ -1,11 +1,12 @@ +use crate::core::renderer::Quad; +use crate::core::svg; use crate::core::{ - image, renderer::Quad, svg, Background, Color, Point, Radians, Rectangle, - Transformation, + Background, Color, Image, Point, Radians, Rectangle, Transformation, }; +use crate::graphics; use crate::graphics::damage; use crate::graphics::layer; use crate::graphics::text::{Editor, Paragraph, Text}; -use crate::graphics::{self, Image}; use crate::Primitive; use std::rc::Rc; @@ -18,7 +19,7 @@ pub struct Layer { pub quads: Vec<(Quad, Background)>, pub primitives: Vec>, pub text: Vec>, - pub images: Vec, + pub images: Vec, } impl Layer { @@ -117,28 +118,14 @@ impl Layer { pub fn draw_image( &mut self, - image: &Image, + image: graphics::Image, transformation: Transformation, ) { match image { - Image::Raster { - handle, - filter_method, - bounds, - rotation, - opacity, - snap: _, - } => { - self.draw_raster( - handle.clone(), - *filter_method, - *bounds, - transformation, - *rotation, - *opacity, - ); + graphics::Image::Raster(raster, bounds) => { + self.draw_raster(raster.clone(), bounds, transformation); } - Image::Vector { + graphics::Image::Vector { handle, color, bounds, @@ -147,11 +134,11 @@ impl Layer { } => { self.draw_svg( handle.clone(), - *color, - *bounds, + color, + bounds, transformation, - *rotation, - *opacity, + rotation, + opacity, ); } } @@ -159,21 +146,11 @@ impl Layer { pub fn draw_raster( &mut self, - handle: image::Handle, - filter_method: image::FilterMethod, + image: Image, bounds: Rectangle, transformation: Transformation, - rotation: Radians, - opacity: f32, ) { - let image = Image::Raster { - handle, - filter_method, - bounds: bounds * transformation, - rotation, - opacity, - snap: false, - }; + let image = graphics::Image::Raster(image, bounds * transformation); self.images.push(image); } @@ -187,7 +164,7 @@ impl Layer { rotation: Radians, opacity: f32, ) { - let svg = Image::Vector { + let svg = graphics::Image::Vector { handle, color, bounds: bounds * transformation, @@ -304,7 +281,7 @@ impl Layer { &previous.images, ¤t.images, |image| vec![image.bounds().expand(1.0)], - Image::eq, + graphics::Image::eq, ); damage.extend(text); diff --git a/tiny_skia/src/lib.rs b/tiny_skia/src/lib.rs index f09e5aa3..00864c11 100644 --- a/tiny_skia/src/lib.rs +++ b/tiny_skia/src/lib.rs @@ -341,7 +341,7 @@ impl graphics::geometry::Renderer for Renderer { ); for image in images { - layer.draw_image(&image, transformation); + layer.draw_image(image, transformation); } layer.draw_text_group(text, clip_bounds, transformation); @@ -354,7 +354,7 @@ impl graphics::geometry::Renderer for Renderer { ); for image in cache.images.iter() { - layer.draw_image(image, transformation); + layer.draw_image(image.clone(), transformation); } layer.draw_text_cache( @@ -381,23 +381,9 @@ impl core::image::Renderer for Renderer { self.engine.raster_pipeline.dimensions(handle) } - fn draw_image( - &mut self, - handle: Self::Handle, - filter_method: core::image::FilterMethod, - bounds: Rectangle, - rotation: core::Radians, - opacity: f32, - ) { + fn draw_image(&mut self, image: core::Image, bounds: Rectangle) { let (layer, transformation) = self.layers.current_mut(); - layer.draw_raster( - handle, - filter_method, - bounds, - transformation, - rotation, - opacity, - ); + layer.draw_raster(image, bounds, transformation); } } -- cgit From 8708101c892540ffc966cf7ee9d66ca5cd2e8ca6 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 4 Aug 2024 04:33:30 +0200 Subject: Simplify types in `tiny_skia::layer` --- tiny_skia/src/layer.rs | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'tiny_skia') diff --git a/tiny_skia/src/layer.rs b/tiny_skia/src/layer.rs index 33df0a86..5d3cb07b 100644 --- a/tiny_skia/src/layer.rs +++ b/tiny_skia/src/layer.rs @@ -1,12 +1,12 @@ use crate::core::renderer::Quad; use crate::core::svg; use crate::core::{ - Background, Color, Image, Point, Radians, Rectangle, Transformation, + self, Background, Color, Point, Radians, Rectangle, Transformation, }; -use crate::graphics; use crate::graphics::damage; use crate::graphics::layer; use crate::graphics::text::{Editor, Paragraph, Text}; +use crate::graphics::{self, Image}; use crate::Primitive; use std::rc::Rc; @@ -19,7 +19,7 @@ pub struct Layer { pub quads: Vec<(Quad, Background)>, pub primitives: Vec>, pub text: Vec>, - pub images: Vec, + pub images: Vec, } impl Layer { @@ -73,7 +73,7 @@ impl Layer { pub fn draw_text( &mut self, - text: crate::core::Text, + text: core::Text, position: Point, color: Color, clip_bounds: Rectangle, @@ -116,16 +116,12 @@ impl Layer { .push(Item::Cached(text, clip_bounds, transformation)); } - pub fn draw_image( - &mut self, - image: graphics::Image, - transformation: Transformation, - ) { + pub fn draw_image(&mut self, image: Image, transformation: Transformation) { match image { - graphics::Image::Raster(raster, bounds) => { + Image::Raster(raster, bounds) => { self.draw_raster(raster.clone(), bounds, transformation); } - graphics::Image::Vector { + Image::Vector { handle, color, bounds, @@ -146,11 +142,11 @@ impl Layer { pub fn draw_raster( &mut self, - image: Image, + image: core::Image, bounds: Rectangle, transformation: Transformation, ) { - let image = graphics::Image::Raster(image, bounds * transformation); + let image = Image::Raster(image, bounds * transformation); self.images.push(image); } @@ -164,7 +160,7 @@ impl Layer { rotation: Radians, opacity: f32, ) { - let svg = graphics::Image::Vector { + let svg = Image::Vector { handle, color, bounds: bounds * transformation, @@ -281,7 +277,7 @@ impl Layer { &previous.images, ¤t.images, |image| vec![image.bounds().expand(1.0)], - graphics::Image::eq, + Image::eq, ); damage.extend(text); @@ -313,7 +309,7 @@ impl graphics::Layer for Layer { fn flush(&mut self) {} - fn resize(&mut self, bounds: graphics::core::Rectangle) { + fn resize(&mut self, bounds: Rectangle) { self.bounds = bounds; } -- cgit From d4b08462e5a25929ec4df32f242898986902af56 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 4 Aug 2024 04:52:55 +0200 Subject: Introduce `Svg` struct in `core::svg` --- tiny_skia/src/engine.rs | 16 +++++----------- tiny_skia/src/geometry.rs | 30 ++++++++++-------------------- tiny_skia/src/layer.rs | 35 ++++++----------------------------- tiny_skia/src/lib.rs | 18 ++---------------- 4 files changed, 23 insertions(+), 76 deletions(-) (limited to 'tiny_skia') diff --git a/tiny_skia/src/engine.rs b/tiny_skia/src/engine.rs index 88e8a9b1..196c36cf 100644 --- a/tiny_skia/src/engine.rs +++ b/tiny_skia/src/engine.rs @@ -580,13 +580,7 @@ impl Engine { ); } #[cfg(feature = "svg")] - Image::Vector { - handle, - color, - bounds, - rotation, - opacity, - } => { + Image::Vector(svg, bounds) => { let physical_bounds = *bounds * _transformation; if !_clip_bounds.intersects(&physical_bounds) { @@ -597,7 +591,7 @@ impl Engine { .then_some(_clip_mask as &_); let center = physical_bounds.center(); - let radians = f32::from(*rotation); + let radians = f32::from(svg.rotation); let transform = into_transform(_transformation).post_rotate_at( radians.to_degrees(), @@ -606,10 +600,10 @@ impl Engine { ); self.vector_pipeline.draw( - handle, - *color, + &svg.handle, + svg.color, physical_bounds, - *opacity, + svg.opacity, _pixels, transform, clip_mask, diff --git a/tiny_skia/src/geometry.rs b/tiny_skia/src/geometry.rs index 7b0e68f4..659612d1 100644 --- a/tiny_skia/src/geometry.rs +++ b/tiny_skia/src/geometry.rs @@ -1,11 +1,10 @@ -use crate::core::svg; use crate::core::text::LineHeight; -use crate::core::{Color, Pixels, Point, Radians, Rectangle, Size, Vector}; +use crate::core::{self, Pixels, Point, Radians, Rectangle, Size, Svg, Vector}; use crate::graphics::cache::{self, Cached}; use crate::graphics::geometry::fill::{self, Fill}; use crate::graphics::geometry::stroke::{self, Stroke}; -use crate::graphics::geometry::{self, Image, Path, Style}; -use crate::graphics::{self, Gradient, Text}; +use crate::graphics::geometry::{self, Path, Style}; +use crate::graphics::{self, Gradient, Image, Text}; use crate::Primitive; use std::rc::Rc; @@ -282,7 +281,7 @@ impl geometry::frame::Backend for Frame { } } - fn draw_image(&mut self, bounds: Rectangle, image: impl Into) { + fn draw_image(&mut self, bounds: Rectangle, image: impl Into) { let mut image = image.into(); let (bounds, external_rotation) = @@ -293,24 +292,15 @@ impl geometry::frame::Backend for Frame { self.images.push(graphics::Image::Raster(image, bounds)); } - fn draw_svg( - &mut self, - handle: &svg::Handle, - bounds: Rectangle, - color: Option, - rotation: Radians, - opacity: f32, - ) { + fn draw_svg(&mut self, bounds: Rectangle, svg: impl Into) { + let mut svg = svg.into(); + let (bounds, external_rotation) = transform_rectangle(bounds, self.transform); - self.images.push(graphics::Image::Vector { - handle: handle.clone(), - bounds, - color, - rotation: rotation + external_rotation, - opacity, - }); + svg.rotation += external_rotation; + + self.images.push(Image::Vector(svg, bounds)); } } diff --git a/tiny_skia/src/layer.rs b/tiny_skia/src/layer.rs index 5d3cb07b..bdfd4d38 100644 --- a/tiny_skia/src/layer.rs +++ b/tiny_skia/src/layer.rs @@ -1,7 +1,6 @@ use crate::core::renderer::Quad; -use crate::core::svg; use crate::core::{ - self, Background, Color, Point, Radians, Rectangle, Transformation, + self, Background, Color, Point, Rectangle, Svg, Transformation, }; use crate::graphics::damage; use crate::graphics::layer; @@ -119,23 +118,10 @@ impl Layer { pub fn draw_image(&mut self, image: Image, transformation: Transformation) { match image { Image::Raster(raster, bounds) => { - self.draw_raster(raster.clone(), bounds, transformation); + self.draw_raster(raster, bounds, transformation); } - Image::Vector { - handle, - color, - bounds, - rotation, - opacity, - } => { - self.draw_svg( - handle.clone(), - color, - bounds, - transformation, - rotation, - opacity, - ); + Image::Vector(svg, bounds) => { + self.draw_svg(svg, bounds, transformation); } } } @@ -153,20 +139,11 @@ impl Layer { pub fn draw_svg( &mut self, - handle: svg::Handle, - color: Option, + svg: Svg, bounds: Rectangle, transformation: Transformation, - rotation: Radians, - opacity: f32, ) { - let svg = Image::Vector { - handle, - color, - bounds: bounds * transformation, - rotation, - opacity, - }; + let svg = Image::Vector(svg, bounds * transformation); self.images.push(svg); } diff --git a/tiny_skia/src/lib.rs b/tiny_skia/src/lib.rs index 00864c11..758921d4 100644 --- a/tiny_skia/src/lib.rs +++ b/tiny_skia/src/lib.rs @@ -396,23 +396,9 @@ impl core::svg::Renderer for Renderer { self.engine.vector_pipeline.viewport_dimensions(handle) } - fn draw_svg( - &mut self, - handle: core::svg::Handle, - color: Option, - bounds: Rectangle, - rotation: core::Radians, - opacity: f32, - ) { + fn draw_svg(&mut self, svg: core::Svg, bounds: Rectangle) { let (layer, transformation) = self.layers.current_mut(); - layer.draw_svg( - handle, - color, - bounds, - transformation, - rotation, - opacity, - ); + layer.draw_svg(svg, bounds, transformation); } } -- cgit