From b5b78d505e22cafccb4ecbf57dc61f536ca558ca Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 30 Apr 2024 07:57:54 +0200 Subject: Introduce `canvas::Cache` grouping Caches with the same `Group` will share their text atlas! --- renderer/src/fallback.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'renderer/src') diff --git a/renderer/src/fallback.rs b/renderer/src/fallback.rs index c932de00..5f69b420 100644 --- a/renderer/src/fallback.rs +++ b/renderer/src/fallback.rs @@ -428,8 +428,8 @@ where mod geometry { use super::Renderer; use crate::core::{Point, Radians, Rectangle, Size, Vector}; + use crate::graphics::cache::{self, Cached}; use crate::graphics::geometry::{self, Fill, Path, Stroke, Text}; - use crate::graphics::Cached; impl geometry::Renderer for Renderer where @@ -483,21 +483,25 @@ mod geometry { } } - fn cache(self, previous: Option) -> Self::Cache { + fn cache( + self, + group: cache::Group, + previous: Option, + ) -> Self::Cache { match (self, previous) { ( Self::Primary(geometry), Some(Geometry::Primary(previous)), - ) => Geometry::Primary(geometry.cache(Some(previous))), + ) => Geometry::Primary(geometry.cache(group, Some(previous))), (Self::Primary(geometry), None) => { - Geometry::Primary(geometry.cache(None)) + Geometry::Primary(geometry.cache(group, None)) } ( Self::Secondary(geometry), Some(Geometry::Secondary(previous)), - ) => Geometry::Secondary(geometry.cache(Some(previous))), + ) => Geometry::Secondary(geometry.cache(group, Some(previous))), (Self::Secondary(geometry), None) => { - Geometry::Secondary(geometry.cache(None)) + Geometry::Secondary(geometry.cache(group, None)) } _ => unreachable!(), } -- cgit From 09a6bcfffc24f5abdc8709403bab7ae1e01563f1 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 2 May 2024 13:15:17 +0200 Subject: Add `Image` rotation support Co-authored-by: DKolter <68352124+DKolter@users.noreply.github.com> --- renderer/src/fallback.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'renderer/src') diff --git a/renderer/src/fallback.rs b/renderer/src/fallback.rs index 5f69b420..37e6ac43 100644 --- a/renderer/src/fallback.rs +++ b/renderer/src/fallback.rs @@ -154,11 +154,13 @@ where handle: Self::Handle, filter_method: image::FilterMethod, bounds: Rectangle, + rotation: f32, + scale: Size, ) { delegate!( self, renderer, - renderer.draw_image(handle, filter_method, bounds) + renderer.draw_image(handle, filter_method, bounds, rotation, scale) ); } } @@ -177,8 +179,14 @@ where handle: svg::Handle, color: Option, bounds: Rectangle, + rotation: f32, + scale: Size, ) { - delegate!(self, renderer, renderer.draw_svg(handle, color, bounds)); + delegate!( + self, + renderer, + renderer.draw_svg(handle, color, bounds, rotation, scale) + ); } } -- cgit From a57313b23ecb9843856ca0ea08635b6121fcb2cb Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 2 May 2024 15:21:22 +0200 Subject: Simplify image rotation API and its internals --- renderer/src/fallback.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'renderer/src') diff --git a/renderer/src/fallback.rs b/renderer/src/fallback.rs index 37e6ac43..a077031b 100644 --- a/renderer/src/fallback.rs +++ b/renderer/src/fallback.rs @@ -3,7 +3,7 @@ use crate::core::image; use crate::core::renderer; use crate::core::svg; use crate::core::{ - self, Background, Color, Point, Rectangle, Size, Transformation, + self, Background, Color, Point, Radians, Rectangle, Size, Transformation, }; use crate::graphics; use crate::graphics::compositor; @@ -154,13 +154,12 @@ where handle: Self::Handle, filter_method: image::FilterMethod, bounds: Rectangle, - rotation: f32, - scale: Size, + rotation: Radians, ) { delegate!( self, renderer, - renderer.draw_image(handle, filter_method, bounds, rotation, scale) + renderer.draw_image(handle, filter_method, bounds, rotation) ); } } @@ -179,13 +178,12 @@ where handle: svg::Handle, color: Option, bounds: Rectangle, - rotation: f32, - scale: Size, + rotation: Radians, ) { delegate!( self, renderer, - renderer.draw_svg(handle, color, bounds, rotation, scale) + renderer.draw_svg(handle, color, bounds, rotation) ); } } -- cgit From fa9e1d96ea1924b51749b775ea0e67e69bc8a305 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 3 May 2024 13:25:58 +0200 Subject: Introduce dynamic `opacity` support for `Image` and `Svg` --- renderer/src/fallback.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'renderer/src') diff --git a/renderer/src/fallback.rs b/renderer/src/fallback.rs index a077031b..6a169692 100644 --- a/renderer/src/fallback.rs +++ b/renderer/src/fallback.rs @@ -155,11 +155,18 @@ where filter_method: image::FilterMethod, bounds: Rectangle, rotation: Radians, + opacity: f32, ) { delegate!( self, renderer, - renderer.draw_image(handle, filter_method, bounds, rotation) + renderer.draw_image( + handle, + filter_method, + bounds, + rotation, + opacity + ) ); } } @@ -179,11 +186,12 @@ where color: Option, bounds: Rectangle, rotation: Radians, + opacity: f32, ) { delegate!( self, renderer, - renderer.draw_svg(handle, color, bounds, rotation) + renderer.draw_svg(handle, color, bounds, rotation, opacity) ); } } -- cgit