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 12 GpuDataManager* GpuDataManager::GetInstance() { 13 return GpuDataManagerImpl::GetInstance(); 14 } 15 16 // static 17 GpuDataManagerImpl* GpuDataManagerImpl::GetInstance() { 18 return Singleton<GpuDataManagerImpl>::get(); 19 } 20 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 27 bool GpuDataManagerImpl::IsFeatureBlacklisted(int feature) const { 28 base::AutoLock auto_lock(lock_); 29 return private_->IsFeatureBlacklisted(feature); 30 } 31 32 bool GpuDataManagerImpl::IsDriverBugWorkaroundActive(int feature) const { 33 base::AutoLock auto_lock(lock_); 34 return private_->IsDriverBugWorkaroundActive(feature); 35 } 36 37 gpu::GPUInfo GpuDataManagerImpl::GetGPUInfo() const { 38 base::AutoLock auto_lock(lock_); 39 return private_->GetGPUInfo(); 40 } 41 42 void GpuDataManagerImpl::GetGpuProcessHandles( 43 const GetGpuProcessHandlesCallback& callback) const { 44 base::AutoLock auto_lock(lock_); 45 private_->GetGpuProcessHandles(callback); 46 } 47 48 bool GpuDataManagerImpl::GpuAccessAllowed(std::string* reason) const { 49 base::AutoLock auto_lock(lock_); 50 return private_->GpuAccessAllowed(reason); 51 } 52 53 void GpuDataManagerImpl::RequestCompleteGpuInfoIfNeeded() { 54 base::AutoLock auto_lock(lock_); 55 private_->RequestCompleteGpuInfoIfNeeded(); 56 } 57 58 bool GpuDataManagerImpl::IsCompleteGpuInfoAvailable() const { 59 base::AutoLock auto_lock(lock_); 60 return private_->IsCompleteGpuInfoAvailable(); 61 } 62 63 void GpuDataManagerImpl::RequestVideoMemoryUsageStatsUpdate() const { 64 base::AutoLock auto_lock(lock_); 65 private_->RequestVideoMemoryUsageStatsUpdate(); 66 } 67 68 bool GpuDataManagerImpl::ShouldUseSwiftShader() const { 69 base::AutoLock auto_lock(lock_); 70 return private_->ShouldUseSwiftShader(); 71 } 72 73 void GpuDataManagerImpl::RegisterSwiftShaderPath( 74 const base::FilePath& path) { 75 base::AutoLock auto_lock(lock_); 76 private_->RegisterSwiftShaderPath(path); 77 } 78 79 void GpuDataManagerImpl::AddObserver( 80 GpuDataManagerObserver* observer) { 81 base::AutoLock auto_lock(lock_); 82 private_->AddObserver(observer); 83 } 84 85 void GpuDataManagerImpl::RemoveObserver( 86 GpuDataManagerObserver* observer) { 87 base::AutoLock auto_lock(lock_); 88 private_->RemoveObserver(observer); 89 } 90 91 void GpuDataManagerImpl::UnblockDomainFrom3DAPIs(const GURL& url) { 92 base::AutoLock auto_lock(lock_); 93 private_->UnblockDomainFrom3DAPIs(url); 94 } 95 96 void GpuDataManagerImpl::DisableGpuWatchdog() { 97 base::AutoLock auto_lock(lock_); 98 private_->DisableGpuWatchdog(); 99 } 100 101 void GpuDataManagerImpl::SetGLStrings(const std::string& gl_vendor, 102 const std::string& gl_renderer, 103 const std::string& gl_version) { 104 base::AutoLock auto_lock(lock_); 105 private_->SetGLStrings(gl_vendor, gl_renderer, gl_version); 106 } 107 108 void GpuDataManagerImpl::GetGLStrings(std::string* gl_vendor, 109 std::string* gl_renderer, 110 std::string* gl_version) { 111 base::AutoLock auto_lock(lock_); 112 private_->GetGLStrings(gl_vendor, gl_renderer, gl_version); 113 } 114 115 void GpuDataManagerImpl::DisableHardwareAcceleration() { 116 base::AutoLock auto_lock(lock_); 117 private_->DisableHardwareAcceleration(); 118 } 119 120 bool GpuDataManagerImpl::CanUseGpuBrowserCompositor() const { 121 base::AutoLock auto_lock(lock_); 122 return private_->CanUseGpuBrowserCompositor(); 123 } 124 125 void GpuDataManagerImpl::Initialize() { 126 base::AutoLock auto_lock(lock_); 127 private_->Initialize(); 128 } 129 130 void GpuDataManagerImpl::UpdateGpuInfo(const gpu::GPUInfo& gpu_info) { 131 base::AutoLock auto_lock(lock_); 132 private_->UpdateGpuInfo(gpu_info); 133 } 134 135 void GpuDataManagerImpl::UpdateVideoMemoryUsageStats( 136 const GPUVideoMemoryUsageStats& video_memory_usage_stats) { 137 base::AutoLock auto_lock(lock_); 138 private_->UpdateVideoMemoryUsageStats(video_memory_usage_stats); 139 } 140 141 void GpuDataManagerImpl::AppendRendererCommandLine( 142 CommandLine* command_line) const { 143 base::AutoLock auto_lock(lock_); 144 private_->AppendRendererCommandLine(command_line); 145 } 146 147 void GpuDataManagerImpl::AppendGpuCommandLine( 148 CommandLine* command_line) const { 149 base::AutoLock auto_lock(lock_); 150 private_->AppendGpuCommandLine(command_line); 151 } 152 153 void GpuDataManagerImpl::AppendPluginCommandLine( 154 CommandLine* command_line) const { 155 base::AutoLock auto_lock(lock_); 156 private_->AppendPluginCommandLine(command_line); 157 } 158 159 void GpuDataManagerImpl::UpdateRendererWebPrefs( 160 WebPreferences* prefs) const { 161 base::AutoLock auto_lock(lock_); 162 private_->UpdateRendererWebPrefs(prefs); 163 } 164 165 std::string GpuDataManagerImpl::GetBlacklistVersion() const { 166 base::AutoLock auto_lock(lock_); 167 return private_->GetBlacklistVersion(); 168 } 169 170 std::string GpuDataManagerImpl::GetDriverBugListVersion() const { 171 base::AutoLock auto_lock(lock_); 172 return private_->GetDriverBugListVersion(); 173 } 174 175 void GpuDataManagerImpl::GetBlacklistReasons(base::ListValue* reasons) const { 176 base::AutoLock auto_lock(lock_); 177 private_->GetBlacklistReasons(reasons); 178 } 179 180 void GpuDataManagerImpl::GetDriverBugWorkarounds( 181 base::ListValue* workarounds) const { 182 base::AutoLock auto_lock(lock_); 183 private_->GetDriverBugWorkarounds(workarounds); 184 } 185 186 void GpuDataManagerImpl::AddLogMessage(int level, 187 const std::string& header, 188 const std::string& message) { 189 base::AutoLock auto_lock(lock_); 190 private_->AddLogMessage(level, header, message); 191 } 192 193 void GpuDataManagerImpl::ProcessCrashed( 194 base::TerminationStatus exit_code) { 195 base::AutoLock auto_lock(lock_); 196 private_->ProcessCrashed(exit_code); 197 } 198 199 base::ListValue* GpuDataManagerImpl::GetLogMessages() const { 200 base::AutoLock auto_lock(lock_); 201 return private_->GetLogMessages(); 202 } 203 204 void GpuDataManagerImpl::HandleGpuSwitch() { 205 base::AutoLock auto_lock(lock_); 206 private_->HandleGpuSwitch(); 207 } 208 209 #if defined(OS_WIN) 210 bool GpuDataManagerImpl::IsUsingAcceleratedSurface() const { 211 base::AutoLock auto_lock(lock_); 212 return private_->IsUsingAcceleratedSurface(); 213 } 214 #endif 215 216 void GpuDataManagerImpl::BlockDomainFrom3DAPIs( 217 const GURL& url, DomainGuilt guilt) { 218 base::AutoLock auto_lock(lock_); 219 private_->BlockDomainFrom3DAPIs(url, guilt); 220 } 221 222 bool GpuDataManagerImpl::Are3DAPIsBlocked(const GURL& url, 223 int render_process_id, 224 int render_view_id, 225 ThreeDAPIType requester) { 226 base::AutoLock auto_lock(lock_); 227 return private_->Are3DAPIsBlocked( 228 url, render_process_id, render_view_id, requester); 229 } 230 231 void GpuDataManagerImpl::DisableDomainBlockingFor3DAPIsForTesting() { 232 base::AutoLock auto_lock(lock_); 233 private_->DisableDomainBlockingFor3DAPIsForTesting(); 234 } 235 236 size_t GpuDataManagerImpl::GetBlacklistedFeatureCount() const { 237 base::AutoLock auto_lock(lock_); 238 return private_->GetBlacklistedFeatureCount(); 239 } 240 241 void GpuDataManagerImpl::SetDisplayCount(unsigned int display_count) { 242 base::AutoLock auto_lock(lock_); 243 private_->SetDisplayCount(display_count); 244 } 245 246 unsigned int GpuDataManagerImpl::GetDisplayCount() const { 247 base::AutoLock auto_lock(lock_); 248 return private_->GetDisplayCount(); 249 } 250 251 void GpuDataManagerImpl::Notify3DAPIBlocked(const GURL& url, 252 int render_process_id, 253 int render_view_id, 254 ThreeDAPIType requester) { 255 base::AutoLock auto_lock(lock_); 256 private_->Notify3DAPIBlocked( 257 url, render_process_id, render_view_id, requester); 258 } 259 260 void GpuDataManagerImpl::OnGpuProcessInitFailure() { 261 base::AutoLock auto_lock(lock_); 262 private_->OnGpuProcessInitFailure(); 263 } 264 265 GpuDataManagerImpl::GpuDataManagerImpl() 266 : private_(GpuDataManagerImplPrivate::Create(this)) { 267 } 268 269 GpuDataManagerImpl::~GpuDataManagerImpl() { 270 } 271 272 } // namespace content 273