mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-17 23:38:06 +08:00
WIP shaders: wrap Texture in Arc within Raster<GPU>
This commit is contained in:
@@ -134,10 +134,11 @@ pub use gpu::GPU;
|
||||
mod gpu {
|
||||
use super::*;
|
||||
use crate::raster_types::__private::Sealed;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Hash)]
|
||||
pub struct GPU {
|
||||
pub texture: wgpu::Texture,
|
||||
pub texture: Arc<InnerTexture>,
|
||||
}
|
||||
|
||||
impl Sealed for Raster<GPU> {}
|
||||
@@ -150,7 +151,9 @@ mod gpu {
|
||||
|
||||
impl Raster<GPU> {
|
||||
pub fn new_gpu(texture: wgpu::Texture) -> Self {
|
||||
Self::new(GPU { texture })
|
||||
Self::new(GPU {
|
||||
texture: Arc::new(InnerTexture(texture)),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn data(&self) -> &wgpu::Texture {
|
||||
@@ -158,9 +161,20 @@ mod gpu {
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for GPU {
|
||||
#[derive(Debug, PartialEq, Hash)]
|
||||
pub struct InnerTexture(wgpu::Texture);
|
||||
|
||||
impl Deref for InnerTexture {
|
||||
type Target = wgpu::Texture;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for InnerTexture {
|
||||
fn drop(&mut self) {
|
||||
self.texture.destroy();
|
||||
self.0.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user