OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/gpu/compositor_util.h" | 5 #include "content/browser/gpu/compositor_util.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "cc/base/switches.h" | 10 #include "cc/base/switches.h" |
11 #include "content/browser/gpu/gpu_data_manager_impl.h" | 11 #include "content/browser/gpu/gpu_data_manager_impl.h" |
12 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
13 #include "gpu/config/gpu_feature_type.h" | 13 #include "gpu/config/gpu_feature_type.h" |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
| 19 const char* kGpuCompositingFeatureName = "gpu_compositing"; |
| 20 const char* kWebGLFeatureName = "webgl"; |
| 21 const char* kRasterizationFeatureName = "rasterization"; |
| 22 |
19 struct GpuFeatureInfo { | 23 struct GpuFeatureInfo { |
20 std::string name; | 24 std::string name; |
21 uint32 blocked; | 25 uint32 blocked; |
22 bool disabled; | 26 bool disabled; |
23 std::string disabled_description; | 27 std::string disabled_description; |
24 bool fallback_to_software; | 28 bool fallback_to_software; |
25 }; | 29 }; |
26 | 30 |
27 const GpuFeatureInfo GetGpuFeatureInfo(size_t index, bool* eof) { | 31 const GpuFeatureInfo GetGpuFeatureInfo(size_t index, bool* eof) { |
28 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 32 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
29 GpuDataManagerImpl* manager = GpuDataManagerImpl::GetInstance(); | 33 GpuDataManagerImpl* manager = GpuDataManagerImpl::GetInstance(); |
30 | 34 |
31 const GpuFeatureInfo kGpuFeatureInfo[] = { | 35 const GpuFeatureInfo kGpuFeatureInfo[] = { |
32 { | 36 { |
33 "2d_canvas", | 37 "2d_canvas", |
34 manager->IsFeatureBlacklisted( | 38 manager->IsFeatureBlacklisted( |
35 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS), | 39 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS), |
36 command_line.HasSwitch(switches::kDisableAccelerated2dCanvas) || | 40 command_line.HasSwitch(switches::kDisableAccelerated2dCanvas) || |
37 !GpuDataManagerImpl::GetInstance()-> | 41 !GpuDataManagerImpl::GetInstance()-> |
38 GetGPUInfo().SupportsAccelerated2dCanvas(), | 42 GetGPUInfo().SupportsAccelerated2dCanvas(), |
39 "Accelerated 2D canvas is unavailable: either disabled at the command" | 43 "Accelerated 2D canvas is unavailable: either disabled at the command" |
40 " line or not supported by the current system.", | 44 " line or not supported by the current system.", |
41 true | 45 true |
42 }, | 46 }, |
43 { | 47 { |
44 "gpu_compositing", | 48 kGpuCompositingFeatureName, |
45 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING), | 49 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING), |
46 false, | 50 false, |
47 "Gpu compositing has been disabled, either via about:flags or" | 51 "Gpu compositing has been disabled, either via about:flags or" |
48 " command line. The browser will fall back to software compositing" | 52 " command line. The browser will fall back to software compositing" |
49 " and hardware acceleration will be unavailable.", | 53 " and hardware acceleration will be unavailable.", |
50 true | 54 true |
51 }, | 55 }, |
52 { | 56 { |
53 "webgl", | 57 kWebGLFeatureName, |
54 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL), | 58 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL), |
55 command_line.HasSwitch(switches::kDisableExperimentalWebGL), | 59 command_line.HasSwitch(switches::kDisableExperimentalWebGL), |
56 "WebGL has been disabled, either via about:flags or command line.", | 60 "WebGL has been disabled, either via about:flags or command line.", |
57 false | 61 false |
58 }, | 62 }, |
59 { | 63 { |
60 "flash_3d", | 64 "flash_3d", |
61 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_FLASH3D), | 65 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_FLASH3D), |
62 command_line.HasSwitch(switches::kDisableFlash3d), | 66 command_line.HasSwitch(switches::kDisableFlash3d), |
63 "Using 3d in flash has been disabled, either via about:flags or" | 67 "Using 3d in flash has been disabled, either via about:flags or" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 { | 119 { |
116 "panel_fitting", | 120 "panel_fitting", |
117 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_PANEL_FITTING), | 121 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_PANEL_FITTING), |
118 command_line.HasSwitch(switches::kDisablePanelFitting), | 122 command_line.HasSwitch(switches::kDisablePanelFitting), |
119 "Panel fitting has been disabled, either via about:flags or command" | 123 "Panel fitting has been disabled, either via about:flags or command" |
120 " line.", | 124 " line.", |
121 false | 125 false |
122 }, | 126 }, |
123 #endif | 127 #endif |
124 { | 128 { |
125 "rasterization", | 129 kRasterizationFeatureName, |
126 manager->IsFeatureBlacklisted( | 130 manager->IsFeatureBlacklisted( |
127 gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION) && | 131 gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION) && |
128 !IsGpuRasterizationEnabled() && !IsForceGpuRasterizationEnabled(), | 132 !IsGpuRasterizationEnabled() && !IsForceGpuRasterizationEnabled(), |
129 !IsGpuRasterizationEnabled() && !IsForceGpuRasterizationEnabled() && | 133 !IsGpuRasterizationEnabled() && !IsForceGpuRasterizationEnabled() && |
130 !manager->IsFeatureBlacklisted( | 134 !manager->IsFeatureBlacklisted( |
131 gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION), | 135 gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION), |
132 "Accelerated rasterization has not been enabled or" | 136 "Accelerated rasterization has not been enabled or" |
133 " is not supported by the current system.", | 137 " is not supported by the current system.", |
134 true | 138 true |
135 } | 139 } |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 !manager->GpuAccessAllowed(&gpu_access_blocked_reason); | 236 !manager->GpuAccessAllowed(&gpu_access_blocked_reason); |
233 | 237 |
234 base::DictionaryValue* feature_status_dict = new base::DictionaryValue(); | 238 base::DictionaryValue* feature_status_dict = new base::DictionaryValue(); |
235 | 239 |
236 bool eof = false; | 240 bool eof = false; |
237 for (size_t i = 0; !eof; ++i) { | 241 for (size_t i = 0; !eof; ++i) { |
238 const GpuFeatureInfo gpu_feature_info = GetGpuFeatureInfo(i, &eof); | 242 const GpuFeatureInfo gpu_feature_info = GetGpuFeatureInfo(i, &eof); |
239 std::string status; | 243 std::string status; |
240 if (gpu_feature_info.disabled) { | 244 if (gpu_feature_info.disabled) { |
241 status = "disabled"; | 245 status = "disabled"; |
242 if (gpu_feature_info.name == "raster") { | 246 if (gpu_feature_info.name == kRasterizationFeatureName) { |
243 if (IsImplSidePaintingEnabled()) | 247 if (IsImplSidePaintingEnabled()) |
244 status += "_software_multithreaded"; | 248 status += "_software_multithreaded"; |
245 else | 249 else |
246 status += "_software"; | 250 status += "_software"; |
247 } else { | 251 } else { |
248 if (gpu_feature_info.fallback_to_software) | 252 if (gpu_feature_info.fallback_to_software) |
249 status += "_software"; | 253 status += "_software"; |
250 else | 254 else |
251 status += "_off"; | 255 status += "_off"; |
252 } | 256 } |
253 } else if (manager->ShouldUseSwiftShader()) { | 257 } else if (manager->ShouldUseSwiftShader()) { |
254 status = "unavailable_software"; | 258 status = "unavailable_software"; |
255 } else if (gpu_feature_info.blocked || | 259 } else if (gpu_feature_info.blocked || |
256 gpu_access_blocked) { | 260 gpu_access_blocked) { |
257 status = "unavailable"; | 261 status = "unavailable"; |
258 if (gpu_feature_info.fallback_to_software) | 262 if (gpu_feature_info.fallback_to_software) |
259 status += "_software"; | 263 status += "_software"; |
260 else | 264 else |
261 status += "_off"; | 265 status += "_off"; |
262 } else { | 266 } else { |
263 status = "enabled"; | 267 status = "enabled"; |
264 if (gpu_feature_info.name == "webgl" && | 268 if (gpu_feature_info.name == kWebGLFeatureName && |
265 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING)) | 269 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING)) |
266 status += "_readback"; | 270 status += "_readback"; |
267 if (gpu_feature_info.name == "raster") { | 271 if (gpu_feature_info.name == kRasterizationFeatureName) { |
268 if (IsForceGpuRasterizationEnabled()) | 272 if (IsForceGpuRasterizationEnabled()) |
269 status += "_force"; | 273 status += "_force"; |
270 } | 274 } |
271 } | 275 } |
272 if (gpu_feature_info.name == "gpu_compositing") { | 276 if (gpu_feature_info.name == kGpuCompositingFeatureName) { |
273 if (IsThreadedCompositingEnabled()) | 277 if (IsThreadedCompositingEnabled()) |
274 status += "_threaded"; | 278 status += "_threaded"; |
275 } | 279 } |
276 feature_status_dict->SetString( | 280 feature_status_dict->SetString( |
277 gpu_feature_info.name.c_str(), status.c_str()); | 281 gpu_feature_info.name.c_str(), status.c_str()); |
278 } | 282 } |
279 return feature_status_dict; | 283 return feature_status_dict; |
280 } | 284 } |
281 | 285 |
282 base::Value* GetProblems() { | 286 base::Value* GetProblems() { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 return problem_list; | 324 return problem_list; |
321 } | 325 } |
322 | 326 |
323 base::Value* GetDriverBugWorkarounds() { | 327 base::Value* GetDriverBugWorkarounds() { |
324 base::ListValue* workaround_list = new base::ListValue(); | 328 base::ListValue* workaround_list = new base::ListValue(); |
325 GpuDataManagerImpl::GetInstance()->GetDriverBugWorkarounds(workaround_list); | 329 GpuDataManagerImpl::GetInstance()->GetDriverBugWorkarounds(workaround_list); |
326 return workaround_list; | 330 return workaround_list; |
327 } | 331 } |
328 | 332 |
329 } // namespace content | 333 } // namespace content |
OLD | NEW |