Bug 1857841 - pt 3. Add a new page kind named "fresh" r=glandium
[gecko.git] / dom / webgpu / TextureView.cpp
blobc36818e9eab37d523c0fc690e9adfe7827458127
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) {
20 MOZ_RELEASE_ASSERT(aId);
23 TextureView::~TextureView() { Cleanup(); }
25 CanvasContext* TextureView::GetTargetContext() const {
26 return mParent->mTargetContext;
27 } // namespace webgpu
29 void TextureView::Cleanup() {
30 if (mValid && mParent && mParent->GetParentDevice()) {
31 mValid = false;
32 auto bridge = mParent->GetParentDevice()->GetBridge();
33 if (bridge && bridge->IsOpen()) {
34 bridge->SendTextureViewDrop(mId);
39 } // namespace mozilla::webgpu