File: gpu_host_impl_test_api.cc

package info (click to toggle)
chromium 139.0.7258.127-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,122,156 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (148 lines) | stat: -rw-r--r-- 4,588 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/viz/test/gpu_host_impl_test_api.h"

#include <algorithm>
#include <memory>
#include <set>
#include <string>
#include <utility>

#include "build/build_config.h"

namespace viz {

gpu::GPUInfo GpuHostImplTestApi::HookDelegateBase::GetGPUInfo() const {
  return original_delegate_->GetGPUInfo();
}

gpu::GpuFeatureInfo GpuHostImplTestApi::HookDelegateBase::GetGpuFeatureInfo()
    const {
  return original_delegate_->GetGpuFeatureInfo();
}

void GpuHostImplTestApi::HookDelegateBase::DidInitialize(
    const gpu::GPUInfo& gpu_info,
    const gpu::GpuFeatureInfo& gpu_feature_info,
    const std::optional<gpu::GPUInfo>& gpu_info_for_hardware_gpu,
    const std::optional<gpu::GpuFeatureInfo>& gpu_feature_info_for_hardware_gpu,
    const gfx::GpuExtraInfo& gpu_extra_info) {
  original_delegate_->DidInitialize(
      gpu_info, gpu_feature_info, gpu_info_for_hardware_gpu,
      gpu_feature_info_for_hardware_gpu, gpu_extra_info);
}

void GpuHostImplTestApi::HookDelegateBase::DidFailInitialize() {
  original_delegate_->DidFailInitialize();
}

void GpuHostImplTestApi::HookDelegateBase::DidCreateContextSuccessfully() {
  original_delegate_->DidCreateContextSuccessfully();
}

void GpuHostImplTestApi::HookDelegateBase::MaybeShutdownGpuProcess() {
  original_delegate_->MaybeShutdownGpuProcess();
}

void GpuHostImplTestApi::HookDelegateBase::DidUpdateGPUInfo(
    const gpu::GPUInfo& gpu_info) {
  original_delegate_->DidUpdateGPUInfo(gpu_info);
}

#if BUILDFLAG(IS_WIN)
void GpuHostImplTestApi::HookDelegateBase::DidUpdateOverlayInfo(
    const gpu::OverlayInfo& overlay_info) {
  original_delegate_->DidUpdateOverlayInfo(overlay_info);
}

void GpuHostImplTestApi::HookDelegateBase::DidUpdateDXGIInfo(
    gfx::mojom::DXGIInfoPtr dxgi_info) {
  original_delegate_->DidUpdateDXGIInfo(std::move(dxgi_info));
}
#endif

void GpuHostImplTestApi::HookDelegateBase::BlockDomainsFrom3DAPIs(
    const std::set<GURL>& urls,
    gpu::DomainGuilt guilt) {
  original_delegate_->BlockDomainsFrom3DAPIs(urls, guilt);
}

std::string GpuHostImplTestApi::HookDelegateBase::GetIsolationKey(
    int32_t client_id,
    const blink::WebGPUExecutionContextToken& token) {
  return original_delegate_->GetIsolationKey(client_id, token);
}

void GpuHostImplTestApi::HookDelegateBase::DisableGpuCompositing() {
  original_delegate_->DisableGpuCompositing();
}

bool GpuHostImplTestApi::HookDelegateBase::GpuAccessAllowed() const {
  return original_delegate_->GpuAccessAllowed();
}

gpu::GpuDiskCacheFactory*
GpuHostImplTestApi::HookDelegateBase::GetGpuDiskCacheFactory() {
  return original_delegate_->GetGpuDiskCacheFactory();
}

void GpuHostImplTestApi::HookDelegateBase::RecordLogMessage(
    int32_t severity,
    const std::string& header,
    const std::string& message) {
  original_delegate_->RecordLogMessage(severity, header, message);
}

void GpuHostImplTestApi::HookDelegateBase::BindDiscardableMemoryReceiver(
    mojo::PendingReceiver<
        discardable_memory::mojom::DiscardableSharedMemoryManager> receiver) {
  original_delegate_->BindDiscardableMemoryReceiver(std::move(receiver));
}

void GpuHostImplTestApi::HookDelegateBase::BindInterface(
    const std::string& interface_name,
    mojo::ScopedMessagePipeHandle interface_pipe) {
  original_delegate_->BindInterface(interface_name, std::move(interface_pipe));
}

#if BUILDFLAG(IS_OZONE)
void GpuHostImplTestApi::HookDelegateBase::TerminateGpuProcess(
    const std::string& message) {
  original_delegate_->TerminateGpuProcess(message);
}
#endif

GpuHostImplTestApi::GpuHostImplTestApi(GpuHostImpl* gpu_host)
    : gpu_host_(gpu_host) {}

GpuHostImplTestApi::~GpuHostImplTestApi() {
  if (hook_delegate_)
    gpu_host_->delegate_ = hook_delegate_->original_delegate();
}

void GpuHostImplTestApi::FlushRemoteForTesting() {
  gpu_host_->gpu_service_remote_.FlushForTesting();
}

void GpuHostImplTestApi::SetGpuService(
    mojo::Remote<mojom::GpuService> gpu_service) {
  gpu_host_->gpu_service_remote_ = std::move(gpu_service);
}

void GpuHostImplTestApi::HookDelegate(
    std::unique_ptr<HookDelegateBase> delegate) {
  DCHECK(delegate);

  GpuHostImpl::Delegate* original_delegate =
      hook_delegate_ ? hook_delegate_->original_delegate()
                     : gpu_host_->delegate_.get();

  hook_delegate_ = std::move(delegate);
  hook_delegate_->set_original_delegate(original_delegate);

  gpu_host_->delegate_ = hook_delegate_.get();
}

}  // namespace viz