blob: ac90573989ce8462c14285c0d015a136a931764a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
use std::collections::HashMap;
use gpu::wgpu;
pub struct StoredTexture {
texture: wgpu::Texture,
}
impl StoredTexture {
pub fn new(texture: wgpu::Texture) -> Self {
Self { texture }
}
pub fn texture(&self) -> &wgpu::Texture {
&self.texture
}
}
#[derive(Default)]
pub struct TextureStore {
textures: HashMap<String, StoredTexture>,
}
impl TextureStore {
pub fn upsert(&mut self, id: String, texture: wgpu::Texture) {
self.textures.insert(id, StoredTexture::new(texture));
}
pub fn get(&self, id: &str) -> Option<&StoredTexture> {
self.textures.get(id)
}
pub fn remove(&mut self, id: &str) {
self.textures.remove(id);
}
}
|