#include "components/viz/service/main/viz_main_impl.h"
#include <memory>
#include <utility>
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/message_loop/message_pump_type.h"
#include "base/power_monitor/power_monitor.h"
#include "base/power_monitor/power_monitor_source.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/single_thread_task_runner.h"
#include "base/trace_event/memory_dump_manager.h"
#include "build/build_config.h"
#include "components/viz/common/buildflags.h"
#include "components/viz/common/features.h"
#include "components/viz/service/debugger/viz_debugger.h"
#include "components/viz/service/performance_hint/hint_session.h"
#include "gpu/command_buffer/common/shm_count.h"
#include "gpu/config/gpu_finch_features.h"
#include "gpu/ipc/service/gpu_init.h"
#include "gpu/ipc/service/gpu_watchdog_thread.h"
#include "media/gpu/buildflags.h"
#include "mojo/public/cpp/bindings/interface_endpoint_client.h"
#include "services/metrics/public/cpp/delegating_ukm_recorder.h"
#include "services/metrics/public/cpp/mojo_ukm_recorder.h"
#include "skia/ext/legacy_display_globals.h"
#if BUILDFLAG(SKIA_USE_DAWN)
#include "gpu/command_buffer/service/dawn_context_provider.h"
#endif
namespace {
std::unique_ptr<base::Thread> CreateAndStartIOThread() { … }
}
namespace viz {
VizMainImpl::ExternalDependencies::ExternalDependencies() = default;
VizMainImpl::ExternalDependencies::~ExternalDependencies() = default;
VizMainImpl::ExternalDependencies::ExternalDependencies(
ExternalDependencies&& other) = default;
VizMainImpl::ExternalDependencies& VizMainImpl::ExternalDependencies::operator=(
ExternalDependencies&& other) = default;
VizMainImpl::VizMainImpl(Delegate* delegate,
ExternalDependencies dependencies,
std::unique_ptr<gpu::GpuInit> gpu_init)
: … { … }
VizMainImpl::~VizMainImpl() { … }
void VizMainImpl::Bind(mojo::PendingReceiver<mojom::VizMain> receiver) { … }
void VizMainImpl::CreateGpuService(
mojo::PendingReceiver<mojom::GpuService> pending_receiver,
mojo::PendingRemote<mojom::GpuHost> pending_gpu_host,
mojo::PendingRemote<
discardable_memory::mojom::DiscardableSharedMemoryManager>
discardable_memory_manager,
base::UnsafeSharedMemoryRegion use_shader_cache_shm_region) { … }
void VizMainImpl::SetRenderParams(
gfx::FontRenderParams::SubpixelRendering subpixel_rendering,
float text_contrast,
float text_gamma) { … }
#if BUILDFLAG(IS_WIN)
void VizMainImpl::CreateInfoCollectionGpuService(
mojo::PendingReceiver<mojom::InfoCollectionGpuService> pending_receiver) {
DCHECK(gpu_thread_task_runner_->BelongsToCurrentThread());
DCHECK(!info_collection_gpu_service_);
DCHECK(gpu_init_->device_perf_info().has_value());
info_collection_gpu_service_ = std::make_unique<InfoCollectionGpuServiceImpl>(
gpu_thread_task_runner_, io_task_runner(),
gpu_init_->device_perf_info().value(), gpu_init_->gpu_info().active_gpu(),
std::move(pending_receiver));
}
#endif
#if BUILDFLAG(IS_ANDROID)
void VizMainImpl::SetHostProcessId(int32_t pid) {
if (gpu_service_)
gpu_service_->SetHostProcessId(pid);
}
#endif
void VizMainImpl::CreateFrameSinkManager(
mojom::FrameSinkManagerParamsPtr params) { … }
void VizMainImpl::CreateFrameSinkManagerInternal(
mojom::FrameSinkManagerParamsPtr params) { … }
void VizMainImpl::RequestBeginFrameForGpuService(bool toggle) { … }
#if BUILDFLAG(USE_VIZ_DEBUGGER)
void VizMainImpl::FilterDebugStream(base::Value::Dict filter_data) { … }
void VizMainImpl::StartDebugStream(
mojo::PendingRemote<mojom::VizDebugOutput> pending_debug_output) { … }
void VizMainImpl::StopDebugStream() { … }
#endif
void VizMainImpl::ExitProcess(ExitCode immediate_exit_code) { … }
}