| 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 "chrome/browser/gpu_blacklist.h" | 5 #include "chrome/browser/gpu_blacklist.h" |
| 6 | 6 |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 case GpuFeatureFlags::kGpuFeatureUnknown: | 371 case GpuFeatureFlags::kGpuFeatureUnknown: |
| 372 return false; | 372 return false; |
| 373 } | 373 } |
| 374 } | 374 } |
| 375 feature_flags_.reset(new GpuFeatureFlags()); | 375 feature_flags_.reset(new GpuFeatureFlags()); |
| 376 feature_flags_->set_flags(flags); | 376 feature_flags_->set_flags(flags); |
| 377 return true; | 377 return true; |
| 378 } | 378 } |
| 379 | 379 |
| 380 bool GpuBlacklist::GpuBlacklistEntry::Contains( | 380 bool GpuBlacklist::GpuBlacklistEntry::Contains( |
| 381 OsType os_type, const Version& os_version, | 381 OsType os_type, const Version& os_version, const GPUInfo& gpu_info) const { |
| 382 uint32 vendor_id, uint32 device_id, | |
| 383 const std::string& driver_vendor, | |
| 384 const Version& driver_version, | |
| 385 const std::string& gl_renderer) const { | |
| 386 DCHECK(os_type != kOsAny); | 382 DCHECK(os_type != kOsAny); |
| 387 if (os_info_.get() != NULL && !os_info_->Contains(os_type, os_version)) | 383 if (os_info_.get() != NULL && !os_info_->Contains(os_type, os_version)) |
| 388 return false; | 384 return false; |
| 389 if (vendor_id_ != 0 && vendor_id_ != vendor_id) | 385 if (vendor_id_ != 0 && vendor_id_ != gpu_info.vendor_id()) |
| 390 return false; | 386 return false; |
| 391 if (device_id_ != 0 && device_id_ != device_id) | 387 if (device_id_ != 0 && device_id_ != gpu_info.device_id()) |
| 392 return false; | 388 return false; |
| 393 if (driver_vendor_info_.get() != NULL && | 389 if (driver_vendor_info_.get() != NULL && |
| 394 !driver_vendor_info_->Contains(driver_vendor)) | 390 !driver_vendor_info_->Contains(gpu_info.driver_vendor())) |
| 395 return false; | 391 return false; |
| 396 if (driver_version_info_.get() != NULL && | 392 if (driver_version_info_.get() != NULL) { |
| 397 !driver_version_info_->Contains(driver_version)) | 393 scoped_ptr<Version> driver_version( |
| 398 return false; | 394 Version::GetVersionFromString(gpu_info.driver_version())); |
| 395 if (driver_version.get() == NULL || |
| 396 !driver_version_info_->Contains(*driver_version)) |
| 397 return false; |
| 398 } |
| 399 if (gl_renderer_info_.get() != NULL && | 399 if (gl_renderer_info_.get() != NULL && |
| 400 !gl_renderer_info_->Contains(gl_renderer)) | 400 !gl_renderer_info_->Contains(gpu_info.gl_renderer())) |
| 401 return false; | 401 return false; |
| 402 return true; | 402 return true; |
| 403 } | 403 } |
| 404 | 404 |
| 405 GpuBlacklist::OsType GpuBlacklist::GpuBlacklistEntry::GetOsType() const { | 405 GpuBlacklist::OsType GpuBlacklist::GpuBlacklistEntry::GetOsType() const { |
| 406 if (os_info_.get() == NULL) | 406 if (os_info_.get() == NULL) |
| 407 return kOsUnknown; | 407 return kOsUnknown; |
| 408 return os_info_->type(); | 408 return os_info_->type(); |
| 409 } | 409 } |
| 410 | 410 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 | 485 |
| 486 GpuFeatureFlags GpuBlacklist::DetermineGpuFeatureFlags( | 486 GpuFeatureFlags GpuBlacklist::DetermineGpuFeatureFlags( |
| 487 GpuBlacklist::OsType os, | 487 GpuBlacklist::OsType os, |
| 488 Version* os_version, | 488 Version* os_version, |
| 489 const GPUInfo& gpu_info) { | 489 const GPUInfo& gpu_info) { |
| 490 active_entries_.clear(); | 490 active_entries_.clear(); |
| 491 GpuFeatureFlags flags; | 491 GpuFeatureFlags flags; |
| 492 // No need to go through blacklist entries if GPUInfo isn't available. | 492 // No need to go through blacklist entries if GPUInfo isn't available. |
| 493 if (gpu_info.progress() == GPUInfo::kUninitialized) | 493 if (gpu_info.progress() == GPUInfo::kUninitialized) |
| 494 return flags; | 494 return flags; |
| 495 scoped_ptr<Version> driver_version( | |
| 496 Version::GetVersionFromString(gpu_info.driver_version())); | |
| 497 if (driver_version.get() == NULL) | |
| 498 return flags; | |
| 499 | 495 |
| 500 if (os == kOsAny) | 496 if (os == kOsAny) |
| 501 os = GetOsType(); | 497 os = GetOsType(); |
| 502 scoped_ptr<Version> my_os_version; | 498 scoped_ptr<Version> my_os_version; |
| 503 if (os_version == NULL) { | 499 if (os_version == NULL) { |
| 504 std::string version_string; | 500 std::string version_string; |
| 505 #if defined(OS_MACOSX) | 501 #if defined(OS_MACOSX) |
| 506 // Seems like base::SysInfo::OperatingSystemVersion() returns the wrong | 502 // Seems like base::SysInfo::OperatingSystemVersion() returns the wrong |
| 507 // version in MacOsx. | 503 // version in MacOsx. |
| 508 int32 version_major, version_minor, version_bugfix; | 504 int32 version_major, version_minor, version_bugfix; |
| 509 base::SysInfo::OperatingSystemVersionNumbers( | 505 base::SysInfo::OperatingSystemVersionNumbers( |
| 510 &version_major, &version_minor, &version_bugfix); | 506 &version_major, &version_minor, &version_bugfix); |
| 511 version_string = base::StringPrintf("%d.%d.%d", | 507 version_string = base::StringPrintf("%d.%d.%d", |
| 512 version_major, | 508 version_major, |
| 513 version_minor, | 509 version_minor, |
| 514 version_bugfix); | 510 version_bugfix); |
| 515 #else | 511 #else |
| 516 version_string = base::SysInfo::OperatingSystemVersion(); | 512 version_string = base::SysInfo::OperatingSystemVersion(); |
| 517 size_t pos = version_string.find_first_not_of("0123456789."); | 513 size_t pos = version_string.find_first_not_of("0123456789."); |
| 518 if (pos != std::string::npos) | 514 if (pos != std::string::npos) |
| 519 version_string = version_string.substr(0, pos); | 515 version_string = version_string.substr(0, pos); |
| 520 #endif | 516 #endif |
| 521 my_os_version.reset(Version::GetVersionFromString(version_string)); | 517 my_os_version.reset(Version::GetVersionFromString(version_string)); |
| 522 os_version = my_os_version.get(); | 518 os_version = my_os_version.get(); |
| 523 } | 519 } |
| 524 DCHECK(os_version != NULL); | 520 DCHECK(os_version != NULL); |
| 525 | 521 |
| 526 for (size_t i = 0; i < blacklist_.size(); ++i) { | 522 for (size_t i = 0; i < blacklist_.size(); ++i) { |
| 527 if (blacklist_[i]->Contains(os, *os_version, | 523 if (blacklist_[i]->Contains(os, *os_version, gpu_info)) { |
| 528 gpu_info.vendor_id(), gpu_info.device_id(), | |
| 529 gpu_info.driver_vendor(), | |
| 530 *driver_version, | |
| 531 gpu_info.gl_renderer())) { | |
| 532 flags.Combine(blacklist_[i]->GetGpuFeatureFlags()); | 524 flags.Combine(blacklist_[i]->GetGpuFeatureFlags()); |
| 533 active_entries_.push_back(blacklist_[i]); | 525 active_entries_.push_back(blacklist_[i]); |
| 534 } | 526 } |
| 535 } | 527 } |
| 536 return flags; | 528 return flags; |
| 537 } | 529 } |
| 538 | 530 |
| 539 void GpuBlacklist::GetGpuFeatureFlagEntries( | 531 void GpuBlacklist::GetGpuFeatureFlagEntries( |
| 540 GpuFeatureFlags::GpuFeatureType feature, | 532 GpuFeatureFlags::GpuFeatureType feature, |
| 541 std::vector<uint32>& entry_ids) const { | 533 std::vector<uint32>& entry_ids) const { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 #endif | 568 #endif |
| 577 } | 569 } |
| 578 | 570 |
| 579 void GpuBlacklist::Clear() { | 571 void GpuBlacklist::Clear() { |
| 580 for (size_t i = 0; i < blacklist_.size(); ++i) | 572 for (size_t i = 0; i < blacklist_.size(); ++i) |
| 581 delete blacklist_[i]; | 573 delete blacklist_[i]; |
| 582 blacklist_.clear(); | 574 blacklist_.clear(); |
| 583 active_entries_.clear(); | 575 active_entries_.clear(); |
| 584 } | 576 } |
| 585 | 577 |
| OLD | NEW |