diff options
author | 2022-10-31 13:37:56 -0700 | |
---|---|---|
committer | 2022-11-05 03:19:37 +0100 | |
commit | 2c7c42ee93a61f39562590f6a75eb2dd8b220fb8 (patch) | |
tree | 83279bcbd9ef0ca5ea8c8b763d38259555640216 /wgpu/src/image.rs | |
parent | 7b129917281baaa6688158c303922f94341ab69f (diff) | |
download | iced-2c7c42ee93a61f39562590f6a75eb2dd8b220fb8.tar.gz iced-2c7c42ee93a61f39562590f6a75eb2dd8b220fb8.tar.bz2 iced-2c7c42ee93a61f39562590f6a75eb2dd8b220fb8.zip |
Move image/svg handling into `iced_graphics`
The `TextureStore` trait is implemented by the atlas, and can also be
implemented in the glow renderer or in a software renderer.
The API here may be improved in the future, but API stability is
presumably not a huge issue since these types will only be used by
renderer backends.
Diffstat (limited to 'wgpu/src/image.rs')
-rw-r--r-- | wgpu/src/image.rs | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/wgpu/src/image.rs b/wgpu/src/image.rs index d964aed7..b9f165f0 100644 --- a/wgpu/src/image.rs +++ b/wgpu/src/image.rs @@ -1,10 +1,10 @@ mod atlas; #[cfg(feature = "image_rs")] -mod raster; +use iced_graphics::image::raster; #[cfg(feature = "svg")] -mod vector; +use iced_graphics::image::vector; use crate::Transformation; use atlas::Atlas; @@ -25,9 +25,9 @@ use iced_native::svg; #[derive(Debug)] pub struct Pipeline { #[cfg(feature = "image_rs")] - raster_cache: RefCell<raster::Cache>, + raster_cache: RefCell<raster::Cache<Atlas>>, #[cfg(feature = "svg")] - vector_cache: RefCell<vector::Cache>, + vector_cache: RefCell<vector::Cache<Atlas>>, pipeline: wgpu::RenderPipeline, uniforms: wgpu::Buffer, @@ -243,10 +243,10 @@ impl Pipeline { Pipeline { #[cfg(feature = "image_rs")] - raster_cache: RefCell::new(raster::Cache::new()), + raster_cache: RefCell::new(raster::Cache::default()), #[cfg(feature = "svg")] - vector_cache: RefCell::new(vector::Cache::new()), + vector_cache: RefCell::new(vector::Cache::default()), pipeline, uniforms: uniforms_buffer, @@ -302,8 +302,7 @@ impl Pipeline { layer::Image::Raster { handle, bounds } => { if let Some(atlas_entry) = raster_cache.upload( handle, - device, - encoder, + &mut (device, encoder), &mut self.texture_atlas, ) { add_instances( @@ -325,8 +324,7 @@ impl Pipeline { handle, size, _scale, - device, - encoder, + &mut (device, encoder), &mut self.texture_atlas, ) { add_instances( @@ -446,12 +444,20 @@ impl Pipeline { } } - pub fn trim_cache(&mut self) { + pub fn trim_cache( + &mut self, + device: &wgpu::Device, + encoder: &mut wgpu::CommandEncoder, + ) { #[cfg(feature = "image_rs")] - self.raster_cache.borrow_mut().trim(&mut self.texture_atlas); + self.raster_cache + .borrow_mut() + .trim(&mut self.texture_atlas, &mut (device, encoder)); #[cfg(feature = "svg")] - self.vector_cache.borrow_mut().trim(&mut self.texture_atlas); + self.vector_cache + .borrow_mut() + .trim(&mut self.texture_atlas, &mut (device, encoder)); } } |