#include "third_party/blink/renderer/modules/webgpu/gpu_external_texture.h"
#include "media/base/video_frame.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_external_texture_descriptor.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_texture_view_descriptor.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_union_htmlvideoelement_videoframe.h"
#include "third_party/blink/renderer/core/dom/scripted_animation_controller.h"
#include "third_party/blink/renderer/core/html/canvas/predefined_color_space.h"
#include "third_party/blink/renderer/core/html/media/html_video_element.h"
#include "third_party/blink/renderer/modules/webcodecs/video_frame.h"
#include "third_party/blink/renderer/modules/webgpu/dawn_conversions.h"
#include "third_party/blink/renderer/modules/webgpu/external_texture_helper.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_device.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_queue.h"
#include "third_party/blink/renderer/platform/graphics/gpu/webgpu_mailbox_texture.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
namespace blink {
ExternalTextureCache::ExternalTextureCache(GPUDevice* device)
: … { … }
GPUExternalTexture* ExternalTextureCache::Import(
const GPUExternalTextureDescriptor* descriptor,
ExceptionState& exception_state) { … }
void ExternalTextureCache::Destroy() { … }
void ExternalTextureCache::Add(HTMLVideoElement* video,
GPUExternalTexture* external_texture) { … }
void ExternalTextureCache::Remove(HTMLVideoElement* video) { … }
void ExternalTextureCache::Add(VideoFrame* frame,
GPUExternalTexture* external_texture) { … }
void ExternalTextureCache::Remove(VideoFrame* frame) { … }
void ExternalTextureCache::Trace(Visitor* visitor) const { … }
GPUDevice* ExternalTextureCache::device() const { … }
void ExternalTextureCache::ExpireAtEndOfTask(
GPUExternalTexture* external_texture) { … }
void ExternalTextureCache::ExpireTask() { … }
void ExternalTextureCache::ReferenceUntilGPUIsFinished(
scoped_refptr<WebGPUMailboxTexture> mailbox_texture) { … }
GPUExternalTexture* GPUExternalTexture::CreateImpl(
ExternalTextureCache* cache,
const GPUExternalTextureDescriptor* webgpu_desc,
scoped_refptr<media::VideoFrame> media_video_frame,
media::PaintCanvasVideoRenderer* video_renderer,
std::optional<media::VideoFrame::ID> media_video_frame_unique_id,
ExceptionState& exception_state) { … }
GPUExternalTexture* GPUExternalTexture::CreateExpired(
ExternalTextureCache* cache,
const GPUExternalTextureDescriptor* webgpu_desc,
ExceptionState& exception_state) { … }
GPUExternalTexture* GPUExternalTexture::FromHTMLVideoElement(
ExternalTextureCache* cache,
HTMLVideoElement* video,
const GPUExternalTextureDescriptor* webgpu_desc,
ExceptionState& exception_state) { … }
GPUExternalTexture* GPUExternalTexture::FromVideoFrame(
ExternalTextureCache* cache,
VideoFrame* frame,
const GPUExternalTextureDescriptor* webgpu_desc,
ExceptionState& exception_state) { … }
GPUExternalTexture::GPUExternalTexture(
ExternalTextureCache* cache,
wgpu::ExternalTexture external_texture,
scoped_refptr<WebGPUMailboxTexture> mailbox_texture,
bool is_zero_copy,
bool read_lock_fences_enabled,
std::optional<media::VideoFrame::ID> media_video_frame_unique_id,
const String& label)
: … { … }
void GPUExternalTexture::Refresh() { … }
void GPUExternalTexture::Expire() { … }
void GPUExternalTexture::Destroy() { … }
void GPUExternalTexture::SetVideo(HTMLVideoElement* video) { … }
bool GPUExternalTexture::NeedsToUpdate() { … }
void GPUExternalTexture::Trace(Visitor* visitor) const { … }
bool GPUExternalTexture::IsCurrentFrameFromHTMLVideoElementValid() { … }
void GPUExternalTexture::OnSourceInvalidated() { … }
void GPUExternalTexture::RemoveFromCache() { … }
bool GPUExternalTexture::ListenToVideoFrame(VideoFrame* frame) { … }
void GPUExternalTexture::OnVideoFrameClosed() { … }
bool GPUExternalTexture::active() const { … }
bool GPUExternalTexture::expired() const { … }
bool GPUExternalTexture::isZeroCopy() const { … }
bool GPUExternalTexture::isReadLockFenceEnabled() const { … }
bool GPUExternalTexture::destroyed() const { … }
}