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); | |
97 const std::vector<uint16>& version_numbers = os_version->components(); | |
98 if (version_numbers[0] == 5) | |
vangelis
2011/08/16 00:23:41
Probably needs a check that version_numbers.size()
Zhenyao Mo
2011/08/16 20:15:57
Done.
| |
99 rt += "XP"; | |
100 else if (version_numbers[0] == 6 && version_numbers[1] == 0) | |
101 rt += "Vista"; | |
102 else if (version_numbers[0] == 6 && version_numbers[1] == 1) | |
103 rt += "7"; | |
104 #elif defined(OS_LINUX) | |
105 rt = "Linux"; | |
106 #elif defined(OS_MACOSX) | |
107 rt = "Mac"; | |
108 #else | |
109 rt = "UnknownOS"; | |
110 #endif | |
111 return rt; | |
112 } | |
113 | |
82 } // namespace anonymous | 114 } // namespace anonymous |
83 | 115 |
84 GpuDataManager::GpuDataManager() | 116 GpuDataManager::GpuDataManager() |
85 : complete_gpu_info_already_requested_(false) { | 117 : complete_gpu_info_already_requested_(false) { |
86 // Certain tests doesn't go through the browser startup path that | 118 // Certain tests doesn't go through the browser startup path that |
87 // initializes GpuDataManager on FILE thread; therefore, it is initialized | 119 // initializes GpuDataManager on FILE thread; therefore, it is initialized |
88 // on UI thread later, and we skip the preliminary gpu info collection | 120 // on UI thread later, and we skip the preliminary gpu info collection |
89 // in such situation. | 121 // in such situation. |
90 if (!BrowserThread::CurrentlyOn(BrowserThread::FILE)) | 122 if (!BrowserThread::CurrentlyOn(BrowserThread::FILE)) |
91 return; | 123 return; |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
354 gpu_feature_flags_.set_flags(0); | 386 gpu_feature_flags_.set_flags(0); |
355 return; | 387 return; |
356 } | 388 } |
357 | 389 |
358 { | 390 { |
359 base::AutoLock auto_lock(gpu_info_lock_); | 391 base::AutoLock auto_lock(gpu_info_lock_); |
360 gpu_feature_flags_ = gpu_blacklist->DetermineGpuFeatureFlags( | 392 gpu_feature_flags_ = gpu_blacklist->DetermineGpuFeatureFlags( |
361 GpuBlacklist::kOsAny, NULL, gpu_info_); | 393 GpuBlacklist::kOsAny, NULL, gpu_info_); |
362 } | 394 } |
363 | 395 |
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 | 396 // Notify clients that GpuInfo state has changed |
372 RunGpuInfoUpdateCallbacks(); | 397 RunGpuInfoUpdateCallbacks(); |
373 | 398 |
374 // TODO(zmo): move histograming to GpuBlacklist::DetermineGpuFeatureFlags. | 399 uint32 max_entry_id = gpu_blacklist->max_entry_id(); |
375 std::vector<uint32> flag_entries; | 400 |
376 gpu_blacklist->GetGpuFeatureFlagEntries( | 401 const GpuFeatureFlags::GpuFeatureType kGpuFeatures[] = { |
377 GpuFeatureFlags::kGpuFeatureAll, flag_entries); | 402 GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas, |
378 DCHECK_GT(flag_entries.size(), 0u); | 403 GpuFeatureFlags::kGpuFeatureAcceleratedCompositing, |
379 for (size_t i = 0; i < flag_entries.size(); ++i) { | 404 GpuFeatureFlags::kGpuFeatureWebgl |
380 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry", | 405 }; |
381 flag_entries[i], max_entry_id + 1); | 406 const std::string kGpuBlacklistHistogramPerEntryNames[] = { |
407 "GPU.BlacklistAccelerated2dCanvasTestResultsPerEntry", | |
408 "GPU.BlacklistAcceleratedCompositingTestResultsPerEntry", | |
409 "GPU.BlacklistWebglTestResultsPerEntry" | |
410 }; | |
411 const std::string kOSString = GetOSString(); | |
412 const std::string kGpuBlacklistHistogramNames[] = { | |
413 "GPU.BlacklistAccelerated2dCanvasTestResults" + kOSString, | |
414 "GPU.BlacklistAcceleratedCompositingTestResults" + kOSString, | |
415 "GPU.BlacklistWebglTestResults" + kOSString | |
416 }; | |
417 | |
418 uint32 flags = gpu_feature_flags_.flags(); | |
419 | |
420 // Cannot use a for-loop here because UMA_HISTOGRAM_ENUMERATION will cache | |
421 // the names from previous loop and reuse them instead of using the correct | |
422 // names in this loop. | |
vangelis
2011/08/16 00:23:41
Hmm, that seems strange. What names get reused bet
Zhenyao Mo
2011/08/16 20:15:57
Per discussion with Vangelis and JAR, we will use
| |
423 int i; | |
424 { | |
425 // Accelerated 2d Canvas | |
426 i = 0; | |
427 if ((flags & kGpuFeatures[i]) == 0) { | |
428 UMA_HISTOGRAM_ENUMERATION(kGpuBlacklistHistogramPerEntryNames[i], | |
429 0, max_entry_id + 1); | |
430 UMA_HISTOGRAM_ENUMERATION(kGpuBlacklistHistogramNames[i], | |
431 0, 2); | |
432 } else { | |
433 std::vector<uint32> flag_entries; | |
434 gpu_blacklist->GetGpuFeatureFlagEntries(kGpuFeatures[i], flag_entries); | |
435 DCHECK_GT(flag_entries.size(), 0u); | |
436 for (size_t j = 0; j < flag_entries.size(); ++j) { | |
437 UMA_HISTOGRAM_ENUMERATION(kGpuBlacklistHistogramPerEntryNames[i], | |
438 flag_entries[j], max_entry_id + 1); | |
439 } | |
440 UMA_HISTOGRAM_ENUMERATION(kGpuBlacklistHistogramNames[i], | |
441 1, 2); | |
442 } | |
443 } | |
444 { | |
445 // Accelerated Compositing | |
446 i = 1; | |
447 if ((flags & kGpuFeatures[i]) == 0) { | |
448 UMA_HISTOGRAM_ENUMERATION(kGpuBlacklistHistogramPerEntryNames[i], | |
449 0, max_entry_id + 1); | |
450 UMA_HISTOGRAM_ENUMERATION(kGpuBlacklistHistogramNames[i], | |
451 0, 2); | |
452 } else { | |
453 std::vector<uint32> flag_entries; | |
454 gpu_blacklist->GetGpuFeatureFlagEntries(kGpuFeatures[i], flag_entries); | |
455 DCHECK_GT(flag_entries.size(), 0u); | |
456 for (size_t j = 0; j < flag_entries.size(); ++j) { | |
457 UMA_HISTOGRAM_ENUMERATION(kGpuBlacklistHistogramPerEntryNames[i], | |
458 flag_entries[j], max_entry_id + 1); | |
459 } | |
460 UMA_HISTOGRAM_ENUMERATION(kGpuBlacklistHistogramNames[i], | |
461 1, 2); | |
462 } | |
463 } | |
464 { | |
465 // WebGL | |
466 i = 2; | |
467 if ((flags & kGpuFeatures[i]) == 0) { | |
468 UMA_HISTOGRAM_ENUMERATION(kGpuBlacklistHistogramPerEntryNames[i], | |
469 0, max_entry_id + 1); | |
470 UMA_HISTOGRAM_ENUMERATION(kGpuBlacklistHistogramNames[i], | |
471 0, 2); | |
472 } else { | |
473 std::vector<uint32> flag_entries; | |
474 gpu_blacklist->GetGpuFeatureFlagEntries(kGpuFeatures[i], flag_entries); | |
475 DCHECK_GT(flag_entries.size(), 0u); | |
476 for (size_t j = 0; j < flag_entries.size(); ++j) { | |
477 UMA_HISTOGRAM_ENUMERATION(kGpuBlacklistHistogramPerEntryNames[i], | |
478 flag_entries[j], max_entry_id + 1); | |
479 } | |
480 UMA_HISTOGRAM_ENUMERATION(kGpuBlacklistHistogramNames[i], | |
481 1, 2); | |
482 } | |
382 } | 483 } |
383 } | 484 } |
384 | 485 |
385 GpuBlacklist* GpuDataManager::GetGpuBlacklist() { | 486 GpuBlacklist* GpuDataManager::GetGpuBlacklist() { |
386 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 487 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
387 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 488 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
388 if (browser_command_line.HasSwitch(switches::kIgnoreGpuBlacklist) || | 489 if (browser_command_line.HasSwitch(switches::kIgnoreGpuBlacklist) || |
389 browser_command_line.GetSwitchValueASCII( | 490 browser_command_line.GetSwitchValueASCII( |
390 switches::kUseGL) == gfx::kGLImplementationOSMesaName) | 491 switches::kUseGL) == gfx::kGLImplementationOSMesaName) |
391 return NULL; | 492 return NULL; |
392 // No need to return an empty blacklist. | 493 // No need to return an empty blacklist. |
393 if (gpu_blacklist_.get() != NULL && gpu_blacklist_->max_entry_id() == 0) | 494 if (gpu_blacklist_.get() != NULL && gpu_blacklist_->max_entry_id() == 0) |
394 return NULL; | 495 return NULL; |
395 return gpu_blacklist_.get(); | 496 return gpu_blacklist_.get(); |
396 } | 497 } |
OLD | NEW |