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

Side by Side Diff: trunk/src/gpu/config/gpu_control_list.cc

Issue 465163002: Revert 289067 "Use RE string pattern matching for blacklist stri..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "gpu/config/gpu_control_list.h" 5 #include "gpu/config/gpu_control_list.h"
6 6
7 #include "base/cpu.h" 7 #include "base/cpu.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/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_split.h" 11 #include "base/strings/string_split.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "base/sys_info.h" 14 #include "base/sys_info.h"
15 #include "gpu/config/gpu_info.h" 15 #include "gpu/config/gpu_info.h"
16 #include "gpu/config/gpu_util.h" 16 #include "gpu/config/gpu_util.h"
17 #include "third_party/re2/re2/re2.h"
18 17
19 namespace gpu { 18 namespace gpu {
20 namespace { 19 namespace {
21 20
22 // Break a version string into segments. Return true if each segment is 21 // Break a version string into segments. Return true if each segment is
23 // a valid number, and not all segment is 0. 22 // a valid number, and not all segment is 0.
24 bool ProcessVersionString(const std::string& version_string, 23 bool ProcessVersionString(const std::string& version_string,
25 char splitter, 24 char splitter,
26 std::vector<std::string>* version) { 25 std::vector<std::string>* version) {
27 DCHECK(version); 26 DCHECK(version);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 value1 = number[i] - '0'; 82 value1 = number[i] - '0';
84 unsigned value2 = number_ref[i] - '0'; 83 unsigned value2 = number_ref[i] - '0';
85 if (value1 > value2) 84 if (value1 > value2)
86 return 1; 85 return 1;
87 if (value1 < value2) 86 if (value1 < value2)
88 return -1; 87 return -1;
89 } 88 }
90 return 0; 89 return 0;
91 } 90 }
92 91
93 // A mismatch is identified only if both |input| and |pattern| are not empty.
94 bool StringMismatch(const std::string& input, const std::string& pattern) {
95 if (input.empty() || pattern.empty())
96 return false;
97 return !RE2::FullMatch(input, pattern);
98 }
99
100 const char kMultiGpuStyleStringAMDSwitchable[] = "amd_switchable"; 92 const char kMultiGpuStyleStringAMDSwitchable[] = "amd_switchable";
101 const char kMultiGpuStyleStringAMDSwitchableDiscrete[] = 93 const char kMultiGpuStyleStringAMDSwitchableDiscrete[] =
102 "amd_switchable_discrete"; 94 "amd_switchable_discrete";
103 const char kMultiGpuStyleStringAMDSwitchableIntegrated[] = 95 const char kMultiGpuStyleStringAMDSwitchableIntegrated[] =
104 "amd_switchable_integrated"; 96 "amd_switchable_integrated";
105 const char kMultiGpuStyleStringOptimus[] = "optimus"; 97 const char kMultiGpuStyleStringOptimus[] = "optimus";
106 98
107 const char kMultiGpuCategoryStringPrimary[] = "primary"; 99 const char kMultiGpuCategoryStringPrimary[] = "primary";
108 const char kMultiGpuCategoryStringSecondary[] = "secondary"; 100 const char kMultiGpuCategoryStringSecondary[] = "secondary";
109 const char kMultiGpuCategoryStringActive[] = "active"; 101 const char kMultiGpuCategoryStringActive[] = "active";
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 return kOsAndroid; 254 return kOsAndroid;
263 else if (os == "linux") 255 else if (os == "linux")
264 return kOsLinux; 256 return kOsLinux;
265 else if (os == "chromeos") 257 else if (os == "chromeos")
266 return kOsChromeOS; 258 return kOsChromeOS;
267 else if (os == "any") 259 else if (os == "any")
268 return kOsAny; 260 return kOsAny;
269 return kOsUnknown; 261 return kOsUnknown;
270 } 262 }
271 263
264 GpuControlList::StringInfo::StringInfo(const std::string& string_op,
265 const std::string& string_value) {
266 op_ = StringToOp(string_op);
267 value_ = base::StringToLowerASCII(string_value);
268 }
269
270 bool GpuControlList::StringInfo::Contains(const std::string& value) const {
271 std::string my_value = base::StringToLowerASCII(value);
272 switch (op_) {
273 case kContains:
274 return strstr(my_value.c_str(), value_.c_str()) != NULL;
275 case kBeginWith:
276 return StartsWithASCII(my_value, value_, false);
277 case kEndWith:
278 return EndsWith(my_value, value_, false);
279 case kEQ:
280 return value_ == my_value;
281 default:
282 return false;
283 }
284 }
285
286 bool GpuControlList::StringInfo::IsValid() const {
287 return op_ != kUnknown;
288 }
289
290 GpuControlList::StringInfo::Op GpuControlList::StringInfo::StringToOp(
291 const std::string& string_op) {
292 if (string_op == "=")
293 return kEQ;
294 else if (string_op == "contains")
295 return kContains;
296 else if (string_op == "beginwith")
297 return kBeginWith;
298 else if (string_op == "endwith")
299 return kEndWith;
300 return kUnknown;
301 }
302
272 GpuControlList::FloatInfo::FloatInfo(const std::string& float_op, 303 GpuControlList::FloatInfo::FloatInfo(const std::string& float_op,
273 const std::string& float_value, 304 const std::string& float_value,
274 const std::string& float_value2) 305 const std::string& float_value2)
275 : op_(kUnknown), 306 : op_(kUnknown),
276 value_(0.f), 307 value_(0.f),
277 value2_(0.f) { 308 value2_(0.f) {
278 op_ = StringToNumericOp(float_op); 309 op_ = StringToNumericOp(float_op);
279 if (op_ == kAny) 310 if (op_ == kAny)
280 return; 311 return;
281 double dvalue = 0; 312 double dvalue = 0;
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 513
483 std::string multi_gpu_category; 514 std::string multi_gpu_category;
484 if (value->GetString("multi_gpu_category", &multi_gpu_category)) { 515 if (value->GetString("multi_gpu_category", &multi_gpu_category)) {
485 if (!entry->SetMultiGpuCategory(multi_gpu_category)) { 516 if (!entry->SetMultiGpuCategory(multi_gpu_category)) {
486 LOG(WARNING) << "Malformed multi_gpu_category entry " << entry->id(); 517 LOG(WARNING) << "Malformed multi_gpu_category entry " << entry->id();
487 return NULL; 518 return NULL;
488 } 519 }
489 dictionary_entry_count++; 520 dictionary_entry_count++;
490 } 521 }
491 522
492 std::string driver_vendor_value; 523 const base::DictionaryValue* driver_vendor_value = NULL;
493 if (value->GetString("driver_vendor", &driver_vendor_value)) { 524 if (value->GetDictionary("driver_vendor", &driver_vendor_value)) {
494 if (!entry->SetDriverVendorInfo(driver_vendor_value)) { 525 std::string vendor_op;
526 std::string vendor_value;
527 driver_vendor_value->GetString(kOp, &vendor_op);
528 driver_vendor_value->GetString("value", &vendor_value);
529 if (!entry->SetDriverVendorInfo(vendor_op, vendor_value)) {
495 LOG(WARNING) << "Malformed driver_vendor entry " << entry->id(); 530 LOG(WARNING) << "Malformed driver_vendor entry " << entry->id();
496 return NULL; 531 return NULL;
497 } 532 }
498 dictionary_entry_count++; 533 dictionary_entry_count++;
499 } 534 }
500 535
501 const base::DictionaryValue* driver_version_value = NULL; 536 const base::DictionaryValue* driver_version_value = NULL;
502 if (value->GetDictionary("driver_version", &driver_version_value)) { 537 if (value->GetDictionary("driver_version", &driver_version_value)) {
503 std::string driver_version_op = "any"; 538 std::string driver_version_op = "any";
504 std::string driver_version_style; 539 std::string driver_version_style;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 gl_version_value->GetString("value", &version_string); 587 gl_version_value->GetString("value", &version_string);
553 gl_version_value->GetString("value2", &version_string2); 588 gl_version_value->GetString("value2", &version_string2);
554 if (!entry->SetGLVersionInfo( 589 if (!entry->SetGLVersionInfo(
555 version_op, version_string, version_string2)) { 590 version_op, version_string, version_string2)) {
556 LOG(WARNING) << "Malformed gl_version entry " << entry->id(); 591 LOG(WARNING) << "Malformed gl_version entry " << entry->id();
557 return NULL; 592 return NULL;
558 } 593 }
559 dictionary_entry_count++; 594 dictionary_entry_count++;
560 } 595 }
561 596
562 std::string gl_vendor_value; 597 const base::DictionaryValue* gl_vendor_value = NULL;
563 if (value->GetString("gl_vendor", &gl_vendor_value)) { 598 if (value->GetDictionary("gl_vendor", &gl_vendor_value)) {
564 if (!entry->SetGLVendorInfo(gl_vendor_value)) { 599 std::string vendor_op;
600 std::string vendor_value;
601 gl_vendor_value->GetString(kOp, &vendor_op);
602 gl_vendor_value->GetString("value", &vendor_value);
603 if (!entry->SetGLVendorInfo(vendor_op, vendor_value)) {
565 LOG(WARNING) << "Malformed gl_vendor entry " << entry->id(); 604 LOG(WARNING) << "Malformed gl_vendor entry " << entry->id();
566 return NULL; 605 return NULL;
567 } 606 }
568 dictionary_entry_count++; 607 dictionary_entry_count++;
569 } 608 }
570 609
571 std::string gl_renderer_value; 610 const base::DictionaryValue* gl_renderer_value = NULL;
572 if (value->GetString("gl_renderer", &gl_renderer_value)) { 611 if (value->GetDictionary("gl_renderer", &gl_renderer_value)) {
573 if (!entry->SetGLRendererInfo(gl_renderer_value)) { 612 std::string renderer_op;
613 std::string renderer_value;
614 gl_renderer_value->GetString(kOp, &renderer_op);
615 gl_renderer_value->GetString("value", &renderer_value);
616 if (!entry->SetGLRendererInfo(renderer_op, renderer_value)) {
574 LOG(WARNING) << "Malformed gl_renderer entry " << entry->id(); 617 LOG(WARNING) << "Malformed gl_renderer entry " << entry->id();
575 return NULL; 618 return NULL;
576 } 619 }
577 dictionary_entry_count++; 620 dictionary_entry_count++;
578 } 621 }
579 622
580 std::string gl_extensions_value; 623 const base::DictionaryValue* gl_extensions_value = NULL;
581 if (value->GetString("gl_extensions", &gl_extensions_value)) { 624 if (value->GetDictionary("gl_extensions", &gl_extensions_value)) {
582 if (!entry->SetGLExtensionsInfo(gl_extensions_value)) { 625 std::string extensions_op;
626 std::string extensions_value;
627 gl_extensions_value->GetString(kOp, &extensions_op);
628 gl_extensions_value->GetString("value", &extensions_value);
629 if (!entry->SetGLExtensionsInfo(extensions_op, extensions_value)) {
583 LOG(WARNING) << "Malformed gl_extensions entry " << entry->id(); 630 LOG(WARNING) << "Malformed gl_extensions entry " << entry->id();
584 return NULL; 631 return NULL;
585 } 632 }
586 dictionary_entry_count++; 633 dictionary_entry_count++;
587 } 634 }
588 635
589 const base::DictionaryValue* gl_reset_notification_strategy_value = NULL; 636 const base::DictionaryValue* gl_reset_notification_strategy_value = NULL;
590 if (value->GetDictionary("gl_reset_notification_strategy", 637 if (value->GetDictionary("gl_reset_notification_strategy",
591 &gl_reset_notification_strategy_value)) { 638 &gl_reset_notification_strategy_value)) {
592 std::string op; 639 std::string op;
593 std::string int_value; 640 std::string int_value;
594 std::string int_value2; 641 std::string int_value2;
595 gl_reset_notification_strategy_value->GetString(kOp, &op); 642 gl_reset_notification_strategy_value->GetString(kOp, &op);
596 gl_reset_notification_strategy_value->GetString("value", &int_value); 643 gl_reset_notification_strategy_value->GetString("value", &int_value);
597 gl_reset_notification_strategy_value->GetString("value2", &int_value2); 644 gl_reset_notification_strategy_value->GetString("value2", &int_value2);
598 if (!entry->SetGLResetNotificationStrategyInfo( 645 if (!entry->SetGLResetNotificationStrategyInfo(
599 op, int_value, int_value2)) { 646 op, int_value, int_value2)) {
600 LOG(WARNING) << "Malformed gl_reset_notification_strategy entry " 647 LOG(WARNING) << "Malformed gl_reset_notification_strategy entry "
601 << entry->id(); 648 << entry->id();
602 return NULL; 649 return NULL;
603 } 650 }
604 dictionary_entry_count++; 651 dictionary_entry_count++;
605 } 652 }
606 653
607 std::string cpu_brand_value; 654 const base::DictionaryValue* cpu_brand_value = NULL;
608 if (value->GetString("cpu_info", &cpu_brand_value)) { 655 if (value->GetDictionary("cpu_info", &cpu_brand_value)) {
609 if (!entry->SetCpuBrand(cpu_brand_value)) { 656 std::string cpu_op;
657 std::string cpu_value;
658 cpu_brand_value->GetString(kOp, &cpu_op);
659 cpu_brand_value->GetString("value", &cpu_value);
660 if (!entry->SetCpuBrand(cpu_op, cpu_value)) {
610 LOG(WARNING) << "Malformed cpu_brand entry " << entry->id(); 661 LOG(WARNING) << "Malformed cpu_brand entry " << entry->id();
611 return NULL; 662 return NULL;
612 } 663 }
613 dictionary_entry_count++; 664 dictionary_entry_count++;
614 } 665 }
615 666
616 const base::DictionaryValue* perf_graphics_value = NULL; 667 const base::DictionaryValue* perf_graphics_value = NULL;
617 if (value->GetDictionary("perf_graphics", &perf_graphics_value)) { 668 if (value->GetDictionary("perf_graphics", &perf_graphics_value)) {
618 std::string op; 669 std::string op;
619 std::string float_value; 670 std::string float_value;
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 bool GpuControlList::GpuControlListEntry::SetGLType( 891 bool GpuControlList::GpuControlListEntry::SetGLType(
841 const std::string& gl_type_string) { 892 const std::string& gl_type_string) {
842 GLType gl_type = StringToGLType(gl_type_string); 893 GLType gl_type = StringToGLType(gl_type_string);
843 if (gl_type == kGLTypeNone) 894 if (gl_type == kGLTypeNone)
844 return false; 895 return false;
845 gl_type_ = gl_type; 896 gl_type_ = gl_type;
846 return true; 897 return true;
847 } 898 }
848 899
849 bool GpuControlList::GpuControlListEntry::SetDriverVendorInfo( 900 bool GpuControlList::GpuControlListEntry::SetDriverVendorInfo(
901 const std::string& vendor_op,
850 const std::string& vendor_value) { 902 const std::string& vendor_value) {
851 driver_vendor_info_ = vendor_value; 903 driver_vendor_info_.reset(new StringInfo(vendor_op, vendor_value));
852 return !driver_vendor_info_.empty(); 904 return driver_vendor_info_->IsValid();
853 } 905 }
854 906
855 bool GpuControlList::GpuControlListEntry::SetDriverVersionInfo( 907 bool GpuControlList::GpuControlListEntry::SetDriverVersionInfo(
856 const std::string& version_op, 908 const std::string& version_op,
857 const std::string& version_style, 909 const std::string& version_style,
858 const std::string& version_string, 910 const std::string& version_string,
859 const std::string& version_string2) { 911 const std::string& version_string2) {
860 driver_version_info_.reset(new VersionInfo( 912 driver_version_info_.reset(new VersionInfo(
861 version_op, version_style, version_string, version_string2)); 913 version_op, version_style, version_string, version_string2));
862 return driver_version_info_->IsValid(); 914 return driver_version_info_->IsValid();
(...skipping 11 matching lines...) Expand all
874 bool GpuControlList::GpuControlListEntry::SetGLVersionInfo( 926 bool GpuControlList::GpuControlListEntry::SetGLVersionInfo(
875 const std::string& version_op, 927 const std::string& version_op,
876 const std::string& version_string, 928 const std::string& version_string,
877 const std::string& version_string2) { 929 const std::string& version_string2) {
878 gl_version_info_.reset(new VersionInfo( 930 gl_version_info_.reset(new VersionInfo(
879 version_op, std::string(), version_string, version_string2)); 931 version_op, std::string(), version_string, version_string2));
880 return gl_version_info_->IsValid(); 932 return gl_version_info_->IsValid();
881 } 933 }
882 934
883 bool GpuControlList::GpuControlListEntry::SetGLVendorInfo( 935 bool GpuControlList::GpuControlListEntry::SetGLVendorInfo(
936 const std::string& vendor_op,
884 const std::string& vendor_value) { 937 const std::string& vendor_value) {
885 gl_vendor_info_ = vendor_value; 938 gl_vendor_info_.reset(new StringInfo(vendor_op, vendor_value));
886 return !gl_vendor_info_.empty(); 939 return gl_vendor_info_->IsValid();
887 } 940 }
888 941
889 bool GpuControlList::GpuControlListEntry::SetGLRendererInfo( 942 bool GpuControlList::GpuControlListEntry::SetGLRendererInfo(
943 const std::string& renderer_op,
890 const std::string& renderer_value) { 944 const std::string& renderer_value) {
891 gl_renderer_info_ = renderer_value; 945 gl_renderer_info_.reset(new StringInfo(renderer_op, renderer_value));
892 return !gl_renderer_info_.empty(); 946 return gl_renderer_info_->IsValid();
893 } 947 }
894 948
895 bool GpuControlList::GpuControlListEntry::SetGLExtensionsInfo( 949 bool GpuControlList::GpuControlListEntry::SetGLExtensionsInfo(
950 const std::string& extensions_op,
896 const std::string& extensions_value) { 951 const std::string& extensions_value) {
897 gl_extensions_info_ = extensions_value; 952 gl_extensions_info_.reset(new StringInfo(extensions_op, extensions_value));
898 return !gl_extensions_info_.empty(); 953 return gl_extensions_info_->IsValid();
899 } 954 }
900 955
901 bool GpuControlList::GpuControlListEntry::SetGLResetNotificationStrategyInfo( 956 bool GpuControlList::GpuControlListEntry::SetGLResetNotificationStrategyInfo(
902 const std::string& op, 957 const std::string& op,
903 const std::string& int_string, 958 const std::string& int_string,
904 const std::string& int_string2) { 959 const std::string& int_string2) {
905 gl_reset_notification_strategy_info_.reset( 960 gl_reset_notification_strategy_info_.reset(
906 new IntInfo(op, int_string, int_string2)); 961 new IntInfo(op, int_string, int_string2));
907 return gl_reset_notification_strategy_info_->IsValid(); 962 return gl_reset_notification_strategy_info_->IsValid();
908 } 963 }
909 964
910 bool GpuControlList::GpuControlListEntry::SetCpuBrand( 965 bool GpuControlList::GpuControlListEntry::SetCpuBrand(
966 const std::string& cpu_op,
911 const std::string& cpu_value) { 967 const std::string& cpu_value) {
912 cpu_brand_ = cpu_value; 968 cpu_brand_.reset(new StringInfo(cpu_op, cpu_value));
913 return !cpu_brand_.empty(); 969 return cpu_brand_->IsValid();
914 } 970 }
915 971
916 bool GpuControlList::GpuControlListEntry::SetPerfGraphicsInfo( 972 bool GpuControlList::GpuControlListEntry::SetPerfGraphicsInfo(
917 const std::string& op, 973 const std::string& op,
918 const std::string& float_string, 974 const std::string& float_string,
919 const std::string& float_string2) { 975 const std::string& float_string2) {
920 perf_graphics_info_.reset(new FloatInfo(op, float_string, float_string2)); 976 perf_graphics_info_.reset(new FloatInfo(op, float_string, float_string2));
921 return perf_graphics_info_->IsValid(); 977 return perf_graphics_info_->IsValid();
922 } 978 }
923 979
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 if (!gpu_info.amd_switchable) 1229 if (!gpu_info.amd_switchable)
1174 return false; 1230 return false;
1175 // Assume the integrated GPU is the first in the secondary GPU list. 1231 // Assume the integrated GPU is the first in the secondary GPU list.
1176 if (gpu_info.secondary_gpus.size() == 0 || 1232 if (gpu_info.secondary_gpus.size() == 0 ||
1177 !gpu_info.secondary_gpus[0].active) 1233 !gpu_info.secondary_gpus[0].active)
1178 return false; 1234 return false;
1179 break; 1235 break;
1180 case kMultiGpuStyleNone: 1236 case kMultiGpuStyleNone:
1181 break; 1237 break;
1182 } 1238 }
1183 if (StringMismatch(gpu_info.driver_vendor, driver_vendor_info_)) 1239 if (driver_vendor_info_.get() != NULL && !gpu_info.driver_vendor.empty() &&
1240 !driver_vendor_info_->Contains(gpu_info.driver_vendor))
1184 return false; 1241 return false;
1185 if (driver_version_info_.get() != NULL && !gpu_info.driver_version.empty()) { 1242 if (driver_version_info_.get() != NULL && !gpu_info.driver_version.empty()) {
1186 if (!driver_version_info_->Contains(gpu_info.driver_version)) 1243 if (!driver_version_info_->Contains(gpu_info.driver_version))
1187 return false; 1244 return false;
1188 } 1245 }
1189 if (driver_date_info_.get() != NULL && !gpu_info.driver_date.empty()) { 1246 if (driver_date_info_.get() != NULL && !gpu_info.driver_date.empty()) {
1190 if (!driver_date_info_->Contains(gpu_info.driver_date, '-')) 1247 if (!driver_date_info_->Contains(gpu_info.driver_date, '-'))
1191 return false; 1248 return false;
1192 } 1249 }
1193 if (GLVersionInfoMismatch(gpu_info.gl_version)) 1250 if (GLVersionInfoMismatch(gpu_info.gl_version))
1194 return false; 1251 return false;
1195 if (StringMismatch(gpu_info.gl_vendor, gl_vendor_info_)) 1252 if (gl_vendor_info_.get() != NULL && !gpu_info.gl_vendor.empty() &&
1253 !gl_vendor_info_->Contains(gpu_info.gl_vendor))
1196 return false; 1254 return false;
1197 if (StringMismatch(gpu_info.gl_renderer, gl_renderer_info_)) 1255 if (gl_renderer_info_.get() != NULL && !gpu_info.gl_renderer.empty() &&
1256 !gl_renderer_info_->Contains(gpu_info.gl_renderer))
1198 return false; 1257 return false;
1199 if (StringMismatch(gpu_info.gl_extensions, gl_extensions_info_)) 1258 if (gl_extensions_info_.get() != NULL && !gpu_info.gl_extensions.empty() &&
1259 !gl_extensions_info_->Contains(gpu_info.gl_extensions))
1200 return false; 1260 return false;
1201 if (gl_reset_notification_strategy_info_.get() != NULL && 1261 if (gl_reset_notification_strategy_info_.get() != NULL &&
1202 !gl_reset_notification_strategy_info_->Contains( 1262 !gl_reset_notification_strategy_info_->Contains(
1203 gpu_info.gl_reset_notification_strategy)) 1263 gpu_info.gl_reset_notification_strategy))
1204 return false; 1264 return false;
1205 if (perf_graphics_info_.get() != NULL && 1265 if (perf_graphics_info_.get() != NULL &&
1206 (gpu_info.performance_stats.graphics == 0.0 || 1266 (gpu_info.performance_stats.graphics == 0.0 ||
1207 !perf_graphics_info_->Contains(gpu_info.performance_stats.graphics))) 1267 !perf_graphics_info_->Contains(gpu_info.performance_stats.graphics)))
1208 return false; 1268 return false;
1209 if (perf_gaming_info_.get() != NULL && 1269 if (perf_gaming_info_.get() != NULL &&
1210 (gpu_info.performance_stats.gaming == 0.0 || 1270 (gpu_info.performance_stats.gaming == 0.0 ||
1211 !perf_gaming_info_->Contains(gpu_info.performance_stats.gaming))) 1271 !perf_gaming_info_->Contains(gpu_info.performance_stats.gaming)))
1212 return false; 1272 return false;
1213 if (perf_overall_info_.get() != NULL && 1273 if (perf_overall_info_.get() != NULL &&
1214 (gpu_info.performance_stats.overall == 0.0 || 1274 (gpu_info.performance_stats.overall == 0.0 ||
1215 !perf_overall_info_->Contains(gpu_info.performance_stats.overall))) 1275 !perf_overall_info_->Contains(gpu_info.performance_stats.overall)))
1216 return false; 1276 return false;
1217 if (!machine_model_name_list_.empty()) { 1277 if (!machine_model_name_list_.empty()) {
1218 if (gpu_info.machine_model_name.empty()) 1278 if (gpu_info.machine_model_name.empty())
1219 return false; 1279 return false;
1220 bool found_match = false; 1280 bool found_match = false;
1221 for (size_t ii = 0; ii < machine_model_name_list_.size(); ++ii) { 1281 for (size_t ii = 0; ii < machine_model_name_list_.size(); ++ii) {
1222 if (RE2::FullMatch(gpu_info.machine_model_name, 1282 if (machine_model_name_list_[ii] == gpu_info.machine_model_name) {
1223 machine_model_name_list_[ii])) {
1224 found_match = true; 1283 found_match = true;
1225 break; 1284 break;
1226 } 1285 }
1227 } 1286 }
1228 if (!found_match) 1287 if (!found_match)
1229 return false; 1288 return false;
1230 } 1289 }
1231 if (machine_model_version_info_.get() != NULL && 1290 if (machine_model_version_info_.get() != NULL &&
1232 (gpu_info.machine_model_version.empty() || 1291 (gpu_info.machine_model_version.empty() ||
1233 !machine_model_version_info_->Contains(gpu_info.machine_model_version))) 1292 !machine_model_version_info_->Contains(gpu_info.machine_model_version)))
1234 return false; 1293 return false;
1235 if (gpu_count_info_.get() != NULL && 1294 if (gpu_count_info_.get() != NULL &&
1236 !gpu_count_info_->Contains(gpu_info.secondary_gpus.size() + 1)) 1295 !gpu_count_info_->Contains(gpu_info.secondary_gpus.size() + 1))
1237 return false; 1296 return false;
1238 if (direct_rendering_info_.get() != NULL && 1297 if (direct_rendering_info_.get() != NULL &&
1239 !direct_rendering_info_->Contains(gpu_info.direct_rendering)) 1298 !direct_rendering_info_->Contains(gpu_info.direct_rendering))
1240 return false; 1299 return false;
1241 if (!cpu_brand_.empty()) { 1300 if (cpu_brand_.get() != NULL) {
1242 base::CPU cpu_info; 1301 base::CPU cpu_info;
1243 if (StringMismatch(cpu_info.cpu_brand(), cpu_brand_)) 1302 if (!cpu_brand_->Contains(cpu_info.cpu_brand()))
1244 return false; 1303 return false;
1245 } 1304 }
1246 1305
1247 for (size_t i = 0; i < exceptions_.size(); ++i) { 1306 for (size_t i = 0; i < exceptions_.size(); ++i) {
1248 if (exceptions_[i]->Contains(os_type, os_version, gpu_info) && 1307 if (exceptions_[i]->Contains(os_type, os_version, gpu_info) &&
1249 !exceptions_[i]->NeedsMoreInfo(gpu_info)) 1308 !exceptions_[i]->NeedsMoreInfo(gpu_info))
1250 return false; 1309 return false;
1251 } 1310 }
1252 return true; 1311 return true;
1253 } 1312 }
1254 1313
1255 bool GpuControlList::GpuControlListEntry::NeedsMoreInfo( 1314 bool GpuControlList::GpuControlListEntry::NeedsMoreInfo(
1256 const GPUInfo& gpu_info) const { 1315 const GPUInfo& gpu_info) const {
1257 // We only check for missing info that might be collected with a gl context. 1316 // We only check for missing info that might be collected with a gl context.
1258 // If certain info is missing due to some error, say, we fail to collect 1317 // If certain info is missing due to some error, say, we fail to collect
1259 // vendor_id/device_id, then even if we launch GPU process and create a gl 1318 // vendor_id/device_id, then even if we launch GPU process and create a gl
1260 // context, we won't gather such missing info, so we still return false. 1319 // context, we won't gather such missing info, so we still return false.
1261 if (!driver_vendor_info_.empty() && gpu_info.driver_vendor.empty()) 1320 if (driver_vendor_info_.get() && gpu_info.driver_vendor.empty())
1262 return true; 1321 return true;
1263 if (driver_version_info_.get() && gpu_info.driver_version.empty()) 1322 if (driver_version_info_.get() && gpu_info.driver_version.empty())
1264 return true; 1323 return true;
1265 if (!gl_vendor_info_.empty() && gpu_info.gl_vendor.empty()) 1324 if (gl_vendor_info_.get() && gpu_info.gl_vendor.empty())
1266 return true; 1325 return true;
1267 if (!gl_renderer_info_.empty() && gpu_info.gl_renderer.empty()) 1326 if (gl_renderer_info_.get() && gpu_info.gl_renderer.empty())
1268 return true; 1327 return true;
1269 for (size_t i = 0; i < exceptions_.size(); ++i) { 1328 for (size_t i = 0; i < exceptions_.size(); ++i) {
1270 if (exceptions_[i]->NeedsMoreInfo(gpu_info)) 1329 if (exceptions_[i]->NeedsMoreInfo(gpu_info))
1271 return true; 1330 return true;
1272 } 1331 }
1273 return false; 1332 return false;
1274 } 1333 }
1275 1334
1276 GpuControlList::OsType GpuControlList::GpuControlListEntry::GetOsType() const { 1335 GpuControlList::OsType GpuControlList::GpuControlListEntry::GetOsType() const {
1277 if (os_info_.get() == NULL) 1336 if (os_info_.get() == NULL)
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1519 const std::string& feature_name, int feature_id) { 1578 const std::string& feature_name, int feature_id) {
1520 feature_map_[feature_name] = feature_id; 1579 feature_map_[feature_name] = feature_id;
1521 } 1580 }
1522 1581
1523 void GpuControlList::set_supports_feature_type_all(bool supported) { 1582 void GpuControlList::set_supports_feature_type_all(bool supported) {
1524 supports_feature_type_all_ = supported; 1583 supports_feature_type_all_ = supported;
1525 } 1584 }
1526 1585
1527 } // namespace gpu 1586 } // namespace gpu
1528 1587
OLDNEW
« no previous file with comments | « trunk/src/gpu/config/gpu_control_list.h ('k') | trunk/src/gpu/config/gpu_control_list_entry_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698