aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/gputextureview.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/gputextureview.rs')
-rw-r--r--components/script/dom/gputextureview.rs30
1 files changed, 28 insertions, 2 deletions
diff --git a/components/script/dom/gputextureview.rs b/components/script/dom/gputextureview.rs
index ce887542684..d9bac21aa25 100644
--- a/components/script/dom/gputextureview.rs
+++ b/components/script/dom/gputextureview.rs
@@ -3,7 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use dom_struct::dom_struct;
-use webgpu::WebGPUTextureView;
+use webgpu::{WebGPU, WebGPURequest, WebGPUTextureView};
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUTextureViewMethods;
@@ -16,6 +16,9 @@ use crate::dom::gputexture::GPUTexture;
#[dom_struct]
pub struct GPUTextureView {
reflector_: Reflector,
+ #[ignore_malloc_size_of = "defined in webgpu"]
+ #[no_trace]
+ channel: WebGPU,
label: DomRefCell<USVString>,
#[no_trace]
texture_view: WebGPUTextureView,
@@ -24,12 +27,14 @@ pub struct GPUTextureView {
impl GPUTextureView {
fn new_inherited(
+ channel: WebGPU,
texture_view: WebGPUTextureView,
texture: &GPUTexture,
label: USVString,
) -> GPUTextureView {
Self {
reflector_: Reflector::new(),
+ channel,
texture: Dom::from_ref(texture),
label: DomRefCell::new(label),
texture_view,
@@ -38,12 +43,18 @@ impl GPUTextureView {
pub fn new(
global: &GlobalScope,
+ channel: WebGPU,
texture_view: WebGPUTextureView,
texture: &GPUTexture,
label: USVString,
) -> DomRoot<GPUTextureView> {
reflect_dom_object(
- Box::new(GPUTextureView::new_inherited(texture_view, texture, label)),
+ Box::new(GPUTextureView::new_inherited(
+ channel,
+ texture_view,
+ texture,
+ label,
+ )),
global,
)
}
@@ -66,3 +77,18 @@ impl GPUTextureViewMethods for GPUTextureView {
*self.label.borrow_mut() = value;
}
}
+
+impl Drop for GPUTextureView {
+ fn drop(&mut self) {
+ if let Err(e) = self
+ .channel
+ .0
+ .send((None, WebGPURequest::DropTextureView(self.texture_view.0)))
+ {
+ warn!(
+ "Failed to send DropTextureView ({:?}) ({})",
+ self.texture_view.0, e
+ );
+ }
+ }
+}