Bug 1732219 - Add API for fetching the preview image. r=geckoview-reviewers,agi,mconley
[gecko.git] / dom / webgpu / BindGroupLayout.cpp
blobfb6b035e01798c45d22549dafb6ce00a71b2427a
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 {
13 namespace webgpu {
15 GPU_IMPL_CYCLE_COLLECTION(BindGroupLayout, mParent)
16 GPU_IMPL_JS_WRAP(BindGroupLayout)
18 BindGroupLayout::BindGroupLayout(Device* const aParent, RawId aId, bool aOwning)
19 : ChildOf(aParent), mId(aId), mOwning(aOwning) {
20 if (!aId) {
21 mValid = false;
25 BindGroupLayout::~BindGroupLayout() { Cleanup(); }
27 void BindGroupLayout::Cleanup() {
28 if (mValid && mParent) {
29 mValid = false;
30 auto bridge = mParent->GetBridge();
31 if (mOwning && bridge && bridge->IsOpen()) {
32 bridge->SendBindGroupLayoutDestroy(mId);
37 } // namespace webgpu
38 } // namespace mozilla