Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/gpu_data_manager.h" | 5 #include "content/browser/gpu/gpu_data_manager.h" |
| 6 | 6 |
| 7 #if defined(OS_MACOSX) | 7 #if defined(OS_MACOSX) |
| 8 #include <CoreGraphics/CGDisplayConfiguration.h> | 8 #include <CoreGraphics/CGDisplayConfiguration.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
| 14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
| 15 #include "base/sys_info.h" | |
| 16 #include "base/values.h" | |
| 17 #include "base/version.h" | |
| 15 #include "content/browser/browser_thread.h" | 18 #include "content/browser/browser_thread.h" |
| 16 #include "content/browser/gpu/gpu_blacklist.h" | 19 #include "content/browser/gpu/gpu_blacklist.h" |
| 17 #include "content/browser/gpu/gpu_process_host.h" | 20 #include "content/browser/gpu/gpu_process_host.h" |
| 18 #include "content/common/content_client.h" | 21 #include "content/common/content_client.h" |
| 19 #include "content/common/content_switches.h" | 22 #include "content/common/content_switches.h" |
| 20 #include "content/common/gpu/gpu_messages.h" | 23 #include "content/common/gpu/gpu_messages.h" |
| 21 #include "content/gpu/gpu_info_collector.h" | 24 #include "content/gpu/gpu_info_collector.h" |
| 22 #include "ui/gfx/gl/gl_implementation.h" | 25 #include "ui/gfx/gl/gl_implementation.h" |
| 23 #include "ui/gfx/gl/gl_switches.h" | 26 #include "ui/gfx/gl/gl_switches.h" |
| 24 | 27 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 it != node.children.end(); | 75 it != node.children.end(); |
| 73 ++it) { | 76 ++it) { |
| 74 ListValue* sublist = DxDiagNodeToList(it->second); | 77 ListValue* sublist = DxDiagNodeToList(it->second); |
| 75 list->Append(NewDescriptionValuePair(it->first, sublist)); | 78 list->Append(NewDescriptionValuePair(it->first, sublist)); |
| 76 } | 79 } |
| 77 return list; | 80 return list; |
| 78 } | 81 } |
| 79 | 82 |
| 80 #endif // OS_WIN | 83 #endif // OS_WIN |
| 81 | 84 |
| 85 std::string GetOSString() { | |
| 86 std::string rt; | |
| 87 #if defined(OS_CHROMEOS) | |
| 88 rt = "ChromeOS"; | |
| 89 #elif defined(OS_WIN) | |
| 90 rt = "Win"; | |
| 91 std::string version_str = base::SysInfo::OperatingSystemVersion(); | |
| 92 size_t pos = version_str.find_first_not_of("0123456789."); | |
| 93 if (pos != std::string::npos) | |
| 94 version_str = version_str.substr(0, pos); | |
| 95 scoped_ptr<Version> os_version(Version::GetVersionFromString(version_str)); | |
| 96 DCHECK(os_version.get()); | |
| 97 const std::vector<uint16>& version_numbers = os_version->components(); | |
| 98 DCHECK_GE(version_numbers.size(), 2); | |
|
vangelis
2011/08/17 17:40:17
I think that in addition to the DCHECK we'll need
Zhenyao Mo
2011/08/17 19:29:54
Done.
| |
| 99 if (version_numbers[0] == 5) | |
| 100 rt += "XP"; | |
| 101 else if (version_numbers[0] == 6 && version_numbers[1] == 0) | |
| 102 rt += "Vista"; | |
| 103 else if (version_numbers[0] == 6 && version_numbers[1] == 1) | |
| 104 rt += "7"; | |
| 105 #elif defined(OS_LINUX) | |
| 106 rt = "Linux"; | |
| 107 #elif defined(OS_MACOSX) | |
| 108 rt = "Mac"; | |
| 109 #else | |
| 110 rt = "UnknownOS"; | |
| 111 #endif | |
| 112 return rt; | |
| 113 } | |
| 114 | |
| 115 void LogToHistogram( | |
| 116 const std::string& name, uint32 sample, uint32 boundary_value) { | |
| 117 base::LinearHistogram::FactoryGet(name, 1, boundary_value, boundary_value + 1, | |
| 118 base::Histogram::kUmaTargetedHistogramFlag)->Add(sample); | |
| 119 } | |
| 120 | |
| 82 } // namespace anonymous | 121 } // namespace anonymous |
| 83 | 122 |
| 84 GpuDataManager::GpuDataManager() | 123 GpuDataManager::GpuDataManager() |
| 85 : complete_gpu_info_already_requested_(false) { | 124 : complete_gpu_info_already_requested_(false) { |
| 86 // Certain tests doesn't go through the browser startup path that | 125 // Certain tests doesn't go through the browser startup path that |
| 87 // initializes GpuDataManager on FILE thread; therefore, it is initialized | 126 // initializes GpuDataManager on FILE thread; therefore, it is initialized |
| 88 // on UI thread later, and we skip the preliminary gpu info collection | 127 // on UI thread later, and we skip the preliminary gpu info collection |
| 89 // in such situation. | 128 // in such situation. |
| 90 if (!BrowserThread::CurrentlyOn(BrowserThread::FILE)) | 129 if (!BrowserThread::CurrentlyOn(BrowserThread::FILE)) |
| 91 return; | 130 return; |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 354 gpu_feature_flags_.set_flags(0); | 393 gpu_feature_flags_.set_flags(0); |
| 355 return; | 394 return; |
| 356 } | 395 } |
| 357 | 396 |
| 358 { | 397 { |
| 359 base::AutoLock auto_lock(gpu_info_lock_); | 398 base::AutoLock auto_lock(gpu_info_lock_); |
| 360 gpu_feature_flags_ = gpu_blacklist->DetermineGpuFeatureFlags( | 399 gpu_feature_flags_ = gpu_blacklist->DetermineGpuFeatureFlags( |
| 361 GpuBlacklist::kOsAny, NULL, gpu_info_); | 400 GpuBlacklist::kOsAny, NULL, gpu_info_); |
| 362 } | 401 } |
| 363 | 402 |
| 364 uint32 max_entry_id = gpu_blacklist->max_entry_id(); | |
| 365 if (!gpu_feature_flags_.flags()) { | |
| 366 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry", | |
| 367 0, max_entry_id + 1); | |
| 368 return; | |
| 369 } | |
| 370 | |
| 371 // Notify clients that GpuInfo state has changed | 403 // Notify clients that GpuInfo state has changed |
| 372 RunGpuInfoUpdateCallbacks(); | 404 RunGpuInfoUpdateCallbacks(); |
| 373 | 405 |
| 374 // TODO(zmo): move histograming to GpuBlacklist::DetermineGpuFeatureFlags. | 406 uint32 max_entry_id = gpu_blacklist->max_entry_id(); |
| 375 std::vector<uint32> flag_entries; | 407 |
| 376 gpu_blacklist->GetGpuFeatureFlagEntries( | 408 const GpuFeatureFlags::GpuFeatureType kGpuFeatures[] = { |
| 377 GpuFeatureFlags::kGpuFeatureAll, flag_entries); | 409 GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas, |
| 378 DCHECK_GT(flag_entries.size(), 0u); | 410 GpuFeatureFlags::kGpuFeatureAcceleratedCompositing, |
| 379 for (size_t i = 0; i < flag_entries.size(); ++i) { | 411 GpuFeatureFlags::kGpuFeatureWebgl |
| 380 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry", | 412 }; |
| 381 flag_entries[i], max_entry_id + 1); | 413 const std::string kGpuBlacklistHistogramPerEntryNames[] = { |
| 414 "GPU.BlacklistAccelerated2dCanvasTestResultsPerEntry", | |
| 415 "GPU.BlacklistAcceleratedCompositingTestResultsPerEntry", | |
| 416 "GPU.BlacklistWebglTestResultsPerEntry" | |
| 417 }; | |
| 418 const std::string kOSString = GetOSString(); | |
| 419 const std::string kGpuBlacklistHistogramNames[] = { | |
| 420 "GPU.BlacklistAccelerated2dCanvasTestResults" + kOSString, | |
| 421 "GPU.BlacklistAcceleratedCompositingTestResults" + kOSString, | |
| 422 "GPU.BlacklistWebglTestResults" + kOSString | |
| 423 }; | |
| 424 | |
| 425 uint32 flags = gpu_feature_flags_.flags(); | |
| 426 | |
| 427 for (size_t i = 0; | |
| 428 i < sizeof(kGpuFeatures) / sizeof(GpuFeatureFlags::GpuFeatureType); | |
| 429 ++i) { | |
| 430 if ((flags & kGpuFeatures[i]) == 0) { | |
| 431 LogToHistogram(kGpuBlacklistHistogramPerEntryNames[i], | |
| 432 0, max_entry_id + 1); | |
| 433 LogToHistogram(kGpuBlacklistHistogramNames[i], 0, 2); | |
|
vangelis
2011/08/17 17:40:17
Sorry, I should have spotted that earlier but I do
Zhenyao Mo
2011/08/17 19:29:54
Done.
| |
| 434 } else { | |
| 435 std::vector<uint32> flag_entries; | |
| 436 gpu_blacklist->GetGpuFeatureFlagEntries(kGpuFeatures[i], flag_entries); | |
| 437 DCHECK_GT(flag_entries.size(), 0u); | |
| 438 for (size_t j = 0; j < flag_entries.size(); ++j) { | |
| 439 LogToHistogram(kGpuBlacklistHistogramPerEntryNames[i], | |
| 440 flag_entries[j], max_entry_id + 1); | |
| 441 } | |
| 442 LogToHistogram(kGpuBlacklistHistogramNames[i], 1, 2); | |
| 443 } | |
| 382 } | 444 } |
| 383 } | 445 } |
| 384 | 446 |
| 385 GpuBlacklist* GpuDataManager::GetGpuBlacklist() { | 447 GpuBlacklist* GpuDataManager::GetGpuBlacklist() { |
| 386 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 448 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 387 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 449 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
| 388 if (browser_command_line.HasSwitch(switches::kIgnoreGpuBlacklist) || | 450 if (browser_command_line.HasSwitch(switches::kIgnoreGpuBlacklist) || |
| 389 browser_command_line.GetSwitchValueASCII( | 451 browser_command_line.GetSwitchValueASCII( |
| 390 switches::kUseGL) == gfx::kGLImplementationOSMesaName) | 452 switches::kUseGL) == gfx::kGLImplementationOSMesaName) |
| 391 return NULL; | 453 return NULL; |
| 392 // No need to return an empty blacklist. | 454 // No need to return an empty blacklist. |
| 393 if (gpu_blacklist_.get() != NULL && gpu_blacklist_->max_entry_id() == 0) | 455 if (gpu_blacklist_.get() != NULL && gpu_blacklist_->max_entry_id() == 0) |
| 394 return NULL; | 456 return NULL; |
| 395 return gpu_blacklist_.get(); | 457 return gpu_blacklist_.get(); |
| 396 } | 458 } |
| OLD | NEW |