#include "media/gpu/chromeos/mailbox_video_frame_converter.h"
#include <optional>
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/memory/ptr_util.h"
#include "base/not_fatal_until.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/trace_event/trace_event.h"
#include "components/viz/common/resources/shared_image_format.h"
#include "gpu/command_buffer/client/client_shared_image.h"
#include "gpu/command_buffer/common/shared_image_usage.h"
#include "gpu/command_buffer/service/scheduler.h"
#include "gpu/command_buffer/service/shared_image/shared_image_factory.h"
#include "gpu/ipc/service/gpu_channel.h"
#include "gpu/ipc/service/gpu_channel_shared_image_interface.h"
#include "media/base/format_utils.h"
#include "media/base/media_switches.h"
#include "media/base/video_util.h"
#include "media/gpu/chromeos/platform_video_frame_utils.h"
#include "media/gpu/macros.h"
#include "ui/gfx/buffer_format_util.h"
#include "ui/gfx/gpu_fence.h"
#include "ui/gfx/gpu_memory_buffer.h"
#include "ui/gl/gl_bindings.h"
namespace {
viz::SharedImageFormat GetSharedImageFormat(gfx::BufferFormat buffer_format) { … }
}
namespace media {
class GpuDelegateImpl : public MailboxVideoFrameConverter::GpuDelegate { … };
class MailboxVideoFrameConverter::ScopedSharedImage { … };
std::unique_ptr<FrameResourceConverter> MailboxVideoFrameConverter::Create(
scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner,
GetCommandBufferStubCB get_stub_cb) { … }
MailboxVideoFrameConverter::MailboxVideoFrameConverter(
scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner,
std::unique_ptr<GpuDelegate> gpu_delegate)
: … { … }
void MailboxVideoFrameConverter::Destroy() { … }
void MailboxVideoFrameConverter::DestroyOnGPUThread() { … }
MailboxVideoFrameConverter::~MailboxVideoFrameConverter() { … }
bool MailboxVideoFrameConverter::InitializeOnGPUThread() { … }
void MailboxVideoFrameConverter::ConvertFrameImpl(
scoped_refptr<FrameResource> frame) { … }
void MailboxVideoFrameConverter::WrapSharedImageAndVideoFrameAndOutput(
FrameResource* origin_frame,
scoped_refptr<FrameResource> frame,
scoped_refptr<gpu::ClientSharedImage> shared_image,
const gpu::SyncToken& shared_image_sync_token) { … }
void MailboxVideoFrameConverter::ConvertFrameOnGPUThread(
FrameResource* origin_frame,
scoped_refptr<FrameResource> frame,
ScopedSharedImage* stored_shared_image) { … }
bool MailboxVideoFrameConverter::GenerateSharedImageOnGPUThread(
FrameResource* origin_frame,
const gfx::ColorSpace& src_color_space,
const gfx::Rect& destination_visible_rect,
ScopedSharedImage* shared_image) { … }
void MailboxVideoFrameConverter::RegisterSharedImage(
FrameResource* origin_frame,
std::unique_ptr<ScopedSharedImage> scoped_shared_image) { … }
std::optional<gpu::SyncToken>
MailboxVideoFrameConverter::UpdateSharedImageOnGPUThread(
const gpu::Mailbox& mailbox) { … }
void MailboxVideoFrameConverter::WaitOnSyncTokenAndReleaseFrameOnGPUThread(
scoped_refptr<FrameResource> frame,
const gpu::SyncToken& sync_token) { … }
void MailboxVideoFrameConverter::UnregisterSharedImage(
UniqueID origin_frame_id,
std::unique_ptr<ScopedSharedImage> scoped_shared_image) { … }
void MailboxVideoFrameConverter::AbortPendingFramesImpl() { … }
bool MailboxVideoFrameConverter::HasPendingFramesImpl() const { … }
bool MailboxVideoFrameConverter::UsesGetOriginalFrameCBImpl() const { … }
void MailboxVideoFrameConverter::OnError(const base::Location& location,
const std::string& msg) { … }
}