chromium/services/viz/public/cpp/gpu/gpu.cc

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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 {

// Encapsulates a mojo::Remote<mojom::Gpu> object that will be used on the IO
// thread. This is required because we can't install an error handler on a
// mojo::SharedRemote<mojom::Gpu> to detect if the message pipe was closed. Only
// the constructor can be called on the main thread.
class Gpu::GpuPtrIO {};

// Encapsulates a single request to establish a GPU channel.
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() {}

// static
std::unique_ptr<Gpu> Gpu::Create(
    service_manager::Connector* connector,
    const std::string& service_name,
    scoped_refptr<base::SingleThreadTaskRunner> task_runner) {}

// static
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  // BUILDFLAG(IS_CHROMEOS_ASH)

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() {}

}  // namespace viz