2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2018-06-13 20:43:48 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "TextureView.h"
|
|
|
|
|
|
|
|
#include "Device.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace webgpu {
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
GPU_IMPL_CYCLE_COLLECTION(TextureView, mParent)
|
|
|
|
GPU_IMPL_JS_WRAP(TextureView)
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2020-02-24 23:12:16 +03:00
|
|
|
TextureView::TextureView(Texture* const aParent, RawId aId)
|
|
|
|
: ChildOf(aParent), mId(aId) {}
|
|
|
|
|
|
|
|
TextureView::~TextureView() { Cleanup(); }
|
|
|
|
|
2020-04-21 02:50:04 +03:00
|
|
|
dom::HTMLCanvasElement* TextureView::GetTargetCanvasElement() const {
|
|
|
|
return mParent->mTargetCanvasElement;
|
|
|
|
} // namespace webgpu
|
|
|
|
|
2020-02-24 23:12:16 +03:00
|
|
|
void TextureView::Cleanup() {
|
2020-04-07 01:29:18 +03:00
|
|
|
if (mValid && mParent && mParent->GetParentDevice()) {
|
2020-02-24 23:12:16 +03:00
|
|
|
mValid = false;
|
2020-04-07 01:29:18 +03:00
|
|
|
auto bridge = mParent->GetParentDevice()->GetBridge();
|
2020-02-24 23:12:16 +03:00
|
|
|
if (bridge && bridge->IsOpen()) {
|
2020-03-23 10:54:08 +03:00
|
|
|
bridge->SendTextureViewDestroy(mId);
|
2020-02-24 23:12:16 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-01-22 10:31:51 +03:00
|
|
|
|
2018-06-13 20:43:48 +03:00
|
|
|
} // namespace webgpu
|
|
|
|
} // namespace mozilla
|