Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / browser / gpu / gpu_data_manager_impl.cc
blob26197c6b94ca90e78353f27cea142e4a02fe2922
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.
5 #include "content/browser/gpu/gpu_data_manager_impl.h"
7 #include "content/browser/gpu/gpu_data_manager_impl_private.h"
9 namespace content {
11 // static
12 GpuDataManager* GpuDataManager::GetInstance() {
13 return GpuDataManagerImpl::GetInstance();
16 // static
17 GpuDataManagerImpl* GpuDataManagerImpl::GetInstance() {
18 return Singleton<GpuDataManagerImpl>::get();
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);
27 bool GpuDataManagerImpl::IsFeatureBlacklisted(int feature) const {
28 base::AutoLock auto_lock(lock_);
29 return private_->IsFeatureBlacklisted(feature);
32 bool GpuDataManagerImpl::IsDriverBugWorkaroundActive(int feature) const {
33 base::AutoLock auto_lock(lock_);
34 return private_->IsDriverBugWorkaroundActive(feature);
37 gpu::GPUInfo GpuDataManagerImpl::GetGPUInfo() const {
38 base::AutoLock auto_lock(lock_);
39 return private_->GetGPUInfo();
42 void GpuDataManagerImpl::GetGpuProcessHandles(
43 const GetGpuProcessHandlesCallback& callback) const {
44 base::AutoLock auto_lock(lock_);
45 private_->GetGpuProcessHandles(callback);
48 bool GpuDataManagerImpl::GpuAccessAllowed(std::string* reason) const {
49 base::AutoLock auto_lock(lock_);
50 return private_->GpuAccessAllowed(reason);
53 void GpuDataManagerImpl::RequestCompleteGpuInfoIfNeeded() {
54 base::AutoLock auto_lock(lock_);
55 private_->RequestCompleteGpuInfoIfNeeded();
58 bool GpuDataManagerImpl::IsEssentialGpuInfoAvailable() const {
59 base::AutoLock auto_lock(lock_);
60 return private_->IsEssentialGpuInfoAvailable();
63 bool GpuDataManagerImpl::IsCompleteGpuInfoAvailable() const {
64 base::AutoLock auto_lock(lock_);
65 return private_->IsCompleteGpuInfoAvailable();
68 void GpuDataManagerImpl::RequestVideoMemoryUsageStatsUpdate() const {
69 base::AutoLock auto_lock(lock_);
70 private_->RequestVideoMemoryUsageStatsUpdate();
73 bool GpuDataManagerImpl::ShouldUseSwiftShader() const {
74 base::AutoLock auto_lock(lock_);
75 return private_->ShouldUseSwiftShader();
78 void GpuDataManagerImpl::RegisterSwiftShaderPath(
79 const base::FilePath& path) {
80 base::AutoLock auto_lock(lock_);
81 private_->RegisterSwiftShaderPath(path);
84 bool GpuDataManagerImpl::ShouldUseWarp() const {
85 base::AutoLock auto_lock(lock_);
86 return private_->ShouldUseWarp();
89 void GpuDataManagerImpl::AddObserver(
90 GpuDataManagerObserver* observer) {
91 base::AutoLock auto_lock(lock_);
92 private_->AddObserver(observer);
95 void GpuDataManagerImpl::RemoveObserver(
96 GpuDataManagerObserver* observer) {
97 base::AutoLock auto_lock(lock_);
98 private_->RemoveObserver(observer);
101 void GpuDataManagerImpl::UnblockDomainFrom3DAPIs(const GURL& url) {
102 base::AutoLock auto_lock(lock_);
103 private_->UnblockDomainFrom3DAPIs(url);
106 void GpuDataManagerImpl::DisableGpuWatchdog() {
107 base::AutoLock auto_lock(lock_);
108 private_->DisableGpuWatchdog();
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);
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);
125 void GpuDataManagerImpl::DisableHardwareAcceleration() {
126 base::AutoLock auto_lock(lock_);
127 private_->DisableHardwareAcceleration();
130 bool GpuDataManagerImpl::CanUseGpuBrowserCompositor() const {
131 base::AutoLock auto_lock(lock_);
132 return private_->CanUseGpuBrowserCompositor();
135 void GpuDataManagerImpl::Initialize() {
136 base::AutoLock auto_lock(lock_);
137 private_->Initialize();
140 void GpuDataManagerImpl::UpdateGpuInfo(const gpu::GPUInfo& gpu_info) {
141 base::AutoLock auto_lock(lock_);
142 private_->UpdateGpuInfo(gpu_info);
145 void GpuDataManagerImpl::UpdateVideoMemoryUsageStats(
146 const GPUVideoMemoryUsageStats& video_memory_usage_stats) {
147 base::AutoLock auto_lock(lock_);
148 private_->UpdateVideoMemoryUsageStats(video_memory_usage_stats);
151 void GpuDataManagerImpl::AppendRendererCommandLine(
152 base::CommandLine* command_line) const {
153 base::AutoLock auto_lock(lock_);
154 private_->AppendRendererCommandLine(command_line);
157 void GpuDataManagerImpl::AppendGpuCommandLine(
158 base::CommandLine* command_line) const {
159 base::AutoLock auto_lock(lock_);
160 private_->AppendGpuCommandLine(command_line);
163 void GpuDataManagerImpl::AppendPluginCommandLine(
164 base::CommandLine* command_line) const {
165 base::AutoLock auto_lock(lock_);
166 private_->AppendPluginCommandLine(command_line);
169 void GpuDataManagerImpl::UpdateRendererWebPrefs(
170 WebPreferences* prefs) const {
171 base::AutoLock auto_lock(lock_);
172 private_->UpdateRendererWebPrefs(prefs);
175 std::string GpuDataManagerImpl::GetBlacklistVersion() const {
176 base::AutoLock auto_lock(lock_);
177 return private_->GetBlacklistVersion();
180 std::string GpuDataManagerImpl::GetDriverBugListVersion() const {
181 base::AutoLock auto_lock(lock_);
182 return private_->GetDriverBugListVersion();
185 void GpuDataManagerImpl::GetBlacklistReasons(base::ListValue* reasons) const {
186 base::AutoLock auto_lock(lock_);
187 private_->GetBlacklistReasons(reasons);
190 std::vector<std::string> GpuDataManagerImpl::GetDriverBugWorkarounds() const {
191 base::AutoLock auto_lock(lock_);
192 return private_->GetDriverBugWorkarounds();
195 void GpuDataManagerImpl::AddLogMessage(int level,
196 const std::string& header,
197 const std::string& message) {
198 base::AutoLock auto_lock(lock_);
199 private_->AddLogMessage(level, header, message);
202 void GpuDataManagerImpl::ProcessCrashed(
203 base::TerminationStatus exit_code) {
204 base::AutoLock auto_lock(lock_);
205 private_->ProcessCrashed(exit_code);
208 base::ListValue* GpuDataManagerImpl::GetLogMessages() const {
209 base::AutoLock auto_lock(lock_);
210 return private_->GetLogMessages();
213 void GpuDataManagerImpl::HandleGpuSwitch() {
214 base::AutoLock auto_lock(lock_);
215 private_->HandleGpuSwitch();
218 void GpuDataManagerImpl::BlockDomainFrom3DAPIs(
219 const GURL& url, DomainGuilt guilt) {
220 base::AutoLock auto_lock(lock_);
221 private_->BlockDomainFrom3DAPIs(url, guilt);
224 bool GpuDataManagerImpl::Are3DAPIsBlocked(const GURL& url,
225 int render_process_id,
226 int render_view_id,
227 ThreeDAPIType requester) {
228 base::AutoLock auto_lock(lock_);
229 return private_->Are3DAPIsBlocked(
230 url, render_process_id, render_view_id, requester);
233 void GpuDataManagerImpl::DisableDomainBlockingFor3DAPIsForTesting() {
234 base::AutoLock auto_lock(lock_);
235 private_->DisableDomainBlockingFor3DAPIsForTesting();
238 size_t GpuDataManagerImpl::GetBlacklistedFeatureCount() const {
239 base::AutoLock auto_lock(lock_);
240 return private_->GetBlacklistedFeatureCount();
243 void GpuDataManagerImpl::SetDisplayCount(unsigned int display_count) {
244 base::AutoLock auto_lock(lock_);
245 private_->SetDisplayCount(display_count);
248 unsigned int GpuDataManagerImpl::GetDisplayCount() const {
249 base::AutoLock auto_lock(lock_);
250 return private_->GetDisplayCount();
253 bool GpuDataManagerImpl::UpdateActiveGpu(uint32 vendor_id, uint32 device_id) {
254 base::AutoLock auto_lock(lock_);
255 return private_->UpdateActiveGpu(vendor_id, device_id);
258 void GpuDataManagerImpl::Notify3DAPIBlocked(const GURL& url,
259 int render_process_id,
260 int render_view_id,
261 ThreeDAPIType requester) {
262 base::AutoLock auto_lock(lock_);
263 private_->Notify3DAPIBlocked(
264 url, render_process_id, render_view_id, requester);
267 void GpuDataManagerImpl::OnGpuProcessInitFailure() {
268 base::AutoLock auto_lock(lock_);
269 private_->OnGpuProcessInitFailure();
272 GpuDataManagerImpl::GpuDataManagerImpl()
273 : private_(GpuDataManagerImplPrivate::Create(this)) {
276 GpuDataManagerImpl::~GpuDataManagerImpl() {
279 } // namespace content