Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: chrome/browser/gpu_blacklist.cc

Issue 10832044: Enhance GPU blacklist so we can also blacklist GPUs other than the primary one. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/gpu_blacklist.h ('k') | chrome/browser/gpu_blacklist_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/gpu_blacklist.h" 5 #include "chrome/browser/gpu_blacklist.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 valid = false; 63 valid = false;
64 } 64 }
65 if (valid) 65 if (valid)
66 return lexical; 66 return lexical;
67 return numerical; 67 return numerical;
68 } 68 }
69 69
70 const char kMultiGpuStyleStringAMDSwitchable[] = "amd_switchable"; 70 const char kMultiGpuStyleStringAMDSwitchable[] = "amd_switchable";
71 const char kMultiGpuStyleStringOptimus[] = "optimus"; 71 const char kMultiGpuStyleStringOptimus[] = "optimus";
72 72
73 const char kMultiGpuCategoryStringPrimary[] = "primary";
74 const char kMultiGpuCategoryStringSecondary[] = "secondary";
75 const char kMultiGpuCategoryStringAny[] = "any";
76
73 const char kVersionStyleStringNumerical[] = "numerical"; 77 const char kVersionStyleStringNumerical[] = "numerical";
74 const char kVersionStyleStringLexical[] = "lexical"; 78 const char kVersionStyleStringLexical[] = "lexical";
75 79
76 } // namespace anonymous 80 } // namespace anonymous
77 81
78 GpuBlacklist::VersionInfo::VersionInfo( 82 GpuBlacklist::VersionInfo::VersionInfo(
79 const std::string& version_op, 83 const std::string& version_op,
80 const std::string& version_style, 84 const std::string& version_style,
81 const std::string& version_string, 85 const std::string& version_string,
82 const std::string& version_string2) 86 const std::string& version_string2)
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 401
398 std::string multi_gpu_style; 402 std::string multi_gpu_style;
399 if (value->GetString("multi_gpu_style", &multi_gpu_style)) { 403 if (value->GetString("multi_gpu_style", &multi_gpu_style)) {
400 if (!entry->SetMultiGpuStyle(multi_gpu_style)) { 404 if (!entry->SetMultiGpuStyle(multi_gpu_style)) {
401 LOG(WARNING) << "Malformed multi_gpu_style entry " << entry->id(); 405 LOG(WARNING) << "Malformed multi_gpu_style entry " << entry->id();
402 return NULL; 406 return NULL;
403 } 407 }
404 dictionary_entry_count++; 408 dictionary_entry_count++;
405 } 409 }
406 410
411 std::string multi_gpu_category;
412 if (value->GetString("multi_gpu_category", &multi_gpu_category)) {
413 if (!entry->SetMultiGpuCategory(multi_gpu_category)) {
414 LOG(WARNING) << "Malformed multi_gpu_category entry " << entry->id();
415 return NULL;
416 }
417 dictionary_entry_count++;
418 }
419
407 DictionaryValue* driver_vendor_value = NULL; 420 DictionaryValue* driver_vendor_value = NULL;
408 if (value->GetDictionary("driver_vendor", &driver_vendor_value)) { 421 if (value->GetDictionary("driver_vendor", &driver_vendor_value)) {
409 std::string vendor_op; 422 std::string vendor_op;
410 std::string vendor_value; 423 std::string vendor_value;
411 driver_vendor_value->GetString("op", &vendor_op); 424 driver_vendor_value->GetString("op", &vendor_op);
412 driver_vendor_value->GetString("value", &vendor_value); 425 driver_vendor_value->GetString("value", &vendor_value);
413 if (!entry->SetDriverVendorInfo(vendor_op, vendor_value)) { 426 if (!entry->SetDriverVendorInfo(vendor_op, vendor_value)) {
414 LOG(WARNING) << "Malformed driver_vendor entry " << entry->id(); 427 LOG(WARNING) << "Malformed driver_vendor entry " << entry->id();
415 return NULL; 428 return NULL;
416 } 429 }
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 entry->contains_unknown_fields_ = true; 596 entry->contains_unknown_fields_ = true;
584 } 597 }
585 return entry; 598 return entry;
586 } 599 }
587 600
588 GpuBlacklist::GpuBlacklistEntry::GpuBlacklistEntry() 601 GpuBlacklist::GpuBlacklistEntry::GpuBlacklistEntry()
589 : id_(0), 602 : id_(0),
590 disabled_(false), 603 disabled_(false),
591 vendor_id_(0), 604 vendor_id_(0),
592 multi_gpu_style_(kMultiGpuStyleNone), 605 multi_gpu_style_(kMultiGpuStyleNone),
606 multi_gpu_category_(kMultiGpuCategoryPrimary),
593 feature_type_(content::GPU_FEATURE_TYPE_UNKNOWN), 607 feature_type_(content::GPU_FEATURE_TYPE_UNKNOWN),
594 contains_unknown_fields_(false), 608 contains_unknown_fields_(false),
595 contains_unknown_features_(false) { 609 contains_unknown_features_(false) {
596 } 610 }
597 611
598 bool GpuBlacklist::GpuBlacklistEntry::SetId(uint32 id) { 612 bool GpuBlacklist::GpuBlacklistEntry::SetId(uint32 id) {
599 if (id != 0) { 613 if (id != 0) {
600 id_ = id; 614 id_ = id;
601 return true; 615 return true;
602 } 616 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 650
637 bool GpuBlacklist::GpuBlacklistEntry::SetMultiGpuStyle( 651 bool GpuBlacklist::GpuBlacklistEntry::SetMultiGpuStyle(
638 const std::string& multi_gpu_style_string) { 652 const std::string& multi_gpu_style_string) {
639 MultiGpuStyle style = StringToMultiGpuStyle(multi_gpu_style_string); 653 MultiGpuStyle style = StringToMultiGpuStyle(multi_gpu_style_string);
640 if (style == kMultiGpuStyleNone) 654 if (style == kMultiGpuStyleNone)
641 return false; 655 return false;
642 multi_gpu_style_ = style; 656 multi_gpu_style_ = style;
643 return true; 657 return true;
644 } 658 }
645 659
660 bool GpuBlacklist::GpuBlacklistEntry::SetMultiGpuCategory(
661 const std::string& multi_gpu_category_string) {
662 MultiGpuCategory category =
663 StringToMultiGpuCategory(multi_gpu_category_string);
664 if (category == kMultiGpuCategoryNone)
665 return false;
666 multi_gpu_category_ = category;
667 return true;
668 }
669
646 bool GpuBlacklist::GpuBlacklistEntry::SetDriverVendorInfo( 670 bool GpuBlacklist::GpuBlacklistEntry::SetDriverVendorInfo(
647 const std::string& vendor_op, 671 const std::string& vendor_op,
648 const std::string& vendor_value) { 672 const std::string& vendor_value) {
649 driver_vendor_info_.reset( 673 driver_vendor_info_.reset(
650 new StringInfo(vendor_op, vendor_value)); 674 new StringInfo(vendor_op, vendor_value));
651 return driver_vendor_info_->IsValid(); 675 return driver_vendor_info_->IsValid();
652 } 676 }
653 677
654 bool GpuBlacklist::GpuBlacklistEntry::SetDriverVersionInfo( 678 bool GpuBlacklist::GpuBlacklistEntry::SetDriverVersionInfo(
655 const std::string& version_op, 679 const std::string& version_op,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 GpuBlacklist::GpuBlacklistEntry::MultiGpuStyle 775 GpuBlacklist::GpuBlacklistEntry::MultiGpuStyle
752 GpuBlacklist::GpuBlacklistEntry::StringToMultiGpuStyle( 776 GpuBlacklist::GpuBlacklistEntry::StringToMultiGpuStyle(
753 const std::string& style) { 777 const std::string& style) {
754 if (style == kMultiGpuStyleStringOptimus) 778 if (style == kMultiGpuStyleStringOptimus)
755 return kMultiGpuStyleOptimus; 779 return kMultiGpuStyleOptimus;
756 if (style == kMultiGpuStyleStringAMDSwitchable) 780 if (style == kMultiGpuStyleStringAMDSwitchable)
757 return kMultiGpuStyleAMDSwitchable; 781 return kMultiGpuStyleAMDSwitchable;
758 return kMultiGpuStyleNone; 782 return kMultiGpuStyleNone;
759 } 783 }
760 784
785 // static
786 GpuBlacklist::GpuBlacklistEntry::MultiGpuCategory
787 GpuBlacklist::GpuBlacklistEntry::StringToMultiGpuCategory(
788 const std::string& category) {
789 if (category == kMultiGpuCategoryStringPrimary)
790 return kMultiGpuCategoryPrimary;
791 if (category == kMultiGpuCategoryStringSecondary)
792 return kMultiGpuCategorySecondary;
793 if (category == kMultiGpuCategoryStringAny)
794 return kMultiGpuCategoryAny;
795 return kMultiGpuCategoryNone;
796 }
797
761 bool GpuBlacklist::GpuBlacklistEntry::Contains( 798 bool GpuBlacklist::GpuBlacklistEntry::Contains(
762 OsType os_type, const Version& os_version, 799 OsType os_type, const Version& os_version,
763 const content::GPUInfo& gpu_info) const { 800 const content::GPUInfo& gpu_info) const {
764 DCHECK(os_type != kOsAny); 801 DCHECK(os_type != kOsAny);
765 if (os_info_.get() != NULL && !os_info_->Contains(os_type, os_version)) 802 if (os_info_.get() != NULL && !os_info_->Contains(os_type, os_version))
766 return false; 803 return false;
767 if (vendor_id_ != 0 && vendor_id_ != gpu_info.gpu.vendor_id) 804 if (vendor_id_ != 0 && vendor_id_ != gpu_info.gpu.vendor_id &&
805 multi_gpu_category_ == kMultiGpuCategoryPrimary)
Ken Russell (switch to Gerrit) 2012/07/27 01:32:52 This logic and that below is getting really diffic
768 return false; 806 return false;
769 if (device_id_list_.size() > 0) { 807 if (device_id_list_.size() > 0) {
770 bool found = false; 808 bool found = false;
771 for (size_t i = 0; i < device_id_list_.size(); ++i) { 809 for (size_t i = 0; i < device_id_list_.size(); ++i) {
772 if (device_id_list_[i] == gpu_info.gpu.device_id) { 810 if ((multi_gpu_category_ == kMultiGpuCategoryPrimary ||
811 multi_gpu_category_ == kMultiGpuCategoryAny) &&
812 device_id_list_[i] == gpu_info.gpu.device_id) {
773 found = true; 813 found = true;
774 break; 814 break;
775 } 815 }
816 if (multi_gpu_category_ == kMultiGpuCategorySecondary ||
817 multi_gpu_category_ == kMultiGpuCategoryAny) {
818 for (size_t j = 0; j < gpu_info.secondary_gpus.size(); ++j) {
819 if (vendor_id_ == gpu_info.secondary_gpus[j].vendor_id &&
820 device_id_list_[i] == gpu_info.secondary_gpus[j].device_id) {
821 found = true;
822 break;
823 }
824 }
825 if (found)
826 break;
827 }
776 } 828 }
777 if (!found) 829 if (!found)
778 return false; 830 return false;
779 } 831 }
780 switch (multi_gpu_style_) { 832 switch (multi_gpu_style_) {
781 case kMultiGpuStyleOptimus: 833 case kMultiGpuStyleOptimus:
782 if (!gpu_info.optimus) 834 if (!gpu_info.optimus)
783 return false; 835 return false;
784 break; 836 break;
785 case kMultiGpuStyleAMDSwitchable: 837 case kMultiGpuStyleAMDSwitchable:
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 return kGT; 1164 return kGT;
1113 if (op == ">=") 1165 if (op == ">=")
1114 return kGE; 1166 return kGE;
1115 if (op == "any") 1167 if (op == "any")
1116 return kAny; 1168 return kAny;
1117 if (op == "between") 1169 if (op == "between")
1118 return kBetween; 1170 return kBetween;
1119 return kUnknown; 1171 return kUnknown;
1120 } 1172 }
1121 1173
OLDNEW
« no previous file with comments | « chrome/browser/gpu_blacklist.h ('k') | chrome/browser/gpu_blacklist_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698