Backed out 2 changesets (bug 1818237) for causing xpc failures on browser/components...
[gecko.git] / dom / webgpu / TextureView.cpp
blob4401155b90444070d4782e701283274c6a485ea9
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 "TextureView.h"
8 #include "Device.h"
9 #include "mozilla/dom/WebGPUBinding.h"
10 #include "mozilla/webgpu/CanvasContext.h"
11 #include "ipc/WebGPUChild.h"
13 namespace mozilla::webgpu {
15 GPU_IMPL_CYCLE_COLLECTION(TextureView, mParent)
16 GPU_IMPL_JS_WRAP(TextureView)
18 TextureView::TextureView(Texture* const aParent, RawId aId)
19 : ChildOf(aParent), mId(aId) {}
21 TextureView::~TextureView() { Cleanup(); }
23 CanvasContext* TextureView::GetTargetContext() const {
24 return mParent->mTargetContext;
25 } // namespace webgpu
27 void TextureView::Cleanup() {
28 if (mValid && mParent && mParent->GetParentDevice()) {
29 mValid = false;
30 auto bridge = mParent->GetParentDevice()->GetBridge();
31 if (bridge && bridge->IsOpen()) {
32 bridge->SendTextureViewDestroy(mId);
37 } // namespace mozilla::webgpu