From 363e95a1c9995538a5bcf2dbd1e937a99d8f5e6d Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Thu, 3 Oct 2024 15:49:35 -0400 Subject: [PATCH] fix: image --- tiny_skia/src/lib.rs | 20 +++++++++----------- wgpu/src/geometry.rs | 10 ++++++++-- wgpu/src/image/mod.rs | 12 ++++++------ wgpu/src/lib.rs | 27 +++++++++++++++++++++++---- 4 files changed, 46 insertions(+), 23 deletions(-) diff --git a/tiny_skia/src/lib.rs b/tiny_skia/src/lib.rs index b84fa0cc2a..9085045790 100644 --- a/tiny_skia/src/lib.rs +++ b/tiny_skia/src/lib.rs @@ -393,18 +393,16 @@ impl core::image::Renderer for Renderer { border_radius: [f32; 4], ) { let (layer, transformation) = self.layers.current_mut(); - layer.draw_image( - iced_graphics::Image::Raster { - handle: crate::core::Image { - handle, - filter_method, - rotation, - opacity, - snap: true, - border_radius, - }, - bounds, + layer.draw_raster( + crate::core::Image { + handle, + filter_method, + rotation, + opacity, + snap: true, + border_radius, }, + bounds, transformation, ); } diff --git a/wgpu/src/geometry.rs b/wgpu/src/geometry.rs index 8e6f77d762..cf71fdcac8 100644 --- a/wgpu/src/geometry.rs +++ b/wgpu/src/geometry.rs @@ -421,7 +421,10 @@ impl geometry::frame::Backend for Frame { image.rotation += external_rotation; - self.images.push(Image::Raster(image, bounds)); + self.images.push(Image::Raster { + handle: image, + bounds, + }); } fn draw_svg(&mut self, bounds: Rectangle, svg: impl Into) { @@ -432,7 +435,10 @@ impl geometry::frame::Backend for Frame { svg.rotation += external_rotation; - self.images.push(Image::Vector(svg, bounds)); + self.images.push(Image::Vector { + handle: svg, + bounds, + }); } } diff --git a/wgpu/src/image/mod.rs b/wgpu/src/image/mod.rs index b2349a8373..bb10770e21 100644 --- a/wgpu/src/image/mod.rs +++ b/wgpu/src/image/mod.rs @@ -222,18 +222,18 @@ impl Pipeline { for image in images { match &image { #[cfg(feature = "image")] - Image::Raster(image, bounds) => { + Image::Raster { handle, bounds } => { if let Some(atlas_entry) = - cache.upload_raster(device, encoder, &image.handle) + cache.upload_raster(device, encoder, &handle.handle) { add_instances( [bounds.x, bounds.y], [bounds.width, bounds.height], - f32::from(image.rotation), - image.opacity, - image.snap, + f32::from(handle.rotation), + handle.opacity, + handle.snap, atlas_entry, - match image.filter_method { + match handle.filter_method { crate::core::image::FilterMethod::Nearest => { nearest_instances } diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index 3e82327eef..c0703996c1 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -62,8 +62,8 @@ pub use settings::Settings; pub use geometry::Geometry; use crate::core::{ - Background, Color, Font, Pixels, Point, Rectangle, Size, Transformation, - Vector, + image::FilterMethod, Background, Color, Font, Pixels, Point, Radians, + Rectangle, Size, Transformation, Vector, }; use crate::graphics::text::{Editor, Paragraph}; use crate::graphics::Viewport; @@ -534,9 +534,28 @@ impl core::image::Renderer for Renderer { self.image_cache.borrow_mut().measure_image(handle) } - fn draw_image(&mut self, image: core::Image, bounds: Rectangle) { + fn draw_image( + &mut self, + handle: Self::Handle, + filter_method: FilterMethod, + bounds: Rectangle, + rotation: Radians, + opacity: f32, + border_radius: [f32; 4], + ) { let (layer, transformation) = self.layers.current_mut(); - layer.draw_raster(image, bounds, transformation); + layer.draw_raster( + crate::core::Image { + handle, + filter_method, + rotation, + opacity, + snap: true, + border_radius, + }, + bounds, + transformation, + ); } }