Merge mozilla-central to autoland. a=merge CLOSED TREE
[gecko.git] / dom / webgpu / BindGroupLayout.cpp
blobcb5035b308cafabf9f04f8643f8baa1f8fecdd92
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "mozilla/dom/WebGPUBinding.h"
7 #include "BindGroupLayout.h"
8 #include "ipc/WebGPUChild.h"
10 #include "Device.h"
12 namespace mozilla::webgpu {
14 GPU_IMPL_CYCLE_COLLECTION(BindGroupLayout, mParent)
15 GPU_IMPL_JS_WRAP(BindGroupLayout)
17 BindGroupLayout::BindGroupLayout(Device* const aParent, RawId aId, bool aOwning)
18 : ChildOf(aParent), mId(aId), mOwning(aOwning) {
19 MOZ_RELEASE_ASSERT(aId);
22 BindGroupLayout::~BindGroupLayout() { Cleanup(); }
24 void BindGroupLayout::Cleanup() {
25 if (mValid && mParent) {
26 mValid = false;
27 auto bridge = mParent->GetBridge();
28 if (mOwning && bridge && bridge->IsOpen()) {
29 bridge->SendBindGroupLayoutDrop(mId);
34 } // namespace mozilla::webgpu