diff options
| author | 2024-05-08 19:16:06 +0900 | |
|---|---|---|
| committer | 2024-05-08 19:16:06 +0900 | |
| commit | 477887b3870aa5fbdab96c3a06f3b930462d7842 (patch) | |
| tree | 2b3272bb178f8757169511966589fe6a106733f4 /tiny_skia | |
| parent | 0ebe0629cef37aee5c48b9409fc36618a3a3e60d (diff) | |
| parent | e07b42ac96b8d098a883c93afe828a439f479c7b (diff) | |
| download | iced-477887b3870aa5fbdab96c3a06f3b930462d7842.tar.gz iced-477887b3870aa5fbdab96c3a06f3b930462d7842.tar.bz2 iced-477887b3870aa5fbdab96c3a06f3b930462d7842.zip | |
Merge branch 'master' of https://github.com/iced-rs/iced into iced-rs-master
Diffstat (limited to 'tiny_skia')
| -rw-r--r-- | tiny_skia/src/engine.rs | 27 | ||||
| -rw-r--r-- | tiny_skia/src/geometry.rs | 5 | ||||
| -rw-r--r-- | tiny_skia/src/layer.rs | 16 | ||||
| -rw-r--r-- | tiny_skia/src/lib.rs | 22 | ||||
| -rw-r--r-- | tiny_skia/src/raster.rs | 8 | ||||
| -rw-r--r-- | tiny_skia/src/vector.rs | 10 | 
6 files changed, 74 insertions, 14 deletions
| diff --git a/tiny_skia/src/engine.rs b/tiny_skia/src/engine.rs index fbca1274..028b304f 100644 --- a/tiny_skia/src/engine.rs +++ b/tiny_skia/src/engine.rs @@ -550,6 +550,8 @@ impl Engine {                  handle,                  filter_method,                  bounds, +                rotation, +                opacity,              } => {                  let physical_bounds = *bounds * _transformation; @@ -560,12 +562,22 @@ impl Engine {                  let clip_mask = (!physical_bounds.is_within(&_clip_bounds))                      .then_some(_clip_mask as &_); +                let center = physical_bounds.center(); +                let radians = f32::from(*rotation); + +                let transform = into_transform(_transformation).post_rotate_at( +                    radians.to_degrees(), +                    center.x, +                    center.y, +                ); +                  self.raster_pipeline.draw(                      handle,                      *filter_method,                      *bounds, +                    *opacity,                      _pixels, -                    into_transform(_transformation), +                    transform,                      clip_mask,                  );              } @@ -574,6 +586,8 @@ impl Engine {                  handle,                  color,                  bounds, +                rotation, +                opacity,              } => {                  let physical_bounds = *bounds * _transformation; @@ -584,11 +598,22 @@ impl Engine {                  let clip_mask = (!physical_bounds.is_within(&_clip_bounds))                      .then_some(_clip_mask as &_); +                let center = physical_bounds.center(); +                let radians = f32::from(*rotation); + +                let transform = into_transform(_transformation).post_rotate_at( +                    radians.to_degrees(), +                    center.x, +                    center.y, +                ); +                  self.vector_pipeline.draw(                      handle,                      *color,                      physical_bounds, +                    *opacity,                      _pixels, +                    transform,                      clip_mask,                  );              } diff --git a/tiny_skia/src/geometry.rs b/tiny_skia/src/geometry.rs index 117daf41..02b6e1b9 100644 --- a/tiny_skia/src/geometry.rs +++ b/tiny_skia/src/geometry.rs @@ -1,9 +1,10 @@  use crate::core::text::LineHeight;  use crate::core::{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::{Cached, Gradient, Text}; +use crate::graphics::{Gradient, Text};  use crate::Primitive;  use std::rc::Rc; @@ -32,7 +33,7 @@ impl Cached for Geometry {          Self::Cache(cache.clone())      } -    fn cache(self, _previous: Option<Cache>) -> Cache { +    fn cache(self, _group: cache::Group, _previous: Option<Cache>) -> Cache {          match self {              Self::Live {                  primitives, diff --git a/tiny_skia/src/layer.rs b/tiny_skia/src/layer.rs index 3e42e4aa..48fca1d8 100644 --- a/tiny_skia/src/layer.rs +++ b/tiny_skia/src/layer.rs @@ -1,7 +1,7 @@ -use crate::core::image; -use crate::core::renderer::Quad; -use crate::core::svg; -use crate::core::{Background, Color, Point, Rectangle, Transformation}; +use crate::core::{ +    image, renderer::Quad, svg, Background, Color, Point, Radians, Rectangle, +    Transformation, +};  use crate::graphics::damage;  use crate::graphics::layer;  use crate::graphics::text::{Editor, Paragraph, Text}; @@ -121,11 +121,15 @@ impl Layer {          filter_method: image::FilterMethod,          bounds: Rectangle,          transformation: Transformation, +        rotation: Radians, +        opacity: f32,      ) {          let image = Image::Raster {              handle,              filter_method,              bounds: bounds * transformation, +            rotation, +            opacity,          };          self.images.push(image); @@ -137,11 +141,15 @@ impl Layer {          color: Option<Color>,          bounds: Rectangle,          transformation: Transformation, +        rotation: Radians, +        opacity: f32,      ) {          let svg = Image::Vector {              handle,              color,              bounds: bounds * transformation, +            rotation, +            opacity,          };          self.images.push(svg); diff --git a/tiny_skia/src/lib.rs b/tiny_skia/src/lib.rs index 4c2c9430..1aabff00 100644 --- a/tiny_skia/src/lib.rs +++ b/tiny_skia/src/lib.rs @@ -377,9 +377,18 @@ impl core::image::Renderer for Renderer {          handle: Self::Handle,          filter_method: core::image::FilterMethod,          bounds: Rectangle, +        rotation: core::Radians, +        opacity: f32,      ) {          let (layer, transformation) = self.layers.current_mut(); -        layer.draw_image(handle, filter_method, bounds, transformation); +        layer.draw_image( +            handle, +            filter_method, +            bounds, +            transformation, +            rotation, +            opacity, +        );      }  } @@ -397,9 +406,18 @@ impl core::svg::Renderer for Renderer {          handle: core::svg::Handle,          color: Option<Color>,          bounds: Rectangle, +        rotation: core::Radians, +        opacity: f32,      ) {          let (layer, transformation) = self.layers.current_mut(); -        layer.draw_svg(handle, color, bounds, transformation); +        layer.draw_svg( +            handle, +            color, +            bounds, +            transformation, +            rotation, +            opacity, +        );      }  } diff --git a/tiny_skia/src/raster.rs b/tiny_skia/src/raster.rs index 176b0da9..c40f55b2 100644 --- a/tiny_skia/src/raster.rs +++ b/tiny_skia/src/raster.rs @@ -31,6 +31,7 @@ impl Pipeline {          handle: &raster::Handle,          filter_method: raster::FilterMethod,          bounds: Rectangle, +        opacity: f32,          pixels: &mut tiny_skia::PixmapMut<'_>,          transform: tiny_skia::Transform,          clip_mask: Option<&tiny_skia::Mask>, @@ -56,6 +57,7 @@ impl Pipeline {                  image,                  &tiny_skia::PixmapPaint {                      quality, +                    opacity,                      ..Default::default()                  },                  transform, @@ -71,8 +73,8 @@ impl Pipeline {  #[derive(Debug, Default)]  struct Cache { -    entries: FxHashMap<u64, Option<Entry>>, -    hits: FxHashSet<u64>, +    entries: FxHashMap<raster::Id, Option<Entry>>, +    hits: FxHashSet<raster::Id>,  }  impl Cache { @@ -83,7 +85,7 @@ impl Cache {          let id = handle.id();          if let hash_map::Entry::Vacant(entry) = self.entries.entry(id) { -            let image = graphics::image::load(handle).ok()?.into_rgba8(); +            let image = graphics::image::load(handle).ok()?;              let mut buffer =                  vec![0u32; image.width() as usize * image.height() as usize]; diff --git a/tiny_skia/src/vector.rs b/tiny_skia/src/vector.rs index 5150cffe..bbe08cb8 100644 --- a/tiny_skia/src/vector.rs +++ b/tiny_skia/src/vector.rs @@ -4,6 +4,7 @@ use crate::graphics::text;  use resvg::usvg::{self, TreeTextToPath};  use rustc_hash::{FxHashMap, FxHashSet}; +use tiny_skia::Transform;  use std::cell::RefCell;  use std::collections::hash_map; @@ -33,7 +34,9 @@ impl Pipeline {          handle: &Handle,          color: Option<Color>,          bounds: Rectangle, +        opacity: f32,          pixels: &mut tiny_skia::PixmapMut<'_>, +        transform: Transform,          clip_mask: Option<&tiny_skia::Mask>,      ) {          if let Some(image) = self.cache.borrow_mut().draw( @@ -45,8 +48,11 @@ impl Pipeline {                  bounds.x as i32,                  bounds.y as i32,                  image, -                &tiny_skia::PixmapPaint::default(), -                tiny_skia::Transform::identity(), +                &tiny_skia::PixmapPaint { +                    opacity, +                    ..tiny_skia::PixmapPaint::default() +                }, +                transform,                  clip_mask,              );          } | 
