OLD | NEW |
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" |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 return (value >= value_); | 407 return (value >= value_); |
408 DCHECK(op_ == kBetween); | 408 DCHECK(op_ == kBetween); |
409 return ((value_ <= value && value <= value2_) || | 409 return ((value_ <= value && value <= value2_) || |
410 (value2_ <= value && value <= value_)); | 410 (value2_ <= value && value <= value_)); |
411 } | 411 } |
412 | 412 |
413 bool GpuControlList::IntInfo::IsValid() const { | 413 bool GpuControlList::IntInfo::IsValid() const { |
414 return op_ != kUnknown; | 414 return op_ != kUnknown; |
415 } | 415 } |
416 | 416 |
| 417 GpuControlList::BoolInfo::BoolInfo(const std::string& bool_value) |
| 418 : valid_(false), |
| 419 value_(false) { |
| 420 if (bool_value == "true") { |
| 421 valid_ = true; |
| 422 value_ = true; |
| 423 } else if (bool_value == "false") { |
| 424 valid_ = true; |
| 425 value_ = false; |
| 426 } |
| 427 } |
| 428 |
| 429 bool GpuControlList::BoolInfo::Contains(bool value) const { |
| 430 if (!valid_) |
| 431 return false; |
| 432 return value_ == value; |
| 433 } |
| 434 |
| 435 bool GpuControlList::BoolInfo::IsValid() const { |
| 436 return valid_; |
| 437 } |
| 438 |
417 // static | 439 // static |
418 GpuControlList::ScopedGpuControlListEntry | 440 GpuControlList::ScopedGpuControlListEntry |
419 GpuControlList::GpuControlListEntry::GetEntryFromValue( | 441 GpuControlList::GpuControlListEntry::GetEntryFromValue( |
420 const base::DictionaryValue* value, bool top_level, | 442 const base::DictionaryValue* value, bool top_level, |
421 const FeatureMap& feature_map, | 443 const FeatureMap& feature_map, |
422 bool supports_feature_type_all) { | 444 bool supports_feature_type_all) { |
423 DCHECK(value); | 445 DCHECK(value); |
424 ScopedGpuControlListEntry entry(new GpuControlListEntry()); | 446 ScopedGpuControlListEntry entry(new GpuControlListEntry()); |
425 | 447 |
426 size_t dictionary_entry_count = 0; | 448 size_t dictionary_entry_count = 0; |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 gpu_count_value->GetString(kOp, &op); | 759 gpu_count_value->GetString(kOp, &op); |
738 gpu_count_value->GetString("value", &int_value); | 760 gpu_count_value->GetString("value", &int_value); |
739 gpu_count_value->GetString("value2", &int_value2); | 761 gpu_count_value->GetString("value2", &int_value2); |
740 if (!entry->SetGpuCountInfo(op, int_value, int_value2)) { | 762 if (!entry->SetGpuCountInfo(op, int_value, int_value2)) { |
741 LOG(WARNING) << "Malformed gpu_count entry " << entry->id(); | 763 LOG(WARNING) << "Malformed gpu_count entry " << entry->id(); |
742 return NULL; | 764 return NULL; |
743 } | 765 } |
744 dictionary_entry_count++; | 766 dictionary_entry_count++; |
745 } | 767 } |
746 | 768 |
| 769 std::string direct_rendering_string; |
| 770 if (value->GetString("direct_rendering", &direct_rendering_string)) { |
| 771 if (!entry->SetDirectRenderingInfo(direct_rendering_string)) { |
| 772 LOG(WARNING) << "Malformed direct_rendering entry " << entry->id(); |
| 773 return NULL; |
| 774 } |
| 775 dictionary_entry_count++; |
| 776 } |
| 777 |
747 if (top_level) { | 778 if (top_level) { |
748 const base::ListValue* feature_value = NULL; | 779 const base::ListValue* feature_value = NULL; |
749 if (value->GetList("features", &feature_value)) { | 780 if (value->GetList("features", &feature_value)) { |
750 std::vector<std::string> feature_list; | 781 std::vector<std::string> feature_list; |
751 for (size_t i = 0; i < feature_value->GetSize(); ++i) { | 782 for (size_t i = 0; i < feature_value->GetSize(); ++i) { |
752 std::string feature; | 783 std::string feature; |
753 if (feature_value->GetString(i, &feature)) { | 784 if (feature_value->GetString(i, &feature)) { |
754 feature_list.push_back(feature); | 785 feature_list.push_back(feature); |
755 } else { | 786 } else { |
756 LOG(WARNING) << "Malformed feature entry " << entry->id(); | 787 LOG(WARNING) << "Malformed feature entry " << entry->id(); |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 } | 994 } |
964 | 995 |
965 bool GpuControlList::GpuControlListEntry::SetGpuCountInfo( | 996 bool GpuControlList::GpuControlListEntry::SetGpuCountInfo( |
966 const std::string& op, | 997 const std::string& op, |
967 const std::string& int_string, | 998 const std::string& int_string, |
968 const std::string& int_string2) { | 999 const std::string& int_string2) { |
969 gpu_count_info_.reset(new IntInfo(op, int_string, int_string2)); | 1000 gpu_count_info_.reset(new IntInfo(op, int_string, int_string2)); |
970 return gpu_count_info_->IsValid(); | 1001 return gpu_count_info_->IsValid(); |
971 } | 1002 } |
972 | 1003 |
| 1004 bool GpuControlList::GpuControlListEntry::SetDirectRenderingInfo( |
| 1005 const std::string& value) { |
| 1006 direct_rendering_info_.reset(new BoolInfo(value)); |
| 1007 return direct_rendering_info_->IsValid(); |
| 1008 } |
| 1009 |
973 bool GpuControlList::GpuControlListEntry::SetFeatures( | 1010 bool GpuControlList::GpuControlListEntry::SetFeatures( |
974 const std::vector<std::string>& feature_strings, | 1011 const std::vector<std::string>& feature_strings, |
975 const FeatureMap& feature_map, | 1012 const FeatureMap& feature_map, |
976 bool supports_feature_type_all) { | 1013 bool supports_feature_type_all) { |
977 size_t size = feature_strings.size(); | 1014 size_t size = feature_strings.size(); |
978 if (size == 0) | 1015 if (size == 0) |
979 return false; | 1016 return false; |
980 features_.clear(); | 1017 features_.clear(); |
981 for (size_t i = 0; i < size; ++i) { | 1018 for (size_t i = 0; i < size; ++i) { |
982 int feature = 0; | 1019 int feature = 0; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 if (machine_model_info_.get() != NULL) { | 1149 if (machine_model_info_.get() != NULL) { |
1113 std::vector<std::string> name_version; | 1150 std::vector<std::string> name_version; |
1114 base::SplitString(gpu_info.machine_model, ' ', &name_version); | 1151 base::SplitString(gpu_info.machine_model, ' ', &name_version); |
1115 if (name_version.size() == 2 && | 1152 if (name_version.size() == 2 && |
1116 !machine_model_info_->Contains(name_version[0], name_version[1])) | 1153 !machine_model_info_->Contains(name_version[0], name_version[1])) |
1117 return false; | 1154 return false; |
1118 } | 1155 } |
1119 if (gpu_count_info_.get() != NULL && | 1156 if (gpu_count_info_.get() != NULL && |
1120 !gpu_count_info_->Contains(gpu_info.secondary_gpus.size() + 1)) | 1157 !gpu_count_info_->Contains(gpu_info.secondary_gpus.size() + 1)) |
1121 return false; | 1158 return false; |
| 1159 if (direct_rendering_info_.get() != NULL && |
| 1160 !direct_rendering_info_->Contains(gpu_info.direct_rendering)) |
| 1161 return false; |
1122 if (cpu_brand_.get() != NULL) { | 1162 if (cpu_brand_.get() != NULL) { |
1123 base::CPU cpu_info; | 1163 base::CPU cpu_info; |
1124 if (!cpu_brand_->Contains(cpu_info.cpu_brand())) | 1164 if (!cpu_brand_->Contains(cpu_info.cpu_brand())) |
1125 return false; | 1165 return false; |
1126 } | 1166 } |
1127 | 1167 |
1128 for (size_t i = 0; i < exceptions_.size(); ++i) { | 1168 for (size_t i = 0; i < exceptions_.size(); ++i) { |
1129 if (exceptions_[i]->Contains(os_type, os_version, gpu_info) && | 1169 if (exceptions_[i]->Contains(os_type, os_version, gpu_info) && |
1130 !exceptions_[i]->NeedsMoreInfo(gpu_info)) | 1170 !exceptions_[i]->NeedsMoreInfo(gpu_info)) |
1131 return false; | 1171 return false; |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1407 const std::string& feature_name, int feature_id) { | 1447 const std::string& feature_name, int feature_id) { |
1408 feature_map_[feature_name] = feature_id; | 1448 feature_map_[feature_name] = feature_id; |
1409 } | 1449 } |
1410 | 1450 |
1411 void GpuControlList::set_supports_feature_type_all(bool supported) { | 1451 void GpuControlList::set_supports_feature_type_all(bool supported) { |
1412 supports_feature_type_all_ = supported; | 1452 supports_feature_type_all_ = supported; |
1413 } | 1453 } |
1414 | 1454 |
1415 } // namespace gpu | 1455 } // namespace gpu |
1416 | 1456 |
OLD | NEW |