mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-18 18:38:05 +08:00
Fix lifetime of cached textures (#4333)
* Fix in-use textures being destroyed * Remove ImageTexture refs * Review
This commit is contained in:
@@ -10,7 +10,7 @@ license = "MIT OR Apache-2.0"
|
||||
default = ["serde"]
|
||||
serde = ["dep:serde", "core-types/serde", "vector-types/serde", "text-nodes/serde", "graphene-resource/serde"]
|
||||
wasm = ["dep:web-sys"]
|
||||
wgpu = ["dep:wgpu"]
|
||||
wgpu = ["dep:raster-types", "raster-types/wgpu"]
|
||||
|
||||
[dependencies]
|
||||
# Local dependencies
|
||||
@@ -20,6 +20,9 @@ vector-types = { workspace = true }
|
||||
text-nodes = { workspace = true }
|
||||
graphene-resource = { workspace = true }
|
||||
|
||||
# Optional local dependencies
|
||||
raster-types = { workspace = true, optional = true }
|
||||
|
||||
# Workspace dependencies
|
||||
blake3 = { workspace = true }
|
||||
glam = { workspace = true }
|
||||
@@ -27,7 +30,4 @@ log = { workspace = true }
|
||||
|
||||
# Optional workspace dependencies
|
||||
serde = { workspace = true, optional = true }
|
||||
|
||||
# Optional workspace dependencies
|
||||
web-sys = { workspace = true, optional = true }
|
||||
wgpu = { workspace = true, optional = true }
|
||||
|
||||
@@ -11,35 +11,10 @@ use vector_types::vector::style::RenderMode;
|
||||
pub use graphene_resource as resource;
|
||||
|
||||
#[cfg(feature = "wgpu")]
|
||||
#[derive(Debug, Clone, Hash, PartialEq, Eq, DynAny)]
|
||||
pub struct ImageTexture(Arc<wgpu::Texture>);
|
||||
#[cfg(feature = "wgpu")]
|
||||
impl AsRef<wgpu::Texture> for ImageTexture {
|
||||
fn as_ref(&self) -> &wgpu::Texture {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "wgpu")]
|
||||
impl From<wgpu::Texture> for ImageTexture {
|
||||
fn from(texture: wgpu::Texture) -> Self {
|
||||
Self(Arc::new(texture))
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "wgpu")]
|
||||
impl From<Arc<wgpu::Texture>> for ImageTexture {
|
||||
fn from(texture: Arc<wgpu::Texture>) -> Self {
|
||||
Self(texture)
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "wgpu")]
|
||||
impl From<ImageTexture> for Arc<wgpu::Texture> {
|
||||
fn from(image_texture: ImageTexture) -> Self {
|
||||
image_texture.0
|
||||
}
|
||||
}
|
||||
pub use raster_types::Texture;
|
||||
#[cfg(not(feature = "wgpu"))]
|
||||
#[derive(Debug, Clone, Hash, PartialEq, Eq, DynAny)]
|
||||
pub struct ImageTexture;
|
||||
pub struct Texture; // TODO: Consider removing this
|
||||
|
||||
pub trait ApplicationIo {
|
||||
type Executor;
|
||||
|
||||
Reference in New Issue
Block a user