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.
26 lines
564 B
Rust
26 lines
564 B
Rust
use crate::image::atlas;
|
|
use iced_graphics::image::TextureStoreEntry;
|
|
|
|
#[derive(Debug)]
|
|
pub enum Entry {
|
|
Contiguous(atlas::Allocation),
|
|
Fragmented {
|
|
size: (u32, u32),
|
|
fragments: Vec<Fragment>,
|
|
},
|
|
}
|
|
|
|
impl TextureStoreEntry for Entry {
|
|
fn size(&self) -> (u32, u32) {
|
|
match self {
|
|
Entry::Contiguous(allocation) => allocation.size(),
|
|
Entry::Fragmented { size, .. } => *size,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub struct Fragment {
|
|
pub position: (u32, u32),
|
|
pub allocation: atlas::Allocation,
|
|
}
|