#include "services/viz/public/cpp/gpu/gpu.h"
#include <memory>
#include <string>
#include <utility>
#include "base/functional/bind.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/single_thread_task_runner.h"
#include "base/threading/thread_checker.h"
#include "base/timer/elapsed_timer.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "gpu/config/gpu_finch_features.h"
#include "gpu/ipc/common/client_gmb_interface.mojom.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/service_manager/public/cpp/connector.h"
#include "services/viz/public/cpp/gpu/client_gpu_memory_buffer_manager.h"
#include "services/viz/public/mojom/gpu.mojom.h"
namespace viz {
class Gpu::GpuPtrIO { … };
class Gpu::EstablishRequest
: public base::RefCountedThreadSafe<Gpu::EstablishRequest> { … };
void Gpu::GpuPtrIO::ConnectionError() { … }
void Gpu::GpuPtrIO::OnEstablishedGpuChannel(
int client_id,
mojo::ScopedMessagePipeHandle channel_handle,
const gpu::GPUInfo& gpu_info,
const gpu::GpuFeatureInfo& gpu_feature_info,
const gpu::SharedImageCapabilities& shared_image_capabilities) { … }
Gpu::Gpu(mojo::PendingRemote<mojom::Gpu> gpu_remote,
scoped_refptr<base::SingleThreadTaskRunner> task_runner)
: … { … }
Gpu::~Gpu() { … }
std::unique_ptr<Gpu> Gpu::Create(
service_manager::Connector* connector,
const std::string& service_name,
scoped_refptr<base::SingleThreadTaskRunner> task_runner) { … }
std::unique_ptr<Gpu> Gpu::Create(
mojo::PendingRemote<mojom::Gpu> remote,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
void Gpu::CreateJpegDecodeAccelerator(
mojo::PendingReceiver<chromeos_camera::mojom::MjpegDecodeAccelerator>
jda_receiver) {
DCHECK(main_task_runner_->BelongsToCurrentThread());
io_task_runner_->PostTask(
FROM_HERE,
base::BindOnce(&GpuPtrIO::CreateJpegDecodeAccelerator,
base::Unretained(gpu_.get()), std::move(jda_receiver)));
}
#endif
void Gpu::CreateVideoEncodeAcceleratorProvider(
mojo::PendingReceiver<media::mojom::VideoEncodeAcceleratorProvider>
vea_provider_receiver) { … }
void Gpu::EstablishGpuChannel(gpu::GpuChannelEstablishedCallback callback) { … }
scoped_refptr<gpu::GpuChannelHost> Gpu::EstablishGpuChannelSync() { … }
gpu::GpuMemoryBufferManager* Gpu::GetGpuMemoryBufferManager() { … }
void Gpu::LoseChannel() { … }
scoped_refptr<gpu::GpuChannelHost> Gpu::GetGpuChannel() { … }
void Gpu::SendEstablishGpuChannelRequest(base::WaitableEvent* waitable_event) { … }
void Gpu::OnEstablishedGpuChannel() { … }
}