#include "third_party/blink/renderer/platform/graphics/web_graphics_context_3d_video_frame_pool.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/trace_event/trace_event_impl.h"
#include "components/viz/common/gpu/raster_context_provider.h"
#include "gpu/GLES2/gl2extchromium.h"
#include "gpu/command_buffer/client/client_shared_image.h"
#include "gpu/command_buffer/client/context_support.h"
#include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
#include "gpu/command_buffer/client/raster_interface.h"
#include "gpu/command_buffer/client/shared_image_interface.h"
#include "gpu/command_buffer/common/shared_image_capabilities.h"
#include "gpu/command_buffer/common/shared_image_usage.h"
#include "media/base/simple_sync_token_client.h"
#include "media/base/video_frame.h"
#include "media/renderers/video_frame_rgba_to_yuva_converter.h"
#include "media/video/gpu_video_accelerator_factories.h"
#include "media/video/renderable_gpu_memory_buffer_video_frame_pool.h"
#include "perfetto/tracing/track_event_args.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/platform/graphics/gpu/shared_gpu_context.h"
#include "third_party/blink/renderer/platform/graphics/web_graphics_context_3d_provider_wrapper.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "third_party/blink/renderer/platform/wtf/wtf.h"
#include "third_party/perfetto/include/perfetto/tracing/track.h"
namespace blink {
namespace {
BASE_FEATURE(…);
class Context : public media::RenderableGpuMemoryBufferVideoFramePool::Context { … };
}
WebGraphicsContext3DVideoFramePool::WebGraphicsContext3DVideoFramePool(
base::WeakPtr<blink::WebGraphicsContext3DProviderWrapper>
weak_context_provider)
: … { … }
WebGraphicsContext3DVideoFramePool::WebGraphicsContext3DVideoFramePool(
base::WeakPtr<blink::WebGraphicsContext3DProviderWrapper>
weak_context_provider,
gpu::GpuMemoryBufferManager* gmb_manager)
: … { … }
WebGraphicsContext3DVideoFramePool::~WebGraphicsContext3DVideoFramePool() =
default;
gpu::raster::RasterInterface*
WebGraphicsContext3DVideoFramePool::GetRasterInterface() const { … }
namespace {
void SignalGpuCompletion(
base::WeakPtr<blink::WebGraphicsContext3DProviderWrapper> ctx_wrapper,
GLenum query_target,
base::OnceClosure callback) { … }
void CopyToGpuMemoryBuffer(
base::WeakPtr<blink::WebGraphicsContext3DProviderWrapper> ctx_wrapper,
media::VideoFrame* dst_frame,
base::OnceClosure callback) { … }
}
bool WebGraphicsContext3DVideoFramePool::CopyRGBATextureToVideoFrame(
viz::SharedImageFormat src_format,
const gfx::Size& src_size,
const gfx::ColorSpace& src_color_space,
GrSurfaceOrigin src_surface_origin,
const gpu::MailboxHolder& src_mailbox_holder,
const gfx::ColorSpace& dst_color_space,
FrameReadyCallback callback) { … }
namespace {
void ApplyMetadataAndRunCallback(
scoped_refptr<media::VideoFrame> src_video_frame,
WebGraphicsContext3DVideoFramePool::FrameReadyCallback orig_callback,
scoped_refptr<media::VideoFrame> converted_video_frame) { … }
BASE_FEATURE(…);
}
bool WebGraphicsContext3DVideoFramePool::ConvertVideoFrame(
scoped_refptr<media::VideoFrame> src_video_frame,
const gfx::ColorSpace& dst_color_space,
FrameReadyCallback callback) { … }
bool WebGraphicsContext3DVideoFramePool::
IsGpuMemoryBufferReadbackFromTextureEnabled() { … }
}