| 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 "base/strings/string_number_conversions.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 const char* kGpuCompositingFeatureName = "gpu_compositing"; | 28 const char* kGpuCompositingFeatureName = "gpu_compositing"; |
| 29 const char* kWebGLFeatureName = "webgl"; | 29 const char* kWebGLFeatureName = "webgl"; |
| 30 const char* kRasterizationFeatureName = "rasterization"; | 30 const char* kRasterizationFeatureName = "rasterization"; |
| 31 const char* kThreadedRasterizationFeatureName = "threaded_rasterization"; | 31 const char* kThreadedRasterizationFeatureName = "threaded_rasterization"; |
| 32 const char* kMultipleRasterThreadsFeatureName = "multiple_raster_threads"; | 32 const char* kMultipleRasterThreadsFeatureName = "multiple_raster_threads"; |
| 33 | 33 |
| 34 const int kMinRasterThreads = 1; | 34 const int kMinRasterThreads = 1; |
| 35 const int kMaxRasterThreads = 64; | 35 const int kMaxRasterThreads = 64; |
| 36 | 36 |
| 37 const int kMinMSAASampleCount = 0; |
| 38 |
| 37 struct GpuFeatureInfo { | 39 struct GpuFeatureInfo { |
| 38 std::string name; | 40 std::string name; |
| 39 bool blocked; | 41 bool blocked; |
| 40 bool disabled; | 42 bool disabled; |
| 41 std::string disabled_description; | 43 std::string disabled_description; |
| 42 bool fallback_to_software; | 44 bool fallback_to_software; |
| 43 }; | 45 }; |
| 44 | 46 |
| 45 const GpuFeatureInfo GetGpuFeatureInfo(size_t index, bool* eof) { | 47 const GpuFeatureInfo GetGpuFeatureInfo(size_t index, bool* eof) { |
| 46 const base::CommandLine& command_line = | 48 const base::CommandLine& command_line = |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 if (!command_line.HasSwitch(switches::kNumRasterThreads)) | 250 if (!command_line.HasSwitch(switches::kNumRasterThreads)) |
| 249 return 0; | 251 return 0; |
| 250 std::string string_value = | 252 std::string string_value = |
| 251 command_line.GetSwitchValueASCII(switches::kNumRasterThreads); | 253 command_line.GetSwitchValueASCII(switches::kNumRasterThreads); |
| 252 int force_num_raster_threads = 0; | 254 int force_num_raster_threads = 0; |
| 253 if (base::StringToInt(string_value, &force_num_raster_threads) && | 255 if (base::StringToInt(string_value, &force_num_raster_threads) && |
| 254 force_num_raster_threads >= kMinRasterThreads && | 256 force_num_raster_threads >= kMinRasterThreads && |
| 255 force_num_raster_threads <= kMaxRasterThreads) { | 257 force_num_raster_threads <= kMaxRasterThreads) { |
| 256 return force_num_raster_threads; | 258 return force_num_raster_threads; |
| 257 } else { | 259 } else { |
| 258 LOG(WARNING) << "Failed to parse switch " << | 260 DLOG(WARNING) << "Failed to parse switch " << |
| 259 switches::kNumRasterThreads << ": " << string_value; | 261 switches::kNumRasterThreads << ": " << string_value; |
| 260 return 0; | 262 return 0; |
| 261 } | 263 } |
| 262 } | 264 } |
| 263 | 265 |
| 264 bool IsGpuRasterizationEnabled() { | 266 bool IsGpuRasterizationEnabled() { |
| 265 const base::CommandLine& command_line = | 267 const base::CommandLine& command_line = |
| 266 *base::CommandLine::ForCurrentProcess(); | 268 *base::CommandLine::ForCurrentProcess(); |
| 267 | 269 |
| 268 if (!IsImplSidePaintingEnabled()) | 270 if (!IsImplSidePaintingEnabled()) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 294 #if defined(OS_ANDROID) | 296 #if defined(OS_ANDROID) |
| 295 return false; | 297 return false; |
| 296 #else | 298 #else |
| 297 const base::CommandLine& command_line = | 299 const base::CommandLine& command_line = |
| 298 *base::CommandLine::ForCurrentProcess(); | 300 *base::CommandLine::ForCurrentProcess(); |
| 299 | 301 |
| 300 return command_line.HasSwitch(switches::kUseSurfaces); | 302 return command_line.HasSwitch(switches::kUseSurfaces); |
| 301 #endif | 303 #endif |
| 302 } | 304 } |
| 303 | 305 |
| 306 int GpuRasterizationMSAASampleCount() { |
| 307 const base::CommandLine& command_line = |
| 308 *base::CommandLine::ForCurrentProcess(); |
| 309 |
| 310 if (!command_line.HasSwitch(switches::kGpuRasterizationMSAASampleCount)) |
| 311 return 0; |
| 312 std::string string_value = command_line.GetSwitchValueASCII( |
| 313 switches::kGpuRasterizationMSAASampleCount); |
| 314 int msaa_sample_count = 0; |
| 315 if (base::StringToInt(string_value, &msaa_sample_count) && |
| 316 msaa_sample_count >= kMinMSAASampleCount) { |
| 317 return msaa_sample_count; |
| 318 } else { |
| 319 DLOG(WARNING) << "Failed to parse switch " |
| 320 << switches::kGpuRasterizationMSAASampleCount << ": " |
| 321 << string_value; |
| 322 return 0; |
| 323 } |
| 324 } |
| 325 |
| 304 base::DictionaryValue* GetFeatureStatus() { | 326 base::DictionaryValue* GetFeatureStatus() { |
| 305 GpuDataManagerImpl* manager = GpuDataManagerImpl::GetInstance(); | 327 GpuDataManagerImpl* manager = GpuDataManagerImpl::GetInstance(); |
| 306 std::string gpu_access_blocked_reason; | 328 std::string gpu_access_blocked_reason; |
| 307 bool gpu_access_blocked = | 329 bool gpu_access_blocked = |
| 308 !manager->GpuAccessAllowed(&gpu_access_blocked_reason); | 330 !manager->GpuAccessAllowed(&gpu_access_blocked_reason); |
| 309 | 331 |
| 310 base::DictionaryValue* feature_status_dict = new base::DictionaryValue(); | 332 base::DictionaryValue* feature_status_dict = new base::DictionaryValue(); |
| 311 | 333 |
| 312 bool eof = false; | 334 bool eof = false; |
| 313 for (size_t i = 0; !eof; ++i) { | 335 for (size_t i = 0; !eof; ++i) { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 } | 418 } |
| 397 } | 419 } |
| 398 return problem_list; | 420 return problem_list; |
| 399 } | 421 } |
| 400 | 422 |
| 401 std::vector<std::string> GetDriverBugWorkarounds() { | 423 std::vector<std::string> GetDriverBugWorkarounds() { |
| 402 return GpuDataManagerImpl::GetInstance()->GetDriverBugWorkarounds(); | 424 return GpuDataManagerImpl::GetInstance()->GetDriverBugWorkarounds(); |
| 403 } | 425 } |
| 404 | 426 |
| 405 } // namespace content | 427 } // namespace content |
| OLD | NEW |