diff options
author | 2020-06-05 21:18:22 +0300 | |
---|---|---|
committer | 2021-02-13 15:53:24 +0100 | |
commit | 8f126c212b887b2621cd8220bc4a52ba4febb1eb (patch) | |
tree | 5ec5abca6b01139e6679ede53ec5432af0eb01a9 /wgpu/src/image | |
parent | 9f5c2eb0c43daa61b19769322cf3692b29e0ac0f (diff) | |
download | iced-8f126c212b887b2621cd8220bc4a52ba4febb1eb.tar.gz iced-8f126c212b887b2621cd8220bc4a52ba4febb1eb.tar.bz2 iced-8f126c212b887b2621cd8220bc4a52ba4febb1eb.zip |
Add image format options to reduce code bloat, fixes #376
Diffstat (limited to '')
-rw-r--r-- | wgpu/src/image.rs | 18 | ||||
-rw-r--r-- | wgpu/src/image/atlas/entry.rs | 2 | ||||
-rw-r--r-- | wgpu/src/image/raster.rs | 8 |
3 files changed, 14 insertions, 14 deletions
diff --git a/wgpu/src/image.rs b/wgpu/src/image.rs index 70bfe586..5511565e 100644 --- a/wgpu/src/image.rs +++ b/wgpu/src/image.rs @@ -1,6 +1,6 @@ mod atlas; -#[cfg(feature = "image")] +#[cfg(feature = "image_rs")] mod raster; #[cfg(feature = "svg")] @@ -16,7 +16,7 @@ use std::mem; use bytemuck::{Pod, Zeroable}; -#[cfg(feature = "image")] +#[cfg(feature = "image_rs")] use iced_native::image; #[cfg(feature = "svg")] @@ -24,7 +24,7 @@ use iced_native::svg; #[derive(Debug)] pub struct Pipeline { - #[cfg(feature = "image")] + #[cfg(feature = "image_rs")] raster_cache: RefCell<raster::Cache>, #[cfg(feature = "svg")] vector_cache: RefCell<vector::Cache>, @@ -259,7 +259,7 @@ impl Pipeline { }); Pipeline { - #[cfg(feature = "image")] + #[cfg(feature = "image_rs")] raster_cache: RefCell::new(raster::Cache::new()), #[cfg(feature = "svg")] @@ -278,7 +278,7 @@ impl Pipeline { } } - #[cfg(feature = "image")] + #[cfg(feature = "image_rs")] pub fn dimensions(&self, handle: &image::Handle) -> (u32, u32) { let mut cache = self.raster_cache.borrow_mut(); let memory = cache.load(&handle); @@ -307,7 +307,7 @@ impl Pipeline { ) { let instances: &mut Vec<Instance> = &mut Vec::new(); - #[cfg(feature = "image")] + #[cfg(feature = "image_rs")] let mut raster_cache = self.raster_cache.borrow_mut(); #[cfg(feature = "svg")] @@ -315,7 +315,7 @@ impl Pipeline { for image in images { match &image { - #[cfg(feature = "image")] + #[cfg(feature = "image_rs")] layer::Image::Raster { handle, bounds } => { if let Some(atlas_entry) = raster_cache.upload( handle, @@ -331,7 +331,7 @@ impl Pipeline { ); } } - #[cfg(not(feature = "image"))] + #[cfg(not(feature = "image_rs"))] layer::Image::Raster { .. } => {} #[cfg(feature = "svg")] @@ -464,7 +464,7 @@ impl Pipeline { } pub fn trim_cache(&mut self) { - #[cfg(feature = "image")] + #[cfg(feature = "image_rs")] self.raster_cache.borrow_mut().trim(&mut self.texture_atlas); #[cfg(feature = "svg")] diff --git a/wgpu/src/image/atlas/entry.rs b/wgpu/src/image/atlas/entry.rs index 0310fc54..9b3f16df 100644 --- a/wgpu/src/image/atlas/entry.rs +++ b/wgpu/src/image/atlas/entry.rs @@ -10,7 +10,7 @@ pub enum Entry { } impl Entry { - #[cfg(feature = "image")] + #[cfg(feature = "image_rs")] pub fn size(&self) -> (u32, u32) { match self { Entry::Contiguous(allocation) => allocation.size(), diff --git a/wgpu/src/image/raster.rs b/wgpu/src/image/raster.rs index 25607dab..d5c62545 100644 --- a/wgpu/src/image/raster.rs +++ b/wgpu/src/image/raster.rs @@ -4,7 +4,7 @@ use std::collections::{HashMap, HashSet}; #[derive(Debug)] pub enum Memory { - Host(::image::ImageBuffer<::image::Bgra<u8>, Vec<u8>>), + Host(::image_rs::ImageBuffer<::image_rs::Bgra<u8>, Vec<u8>>), Device(atlas::Entry), NotFound, Invalid, @@ -42,14 +42,14 @@ impl Cache { let memory = match handle.data() { image::Data::Path(path) => { - if let Ok(image) = ::image::open(path) { + if let Ok(image) = ::image_rs::open(path) { Memory::Host(image.to_bgra8()) } else { Memory::NotFound } } image::Data::Bytes(bytes) => { - if let Ok(image) = ::image::load_from_memory(&bytes) { + if let Ok(image) = ::image_rs::load_from_memory(&bytes) { Memory::Host(image.to_bgra8()) } else { Memory::Invalid @@ -60,7 +60,7 @@ impl Cache { height, pixels, } => { - if let Some(image) = ::image::ImageBuffer::from_vec( + if let Some(image) = ::image_rs::ImageBuffer::from_vec( *width, *height, pixels.to_vec(), |