#include "components/viz/host/gpu_client.h"
#include <utility>
#include "base/functional/bind.h"
#include "base/metrics/histogram_macros.h"
#include "base/numerics/checked_math.h"
#include "base/task/single_thread_task_runner.h"
#include "build/chromeos_buildflags.h"
#include "components/viz/host/gpu_host_impl.h"
#include "components/viz/host/host_gpu_memory_buffer_manager.h"
#include "gpu/config/gpu_finch_features.h"
#include "gpu/ipc/client/gpu_channel_host.h"
#include "gpu/ipc/common/gpu_memory_buffer_impl.h"
#include "gpu/ipc/common/gpu_memory_buffer_impl_shared_memory.h"
#include "gpu/ipc/common/gpu_memory_buffer_support.h"
#include "services/viz/privileged/mojom/gl/gpu_service.mojom.h"
#if !BUILDFLAG(IS_CHROMEOS)
#include "base/feature_list.h"
#endif
namespace viz {
GpuClient::GpuClient(std::unique_ptr<GpuClientDelegate> delegate,
int client_id,
uint64_t client_tracing_id,
scoped_refptr<base::SingleThreadTaskRunner> task_runner)
: … { … }
GpuClient::~GpuClient() { … }
void GpuClient::Add(mojo::PendingReceiver<mojom::Gpu> receiver) { … }
void GpuClient::OnError(ErrorReason reason) { … }
void GpuClient::PreEstablishGpuChannel() { … }
void GpuClient::SetClientPid(base::ProcessId client_pid) { … }
void GpuClient::SetDiskCacheHandle(const gpu::GpuDiskCacheHandle& handle) { … }
void GpuClient::RemoveDiskCacheHandles() { … }
base::WeakPtr<GpuClient> GpuClient::GetWeakPtr() { … }
#if !BUILDFLAG(IS_CHROMEOS)
void GpuClient::BindWebNNContextProvider(
mojo::PendingReceiver<webnn::mojom::WebNNContextProvider> receiver) { … }
#endif
void GpuClient::OnEstablishGpuChannel(
mojo::ScopedMessagePipeHandle channel_handle,
const gpu::GPUInfo& gpu_info,
const gpu::GpuFeatureInfo& gpu_feature_info,
const gpu::SharedImageCapabilities& shared_image_capabilities,
GpuHostImpl::EstablishChannelStatus status) { … }
void GpuClient::ClearCallback() { … }
void GpuClient::EstablishGpuChannel(EstablishGpuChannelCallback callback) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
void GpuClient::CreateJpegDecodeAccelerator(
mojo::PendingReceiver<chromeos_camera::mojom::MjpegDecodeAccelerator>
jda_receiver) {
if (auto* gpu_host = delegate_->EnsureGpuHost()) {
gpu_host->gpu_service()->CreateJpegDecodeAccelerator(
std::move(jda_receiver));
}
}
#endif
void GpuClient::CreateVideoEncodeAcceleratorProvider(
mojo::PendingReceiver<media::mojom::VideoEncodeAcceleratorProvider>
vea_provider_receiver) { … }
void GpuClient::CreateClientGpuMemoryBufferFactory(
mojo::PendingReceiver<gpu::mojom::ClientGmbInterface> receiver) { … }
}