aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/gpusampler.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/gpusampler.rs')
-rw-r--r--components/script/dom/gpusampler.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/components/script/dom/gpusampler.rs b/components/script/dom/gpusampler.rs
index 48663c722e6..5325877c8fd 100644
--- a/components/script/dom/gpusampler.rs
+++ b/components/script/dom/gpusampler.rs
@@ -3,7 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use dom_struct::dom_struct;
-use webgpu::{WebGPUDevice, WebGPUSampler};
+use webgpu::{WebGPU, WebGPUDevice, WebGPURequest, WebGPUSampler};
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUSamplerMethods;
@@ -15,6 +15,9 @@ use crate::dom::globalscope::GlobalScope;
#[dom_struct]
pub struct GPUSampler {
reflector_: Reflector,
+ #[ignore_malloc_size_of = "defined in webgpu"]
+ #[no_trace]
+ channel: WebGPU,
label: DomRefCell<USVString>,
#[no_trace]
device: WebGPUDevice,
@@ -25,6 +28,7 @@ pub struct GPUSampler {
impl GPUSampler {
fn new_inherited(
+ channel: WebGPU,
device: WebGPUDevice,
compare_enable: bool,
sampler: WebGPUSampler,
@@ -32,6 +36,7 @@ impl GPUSampler {
) -> Self {
Self {
reflector_: Reflector::new(),
+ channel,
label: DomRefCell::new(label),
device,
sampler,
@@ -41,6 +46,7 @@ impl GPUSampler {
pub fn new(
global: &GlobalScope,
+ channel: WebGPU,
device: WebGPUDevice,
compare_enable: bool,
sampler: WebGPUSampler,
@@ -48,6 +54,7 @@ impl GPUSampler {
) -> DomRoot<Self> {
reflect_dom_object(
Box::new(GPUSampler::new_inherited(
+ channel,
device,
compare_enable,
sampler,
@@ -75,3 +82,15 @@ impl GPUSamplerMethods for GPUSampler {
*self.label.borrow_mut() = value;
}
}
+
+impl Drop for GPUSampler {
+ fn drop(&mut self) {
+ if let Err(e) = self
+ .channel
+ .0
+ .send((None, WebGPURequest::DropSampler(self.sampler.0)))
+ {
+ warn!("Failed to send DropSampler ({:?}) ({})", self.sampler.0, e);
+ }
+ }
+}