| 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 "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/strings/string_number_conversions.h" |
| 10 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 11 #include "cc/base/switches.h" | 12 #include "cc/base/switches.h" |
| 12 #include "content/browser/gpu/gpu_data_manager_impl.h" | 13 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 13 #include "content/public/common/content_switches.h" | 14 #include "content/public/common/content_switches.h" |
| 14 #include "gpu/config/gpu_feature_type.h" | 15 #include "gpu/config/gpu_feature_type.h" |
| 15 | 16 |
| 16 namespace content { | 17 namespace content { |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 static bool IsGpuRasterizationBlacklisted() { | 21 static bool IsGpuRasterizationBlacklisted() { |
| 21 GpuDataManagerImpl* manager = GpuDataManagerImpl::GetInstance(); | 22 GpuDataManagerImpl* manager = GpuDataManagerImpl::GetInstance(); |
| 22 return manager->IsFeatureBlacklisted( | 23 return manager->IsFeatureBlacklisted( |
| 23 gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION); | 24 gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION); |
| 24 } | 25 } |
| 25 | 26 |
| 26 const char* kGpuCompositingFeatureName = "gpu_compositing"; | 27 const char* kGpuCompositingFeatureName = "gpu_compositing"; |
| 27 const char* kWebGLFeatureName = "webgl"; | 28 const char* kWebGLFeatureName = "webgl"; |
| 28 const char* kRasterizationFeatureName = "rasterization"; | 29 const char* kRasterizationFeatureName = "rasterization"; |
| 29 const char* kThreadedRasterizationFeatureName = "threaded_rasterization"; | 30 const char* kThreadedRasterizationFeatureName = "threaded_rasterization"; |
| 31 const char* kMultipleRasterThreadsFeatureName = "multiple_raster_threads"; |
| 32 |
| 33 const int kMinRasterThreads = 1; |
| 34 const int kMaxRasterThreads = 64; |
| 30 | 35 |
| 31 struct GpuFeatureInfo { | 36 struct GpuFeatureInfo { |
| 32 std::string name; | 37 std::string name; |
| 33 bool blocked; | 38 bool blocked; |
| 34 bool disabled; | 39 bool disabled; |
| 35 std::string disabled_description; | 40 std::string disabled_description; |
| 36 bool fallback_to_software; | 41 bool fallback_to_software; |
| 37 }; | 42 }; |
| 38 | 43 |
| 39 const GpuFeatureInfo GetGpuFeatureInfo(size_t index, bool* eof) { | 44 const GpuFeatureInfo GetGpuFeatureInfo(size_t index, bool* eof) { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 " or command line.", | 140 " or command line.", |
| 136 true | 141 true |
| 137 }, | 142 }, |
| 138 { | 143 { |
| 139 kThreadedRasterizationFeatureName, | 144 kThreadedRasterizationFeatureName, |
| 140 false, | 145 false, |
| 141 !IsImplSidePaintingEnabled(), | 146 !IsImplSidePaintingEnabled(), |
| 142 "Threaded rasterization has not been enabled or" | 147 "Threaded rasterization has not been enabled or" |
| 143 " is not supported by the current system.", | 148 " is not supported by the current system.", |
| 144 false | 149 false |
| 145 } | 150 }, |
| 146 | 151 { |
| 152 kMultipleRasterThreadsFeatureName, |
| 153 false, |
| 154 NumberOfRendererRasterThreads() == 1, |
| 155 "Raster is using a single thread.", |
| 156 false |
| 157 }, |
| 147 }; | 158 }; |
| 148 DCHECK(index < arraysize(kGpuFeatureInfo)); | 159 DCHECK(index < arraysize(kGpuFeatureInfo)); |
| 149 *eof = (index == arraysize(kGpuFeatureInfo) - 1); | 160 *eof = (index == arraysize(kGpuFeatureInfo) - 1); |
| 150 return kGpuFeatureInfo[index]; | 161 return kGpuFeatureInfo[index]; |
| 151 } | 162 } |
| 152 | 163 |
| 153 } // namespace | 164 } // namespace |
| 154 | 165 |
| 155 bool IsPinchVirtualViewportEnabled() { | 166 bool IsPinchVirtualViewportEnabled() { |
| 156 const base::CommandLine& command_line = | 167 const base::CommandLine& command_line = |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 return false; | 204 return false; |
| 194 else if (command_line.HasSwitch(switches::kEnableImplSidePainting)) | 205 else if (command_line.HasSwitch(switches::kEnableImplSidePainting)) |
| 195 return true; | 206 return true; |
| 196 else if (command_line.HasSwitch( | 207 else if (command_line.HasSwitch( |
| 197 switches::kEnableBleedingEdgeRenderingFastPaths)) | 208 switches::kEnableBleedingEdgeRenderingFastPaths)) |
| 198 return true; | 209 return true; |
| 199 | 210 |
| 200 return true; | 211 return true; |
| 201 } | 212 } |
| 202 | 213 |
| 214 int NumberOfRendererRasterThreads() { |
| 215 int num_raster_threads = 1; |
| 216 |
| 217 int force_num_raster_threads = ForceNumberOfRendererRasterThreads(); |
| 218 if (force_num_raster_threads) |
| 219 num_raster_threads = force_num_raster_threads; |
| 220 |
| 221 return num_raster_threads; |
| 222 } |
| 223 |
| 224 int ForceNumberOfRendererRasterThreads() { |
| 225 const base::CommandLine& command_line = |
| 226 *base::CommandLine::ForCurrentProcess(); |
| 227 |
| 228 if (!command_line.HasSwitch(switches::kNumRasterThreads)) |
| 229 return 0; |
| 230 std::string string_value = |
| 231 command_line.GetSwitchValueASCII(switches::kNumRasterThreads); |
| 232 int force_num_raster_threads = 0; |
| 233 if (base::StringToInt(string_value, &force_num_raster_threads) && |
| 234 force_num_raster_threads >= kMinRasterThreads && |
| 235 force_num_raster_threads <= kMaxRasterThreads) { |
| 236 return force_num_raster_threads; |
| 237 } else { |
| 238 LOG(WARNING) << "Failed to parse switch " << |
| 239 switches::kNumRasterThreads << ": " << string_value; |
| 240 return 0; |
| 241 } |
| 242 } |
| 243 |
| 203 bool IsGpuRasterizationEnabled() { | 244 bool IsGpuRasterizationEnabled() { |
| 204 const base::CommandLine& command_line = | 245 const base::CommandLine& command_line = |
| 205 *base::CommandLine::ForCurrentProcess(); | 246 *base::CommandLine::ForCurrentProcess(); |
| 206 | 247 |
| 207 if (!IsImplSidePaintingEnabled()) | 248 if (!IsImplSidePaintingEnabled()) |
| 208 return false; | 249 return false; |
| 209 | 250 |
| 210 if (command_line.HasSwitch(switches::kDisableGpuRasterization)) | 251 if (command_line.HasSwitch(switches::kDisableGpuRasterization)) |
| 211 return false; | 252 return false; |
| 212 else if (command_line.HasSwitch(switches::kEnableGpuRasterization)) | 253 else if (command_line.HasSwitch(switches::kEnableGpuRasterization)) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 status = "disabled"; | 286 status = "disabled"; |
| 246 if (gpu_feature_info.fallback_to_software) | 287 if (gpu_feature_info.fallback_to_software) |
| 247 status += "_software"; | 288 status += "_software"; |
| 248 else | 289 else |
| 249 status += "_off"; | 290 status += "_off"; |
| 250 if (gpu_feature_info.name == kThreadedRasterizationFeatureName) | 291 if (gpu_feature_info.name == kThreadedRasterizationFeatureName) |
| 251 status += "_ok"; | 292 status += "_ok"; |
| 252 } else if (gpu_feature_info.blocked || | 293 } else if (gpu_feature_info.blocked || |
| 253 gpu_access_blocked) { | 294 gpu_access_blocked) { |
| 254 status = "unavailable"; | 295 status = "unavailable"; |
| 255 if (gpu_feature_info.fallback_to_software) { | 296 if (gpu_feature_info.fallback_to_software) |
| 256 status += "_software"; | 297 status += "_software"; |
| 257 } else | 298 else |
| 258 status += "_off"; | 299 status += "_off"; |
| 259 } else { | 300 } else { |
| 260 status = "enabled"; | 301 status = "enabled"; |
| 261 if (gpu_feature_info.name == kWebGLFeatureName && | 302 if (gpu_feature_info.name == kWebGLFeatureName && |
| 262 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING)) | 303 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING)) |
| 263 status += "_readback"; | 304 status += "_readback"; |
| 264 if (gpu_feature_info.name == kRasterizationFeatureName) { | 305 if (gpu_feature_info.name == kRasterizationFeatureName) { |
| 265 if (IsForceGpuRasterizationEnabled()) | 306 if (IsForceGpuRasterizationEnabled()) |
| 266 status += "_force"; | 307 status += "_force"; |
| 267 } | 308 } |
| 268 if (gpu_feature_info.name == kThreadedRasterizationFeatureName) | 309 if (gpu_feature_info.name == kMultipleRasterThreadsFeatureName) { |
| 310 if (ForceNumberOfRendererRasterThreads() > 0) |
| 311 status += "_force"; |
| 312 } |
| 313 if (gpu_feature_info.name == kThreadedRasterizationFeatureName || |
| 314 gpu_feature_info.name == kMultipleRasterThreadsFeatureName) |
| 269 status += "_on"; | 315 status += "_on"; |
| 270 } | 316 } |
| 271 if (gpu_feature_info.name == kWebGLFeatureName && | 317 if (gpu_feature_info.name == kWebGLFeatureName && |
| 272 (gpu_feature_info.blocked || gpu_access_blocked) && | 318 (gpu_feature_info.blocked || gpu_access_blocked) && |
| 273 manager->ShouldUseSwiftShader()) { | 319 manager->ShouldUseSwiftShader()) { |
| 274 status = "unavailable_software"; | 320 status = "unavailable_software"; |
| 275 } | 321 } |
| 276 | 322 |
| 277 feature_status_dict->SetString( | 323 feature_status_dict->SetString( |
| 278 gpu_feature_info.name.c_str(), status.c_str()); | 324 gpu_feature_info.name.c_str(), status.c_str()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 return problem_list; | 367 return problem_list; |
| 322 } | 368 } |
| 323 | 369 |
| 324 base::Value* GetDriverBugWorkarounds() { | 370 base::Value* GetDriverBugWorkarounds() { |
| 325 base::ListValue* workaround_list = new base::ListValue(); | 371 base::ListValue* workaround_list = new base::ListValue(); |
| 326 GpuDataManagerImpl::GetInstance()->GetDriverBugWorkarounds(workaround_list); | 372 GpuDataManagerImpl::GetInstance()->GetDriverBugWorkarounds(workaround_list); |
| 327 return workaround_list; | 373 return workaround_list; |
| 328 } | 374 } |
| 329 | 375 |
| 330 } // namespace content | 376 } // namespace content |
| OLD | NEW |