1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/gpu/gpu_data_manager_impl.h"
6
7 #include "content/browser/gpu/gpu_data_manager_impl_private.h"
8
9 namespace content {
10
11 // static
GetInstance()12 GpuDataManager* GpuDataManager::GetInstance() {
13 return GpuDataManagerImpl::GetInstance();
14 }
15
16 // static
GetInstance()17 GpuDataManagerImpl* GpuDataManagerImpl::GetInstance() {
18 return Singleton<GpuDataManagerImpl>::get();
19 }
20
InitializeForTesting(const std::string & gpu_blacklist_json,const gpu::GPUInfo & gpu_info)21 void GpuDataManagerImpl::InitializeForTesting(
22 const std::string& gpu_blacklist_json, const gpu::GPUInfo& gpu_info) {
23 base::AutoLock auto_lock(lock_);
24 private_->InitializeForTesting(gpu_blacklist_json, gpu_info);
25 }
26
IsFeatureBlacklisted(int feature) const27 bool GpuDataManagerImpl::IsFeatureBlacklisted(int feature) const {
28 base::AutoLock auto_lock(lock_);
29 return private_->IsFeatureBlacklisted(feature);
30 }
31
IsDriverBugWorkaroundActive(int feature) const32 bool GpuDataManagerImpl::IsDriverBugWorkaroundActive(int feature) const {
33 base::AutoLock auto_lock(lock_);
34 return private_->IsDriverBugWorkaroundActive(feature);
35 }
36
GetGPUInfo() const37 gpu::GPUInfo GpuDataManagerImpl::GetGPUInfo() const {
38 base::AutoLock auto_lock(lock_);
39 return private_->GetGPUInfo();
40 }
41
GetGpuProcessHandles(const GetGpuProcessHandlesCallback & callback) const42 void GpuDataManagerImpl::GetGpuProcessHandles(
43 const GetGpuProcessHandlesCallback& callback) const {
44 base::AutoLock auto_lock(lock_);
45 private_->GetGpuProcessHandles(callback);
46 }
47
GpuAccessAllowed(std::string * reason) const48 bool GpuDataManagerImpl::GpuAccessAllowed(std::string* reason) const {
49 base::AutoLock auto_lock(lock_);
50 return private_->GpuAccessAllowed(reason);
51 }
52
RequestCompleteGpuInfoIfNeeded()53 void GpuDataManagerImpl::RequestCompleteGpuInfoIfNeeded() {
54 base::AutoLock auto_lock(lock_);
55 private_->RequestCompleteGpuInfoIfNeeded();
56 }
57
IsEssentialGpuInfoAvailable() const58 bool GpuDataManagerImpl::IsEssentialGpuInfoAvailable() const {
59 base::AutoLock auto_lock(lock_);
60 return private_->IsEssentialGpuInfoAvailable();
61 }
62
IsCompleteGpuInfoAvailable() const63 bool GpuDataManagerImpl::IsCompleteGpuInfoAvailable() const {
64 base::AutoLock auto_lock(lock_);
65 return private_->IsCompleteGpuInfoAvailable();
66 }
67
RequestVideoMemoryUsageStatsUpdate() const68 void GpuDataManagerImpl::RequestVideoMemoryUsageStatsUpdate() const {
69 base::AutoLock auto_lock(lock_);
70 private_->RequestVideoMemoryUsageStatsUpdate();
71 }
72
ShouldUseSwiftShader() const73 bool GpuDataManagerImpl::ShouldUseSwiftShader() const {
74 base::AutoLock auto_lock(lock_);
75 return private_->ShouldUseSwiftShader();
76 }
77
RegisterSwiftShaderPath(const base::FilePath & path)78 void GpuDataManagerImpl::RegisterSwiftShaderPath(
79 const base::FilePath& path) {
80 base::AutoLock auto_lock(lock_);
81 private_->RegisterSwiftShaderPath(path);
82 }
83
ShouldUseWarp() const84 bool GpuDataManagerImpl::ShouldUseWarp() const {
85 base::AutoLock auto_lock(lock_);
86 return private_->ShouldUseWarp();
87 }
88
AddObserver(GpuDataManagerObserver * observer)89 void GpuDataManagerImpl::AddObserver(
90 GpuDataManagerObserver* observer) {
91 base::AutoLock auto_lock(lock_);
92 private_->AddObserver(observer);
93 }
94
RemoveObserver(GpuDataManagerObserver * observer)95 void GpuDataManagerImpl::RemoveObserver(
96 GpuDataManagerObserver* observer) {
97 base::AutoLock auto_lock(lock_);
98 private_->RemoveObserver(observer);
99 }
100
UnblockDomainFrom3DAPIs(const GURL & url)101 void GpuDataManagerImpl::UnblockDomainFrom3DAPIs(const GURL& url) {
102 base::AutoLock auto_lock(lock_);
103 private_->UnblockDomainFrom3DAPIs(url);
104 }
105
DisableGpuWatchdog()106 void GpuDataManagerImpl::DisableGpuWatchdog() {
107 base::AutoLock auto_lock(lock_);
108 private_->DisableGpuWatchdog();
109 }
110
SetGLStrings(const std::string & gl_vendor,const std::string & gl_renderer,const std::string & gl_version)111 void GpuDataManagerImpl::SetGLStrings(const std::string& gl_vendor,
112 const std::string& gl_renderer,
113 const std::string& gl_version) {
114 base::AutoLock auto_lock(lock_);
115 private_->SetGLStrings(gl_vendor, gl_renderer, gl_version);
116 }
117
GetGLStrings(std::string * gl_vendor,std::string * gl_renderer,std::string * gl_version)118 void GpuDataManagerImpl::GetGLStrings(std::string* gl_vendor,
119 std::string* gl_renderer,
120 std::string* gl_version) {
121 base::AutoLock auto_lock(lock_);
122 private_->GetGLStrings(gl_vendor, gl_renderer, gl_version);
123 }
124
DisableHardwareAcceleration()125 void GpuDataManagerImpl::DisableHardwareAcceleration() {
126 base::AutoLock auto_lock(lock_);
127 private_->DisableHardwareAcceleration();
128 }
129
CanUseGpuBrowserCompositor() const130 bool GpuDataManagerImpl::CanUseGpuBrowserCompositor() const {
131 base::AutoLock auto_lock(lock_);
132 return private_->CanUseGpuBrowserCompositor();
133 }
134
Initialize()135 void GpuDataManagerImpl::Initialize() {
136 base::AutoLock auto_lock(lock_);
137 private_->Initialize();
138 }
139
UpdateGpuInfo(const gpu::GPUInfo & gpu_info)140 void GpuDataManagerImpl::UpdateGpuInfo(const gpu::GPUInfo& gpu_info) {
141 base::AutoLock auto_lock(lock_);
142 private_->UpdateGpuInfo(gpu_info);
143 }
144
UpdateVideoMemoryUsageStats(const GPUVideoMemoryUsageStats & video_memory_usage_stats)145 void GpuDataManagerImpl::UpdateVideoMemoryUsageStats(
146 const GPUVideoMemoryUsageStats& video_memory_usage_stats) {
147 base::AutoLock auto_lock(lock_);
148 private_->UpdateVideoMemoryUsageStats(video_memory_usage_stats);
149 }
150
AppendRendererCommandLine(base::CommandLine * command_line) const151 void GpuDataManagerImpl::AppendRendererCommandLine(
152 base::CommandLine* command_line) const {
153 base::AutoLock auto_lock(lock_);
154 private_->AppendRendererCommandLine(command_line);
155 }
156
AppendGpuCommandLine(base::CommandLine * command_line) const157 void GpuDataManagerImpl::AppendGpuCommandLine(
158 base::CommandLine* command_line) const {
159 base::AutoLock auto_lock(lock_);
160 private_->AppendGpuCommandLine(command_line);
161 }
162
AppendPluginCommandLine(base::CommandLine * command_line) const163 void GpuDataManagerImpl::AppendPluginCommandLine(
164 base::CommandLine* command_line) const {
165 base::AutoLock auto_lock(lock_);
166 private_->AppendPluginCommandLine(command_line);
167 }
168
UpdateRendererWebPrefs(WebPreferences * prefs) const169 void GpuDataManagerImpl::UpdateRendererWebPrefs(
170 WebPreferences* prefs) const {
171 base::AutoLock auto_lock(lock_);
172 private_->UpdateRendererWebPrefs(prefs);
173 }
174
GetBlacklistVersion() const175 std::string GpuDataManagerImpl::GetBlacklistVersion() const {
176 base::AutoLock auto_lock(lock_);
177 return private_->GetBlacklistVersion();
178 }
179
GetDriverBugListVersion() const180 std::string GpuDataManagerImpl::GetDriverBugListVersion() const {
181 base::AutoLock auto_lock(lock_);
182 return private_->GetDriverBugListVersion();
183 }
184
GetBlacklistReasons(base::ListValue * reasons) const185 void GpuDataManagerImpl::GetBlacklistReasons(base::ListValue* reasons) const {
186 base::AutoLock auto_lock(lock_);
187 private_->GetBlacklistReasons(reasons);
188 }
189
GetDriverBugWorkarounds(base::ListValue * workarounds) const190 void GpuDataManagerImpl::GetDriverBugWorkarounds(
191 base::ListValue* workarounds) const {
192 base::AutoLock auto_lock(lock_);
193 private_->GetDriverBugWorkarounds(workarounds);
194 }
195
AddLogMessage(int level,const std::string & header,const std::string & message)196 void GpuDataManagerImpl::AddLogMessage(int level,
197 const std::string& header,
198 const std::string& message) {
199 base::AutoLock auto_lock(lock_);
200 private_->AddLogMessage(level, header, message);
201 }
202
ProcessCrashed(base::TerminationStatus exit_code)203 void GpuDataManagerImpl::ProcessCrashed(
204 base::TerminationStatus exit_code) {
205 base::AutoLock auto_lock(lock_);
206 private_->ProcessCrashed(exit_code);
207 }
208
GetLogMessages() const209 base::ListValue* GpuDataManagerImpl::GetLogMessages() const {
210 base::AutoLock auto_lock(lock_);
211 return private_->GetLogMessages();
212 }
213
HandleGpuSwitch()214 void GpuDataManagerImpl::HandleGpuSwitch() {
215 base::AutoLock auto_lock(lock_);
216 private_->HandleGpuSwitch();
217 }
218
BlockDomainFrom3DAPIs(const GURL & url,DomainGuilt guilt)219 void GpuDataManagerImpl::BlockDomainFrom3DAPIs(
220 const GURL& url, DomainGuilt guilt) {
221 base::AutoLock auto_lock(lock_);
222 private_->BlockDomainFrom3DAPIs(url, guilt);
223 }
224
Are3DAPIsBlocked(const GURL & url,int render_process_id,int render_view_id,ThreeDAPIType requester)225 bool GpuDataManagerImpl::Are3DAPIsBlocked(const GURL& url,
226 int render_process_id,
227 int render_view_id,
228 ThreeDAPIType requester) {
229 base::AutoLock auto_lock(lock_);
230 return private_->Are3DAPIsBlocked(
231 url, render_process_id, render_view_id, requester);
232 }
233
DisableDomainBlockingFor3DAPIsForTesting()234 void GpuDataManagerImpl::DisableDomainBlockingFor3DAPIsForTesting() {
235 base::AutoLock auto_lock(lock_);
236 private_->DisableDomainBlockingFor3DAPIsForTesting();
237 }
238
GetBlacklistedFeatureCount() const239 size_t GpuDataManagerImpl::GetBlacklistedFeatureCount() const {
240 base::AutoLock auto_lock(lock_);
241 return private_->GetBlacklistedFeatureCount();
242 }
243
SetDisplayCount(unsigned int display_count)244 void GpuDataManagerImpl::SetDisplayCount(unsigned int display_count) {
245 base::AutoLock auto_lock(lock_);
246 private_->SetDisplayCount(display_count);
247 }
248
GetDisplayCount() const249 unsigned int GpuDataManagerImpl::GetDisplayCount() const {
250 base::AutoLock auto_lock(lock_);
251 return private_->GetDisplayCount();
252 }
253
UpdateActiveGpu(uint32 vendor_id,uint32 device_id)254 bool GpuDataManagerImpl::UpdateActiveGpu(uint32 vendor_id, uint32 device_id) {
255 base::AutoLock auto_lock(lock_);
256 return private_->UpdateActiveGpu(vendor_id, device_id);
257 }
258
Notify3DAPIBlocked(const GURL & url,int render_process_id,int render_view_id,ThreeDAPIType requester)259 void GpuDataManagerImpl::Notify3DAPIBlocked(const GURL& url,
260 int render_process_id,
261 int render_view_id,
262 ThreeDAPIType requester) {
263 base::AutoLock auto_lock(lock_);
264 private_->Notify3DAPIBlocked(
265 url, render_process_id, render_view_id, requester);
266 }
267
OnGpuProcessInitFailure()268 void GpuDataManagerImpl::OnGpuProcessInitFailure() {
269 base::AutoLock auto_lock(lock_);
270 private_->OnGpuProcessInitFailure();
271 }
272
GpuDataManagerImpl()273 GpuDataManagerImpl::GpuDataManagerImpl()
274 : private_(GpuDataManagerImplPrivate::Create(this)) {
275 }
276
~GpuDataManagerImpl()277 GpuDataManagerImpl::~GpuDataManagerImpl() {
278 }
279
280 } // namespace content
281