#include "third_party/blink/renderer/platform/graphics/gpu/webgpu_mailbox_texture.h"
#include "base/numerics/safe_conversions.h"
#include "components/viz/common/resources/shared_image_format.h"
#include "gpu/command_buffer/client/webgpu_interface.h"
#include "media/base/video_frame.h"
#include "media/base/wait_and_replace_sync_token_client.h"
#include "third_party/blink/renderer/platform/graphics/canvas_resource.h"
#include "third_party/blink/renderer/platform/graphics/canvas_resource_provider.h"
#include "third_party/blink/renderer/platform/graphics/gpu/shared_gpu_context.h"
#include "third_party/blink/renderer/platform/graphics/gpu/webgpu_texture_alpha_clearer.h"
#include "third_party/blink/renderer/platform/graphics/static_bitmap_image.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
namespace blink {
namespace {
wgpu::TextureFormat VizToWGPUFormat(const viz::SharedImageFormat& format) { … }
}
scoped_refptr<WebGPUMailboxTexture> WebGPUMailboxTexture::FromStaticBitmapImage(
scoped_refptr<DawnControlClientHolder> dawn_control_client,
const wgpu::Device& device,
wgpu::TextureUsage usage,
scoped_refptr<StaticBitmapImage> image,
const SkImageInfo& info,
const gfx::Rect& image_sub_rect,
bool is_dummy_mailbox_texture) { … }
scoped_refptr<WebGPUMailboxTexture> WebGPUMailboxTexture::FromCanvasResource(
scoped_refptr<DawnControlClientHolder> dawn_control_client,
const wgpu::Device& device,
wgpu::TextureUsage usage,
std::unique_ptr<RecyclableCanvasResource> recyclable_canvas_resource) { … }
scoped_refptr<WebGPUMailboxTexture> WebGPUMailboxTexture::FromExistingMailbox(
scoped_refptr<DawnControlClientHolder> dawn_control_client,
const wgpu::Device& device,
const wgpu::TextureDescriptor& desc,
const gpu::Mailbox& mailbox,
const gpu::SyncToken& sync_token,
gpu::webgpu::MailboxFlags mailbox_flags,
wgpu::TextureUsage additional_internal_usage,
base::OnceCallback<void(const gpu::SyncToken&)> finished_access_callback) { … }
scoped_refptr<WebGPUMailboxTexture> WebGPUMailboxTexture::FromVideoFrame(
scoped_refptr<DawnControlClientHolder> dawn_control_client,
const wgpu::Device& device,
wgpu::TextureUsage usage,
scoped_refptr<media::VideoFrame> video_frame) { … }
WebGPUMailboxTexture::WebGPUMailboxTexture(
scoped_refptr<DawnControlClientHolder> dawn_control_client,
const wgpu::Device& device,
const wgpu::TextureDescriptor& desc,
const gpu::Mailbox& mailbox,
const gpu::SyncToken& sync_token,
gpu::webgpu::MailboxFlags mailbox_flags,
wgpu::TextureUsage additional_internal_usage,
base::OnceCallback<void(const gpu::SyncToken&)> finished_access_callback,
std::unique_ptr<RecyclableCanvasResource> recyclable_canvas_resource)
: … { … }
void WebGPUMailboxTexture::SetAlphaClearer(
scoped_refptr<WebGPUTextureAlphaClearer> alpha_clearer) { … }
gpu::SyncToken WebGPUMailboxTexture::Dissociate() { … }
void WebGPUMailboxTexture::SetCompletionSyncToken(const gpu::SyncToken& token) { … }
WebGPUMailboxTexture::~WebGPUMailboxTexture() { … }
}