summaryrefslogtreecommitdiffstats
path: root/graphics/src/image/vector.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-11-05 03:13:04 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-11-05 03:19:38 +0100
commit8ce8d374b1e8d1d394a42a5ee2bca8af790f0b71 (patch)
tree40cf3587e2a08f845c9a8d89108b1b3d8cd86213 /graphics/src/image/vector.rs
parent5575e6ea0897e406674e7e4239808fbf9daa07c3 (diff)
downloadiced-8ce8d374b1e8d1d394a42a5ee2bca8af790f0b71.tar.gz
iced-8ce8d374b1e8d1d394a42a5ee2bca8af790f0b71.tar.bz2
iced-8ce8d374b1e8d1d394a42a5ee2bca8af790f0b71.zip
Refactor some `image` traits a bit
- Use `Size<u32>` were applicable. - Rename `TextureStore` to `image::Storage`. - Rename `TextureStoreEntry` to `image::storage::Entry`. - Wire up `viewport_dimensions` to `iced_glow` for `Svg`.
Diffstat (limited to 'graphics/src/image/vector.rs')
-rw-r--r--graphics/src/image/vector.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/graphics/src/image/vector.rs b/graphics/src/image/vector.rs
index 0062e2ce..818fdd20 100644
--- a/graphics/src/image/vector.rs
+++ b/graphics/src/image/vector.rs
@@ -1,12 +1,12 @@
//! Vector image loading and caching
+use crate::image::Storage;
use iced_native::svg;
+use iced_native::Size;
use std::collections::{HashMap, HashSet};
use std::fs;
-use super::TextureStore;
-
/// Entry in cache corresponding to an svg handle
pub enum Svg {
/// Parsed svg
@@ -17,28 +17,28 @@ pub enum Svg {
impl Svg {
/// Viewport width and height
- pub fn viewport_dimensions(&self) -> (u32, u32) {
+ pub fn viewport_dimensions(&self) -> Size<u32> {
match self {
Svg::Loaded(tree) => {
let size = tree.svg_node().size;
- (size.width() as u32, size.height() as u32)
+ Size::new(size.width() as u32, size.height() as u32)
}
- Svg::NotFound => (1, 1),
+ Svg::NotFound => Size::new(1, 1),
}
}
}
/// Caches svg vector and raster data
#[derive(Debug)]
-pub struct Cache<T: TextureStore> {
+pub struct Cache<T: Storage> {
svgs: HashMap<u64, Svg>,
rasterized: HashMap<(u64, u32, u32), T::Entry>,
svg_hits: HashSet<u64>,
rasterized_hits: HashSet<(u64, u32, u32)>,
}
-impl<T: TextureStore> Cache<T> {
+impl<T: Storage> Cache<T> {
/// Load svg
pub fn load(&mut self, handle: &svg::Handle) -> &Svg {
if self.svgs.contains_key(&handle.id()) {
@@ -162,7 +162,7 @@ impl<T: TextureStore> Cache<T> {
}
}
-impl<T: TextureStore> Default for Cache<T> {
+impl<T: Storage> Default for Cache<T> {
fn default() -> Self {
Self {
svgs: HashMap::new(),