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`.
This commit is contained in:
Héctor Ramón Jiménez 2022-11-05 03:13:04 +01:00
parent 5575e6ea08
commit 8ce8d374b1
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
20 changed files with 164 additions and 127 deletions

View file

@ -1,16 +1,12 @@
use iced_graphics::image;
use iced_graphics::Size;
use glow::HasContext;
use iced_graphics::image::{TextureStore, TextureStoreEntry};
#[derive(Debug)]
pub struct Textures;
#[derive(Debug, Default)]
pub struct Storage;
impl Textures {
pub fn new() -> Self {
Self
}
}
impl TextureStore for Textures {
impl image::Storage for Storage {
type Entry = Entry;
type State<'a> = &'a glow::Context;
@ -58,7 +54,7 @@ impl TextureStore for Textures {
gl.bind_texture(glow::TEXTURE_2D, None);
Some(Entry {
size: (width, height),
size: Size::new(width, height),
texture,
})
}
@ -71,12 +67,12 @@ impl TextureStore for Textures {
#[derive(Debug)]
pub struct Entry {
size: (u32, u32),
pub texture: glow::NativeTexture,
size: Size<u32>,
pub(super) texture: glow::NativeTexture,
}
impl TextureStoreEntry for Entry {
fn size(&self) -> (u32, u32) {
impl image::storage::Entry for Entry {
fn size(&self) -> Size<u32> {
self.size
}
}