#include "third_party/blink/renderer/platform/graphics/video_frame_submitter.h"
#include <optional>
#include <utility>
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/memory/weak_ptr.h"
#include "base/metrics/histogram_macros.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/threading/platform_thread.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "cc/metrics/video_playback_roughness_reporter.h"
#include "components/viz/common/features.h"
#include "components/viz/common/resources/resource_id.h"
#include "components/viz/common/resources/returned_resource.h"
#include "components/viz/common/surfaces/frame_sink_bundle_id.h"
#include "gpu/command_buffer/client/raster_interface.h"
#include "gpu/ipc/client/client_shared_image_interface.h"
#include "gpu/ipc/client/gpu_channel_host.h"
#include "media/base/video_frame.h"
#include "media/base/video_types.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/viz/public/cpp/gpu/context_provider_command_buffer.h"
#include "services/viz/public/mojom/compositing/compositor_frame_sink.mojom-blink.h"
#include "services/viz/public/mojom/compositing/frame_sink_bundle.mojom-blink.h"
#include "services/viz/public/mojom/compositing/layer_context.mojom-blink.h"
#include "services/viz/public/mojom/hit_test/hit_test_region_list.mojom-blink.h"
#include "third_party/abseil-cpp/absl/cleanup/cleanup.h"
#include "third_party/blink/public/common/thread_safe_browser_interface_broker_proxy.h"
#include "third_party/blink/public/mojom/frame_sinks/embedded_frame_sink.mojom-blink.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/platform/graphics/canvas_resource.h"
#include "third_party/blink/renderer/platform/graphics/video_frame_sink_bundle.h"
#include "ui/gfx/presentation_feedback.h"
namespace blink {
namespace {
BASE_FEATURE(…);
cc::FrameInfo CreateFrameInfo(cc::FrameInfo::FrameFinalState final_state) { … }
viz::BeginFrameAck CreateManualAckWithDamageAndPreferredFrameInterval(
cc::VideoFrameProvider* video_frame_provider) { … }
}
class VideoFrameSubmitter::FrameSinkBundleProxy
: public viz::mojom::blink::CompositorFrameSink { … };
VideoFrameSubmitter::VideoFrameSubmitter(
WebContextProviderCallback context_provider_callback,
cc::VideoPlaybackRoughnessReporter::ReportingCallback
roughness_reporting_callback,
std::unique_ptr<VideoFrameResourceProvider> resource_provider)
: … { … }
VideoFrameSubmitter::~VideoFrameSubmitter() { … }
void VideoFrameSubmitter::StopUsingProvider() { … }
void VideoFrameSubmitter::StartRendering() { … }
void VideoFrameSubmitter::StopRendering() { … }
void VideoFrameSubmitter::DidReceiveFrame() { … }
bool VideoFrameSubmitter::IsDrivingFrameUpdates() const { … }
void VideoFrameSubmitter::Initialize(cc::VideoFrameProvider* provider,
bool is_media_stream) { … }
void VideoFrameSubmitter::SetTransform(media::VideoTransformation transform) { … }
void VideoFrameSubmitter::EnableSubmission(viz::SurfaceId surface_id) { … }
void VideoFrameSubmitter::SetIsSurfaceVisible(bool is_visible) { … }
void VideoFrameSubmitter::SetIsPageVisible(bool is_visible) { … }
void VideoFrameSubmitter::SetForceBeginFrames(bool force_begin_frames) { … }
void VideoFrameSubmitter::SetForceSubmit(bool force_submit) { … }
void VideoFrameSubmitter::OnContextLost() { … }
void VideoFrameSubmitter::OnGpuChannelLost() { … }
void VideoFrameSubmitter::DidReceiveCompositorFrameAck(
WTF::Vector<viz::ReturnedResource> resources) { … }
void VideoFrameSubmitter::OnBeginFrame(
const viz::BeginFrameArgs& args,
const WTF::HashMap<uint32_t, viz::FrameTimingDetails>& timing_details,
bool frame_ack,
WTF::Vector<viz::ReturnedResource> resources) { … }
void VideoFrameSubmitter::ReclaimResources(
WTF::Vector<viz::ReturnedResource> resources) { … }
void VideoFrameSubmitter::DidAllocateSharedBitmap(
base::ReadOnlySharedMemoryRegion region,
const viz::SharedBitmapId& id) { … }
void VideoFrameSubmitter::DidDeleteSharedBitmap(const viz::SharedBitmapId& id) { … }
void VideoFrameSubmitter::OnReceivedContextProvider(
bool use_gpu_compositing,
scoped_refptr<viz::RasterContextProvider> context_provider,
scoped_refptr<gpu::ClientSharedImageInterface> shared_image_interface) { … }
bool VideoFrameSubmitter::MaybeAcceptContextProvider(
scoped_refptr<viz::RasterContextProvider> context_provider) { … }
void VideoFrameSubmitter::StartSubmitting() { … }
void VideoFrameSubmitter::UpdateSubmissionState() { … }
void VideoFrameSubmitter::SubmitEmptyFrameIfNeeded() { … }
bool VideoFrameSubmitter::SubmitFrame(
const viz::BeginFrameAck& begin_frame_ack,
scoped_refptr<media::VideoFrame> video_frame) { … }
void VideoFrameSubmitter::SubmitEmptyFrame() { … }
void VideoFrameSubmitter::SubmitSingleFrame() { … }
bool VideoFrameSubmitter::ShouldSubmit() const { … }
viz::CompositorFrame VideoFrameSubmitter::CreateCompositorFrame(
uint32_t frame_token,
const viz::BeginFrameAck& begin_frame_ack,
scoped_refptr<media::VideoFrame> video_frame,
media::VideoTransformation transform) { … }
void VideoFrameSubmitter::GenerateNewSurfaceId() { … }
}