#include "services/video_effects/video_effects_processor_impl.h"
#include <memory>
#include "base/functional/bind.h"
#include "base/functional/callback_forward.h"
#include "base/types/cxx23_to_underlying.h"
#include "content/public/common/gpu_stream_constants.h"
#include "gpu/ipc/client/client_shared_image_interface.h"
#include "gpu/ipc/client/gpu_channel_host.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "services/video_effects/public/mojom/video_effects_processor.mojom.h"
#include "services/video_effects/video_effects_processor_webgpu.h"
#include "services/video_effects/video_effects_service_impl.h"
#include "services/viz/public/cpp/gpu/context_provider_command_buffer.h"
namespace {
constexpr int kMaxNumOfContextLosses = …;
bool ContextLossesExceedThreshold(int num_context_losses) { … }
scoped_refptr<viz::ContextProviderCommandBuffer> CreateAndBindContextProvider(
scoped_refptr<gpu::GpuChannelHost> gpu_channel_host,
gpu::ContextType context_type) { … }
}
namespace video_effects {
VideoEffectsProcessorImpl::VideoEffectsProcessorImpl(
mojo::PendingRemote<media::mojom::VideoEffectsManager> manager_remote,
mojo::PendingReceiver<mojom::VideoEffectsProcessor> processor_receiver,
std::unique_ptr<GpuChannelHostProvider> gpu_channel_host_provider,
base::OnceClosure on_unrecoverable_error)
: … { … }
VideoEffectsProcessorImpl::~VideoEffectsProcessorImpl() { … }
bool VideoEffectsProcessorImpl::Initialize() { … }
void VideoEffectsProcessorImpl::SetBackgroundSegmentationModel(
base::span<const uint8_t> model_blob) { … }
bool VideoEffectsProcessorImpl::InitializeGpuState() { … }
void VideoEffectsProcessorImpl::OnContextLost() { … }
void VideoEffectsProcessorImpl::OnMojoDisconnected() { … }
void VideoEffectsProcessorImpl::OnWebGpuProcessorError() { … }
void VideoEffectsProcessorImpl::PostProcess(
media::mojom::VideoBufferHandlePtr input_frame_data,
media::mojom::VideoFrameInfoPtr input_frame_info,
media::mojom::VideoBufferHandlePtr result_frame_data,
media::VideoPixelFormat result_pixel_format,
PostProcessCallback callback) { … }
void VideoEffectsProcessorImpl::MaybeCallOnUnrecoverableError() { … }
}