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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 | 451 |
452 std::string vendor_id; | 452 std::string vendor_id; |
453 if (value->GetString("vendor_id", &vendor_id)) { | 453 if (value->GetString("vendor_id", &vendor_id)) { |
454 if (!entry->SetVendorId(vendor_id)) { | 454 if (!entry->SetVendorId(vendor_id)) { |
455 LOG(WARNING) << "Malformed vendor_id entry " << entry->id(); | 455 LOG(WARNING) << "Malformed vendor_id entry " << entry->id(); |
456 return NULL; | 456 return NULL; |
457 } | 457 } |
458 dictionary_entry_count++; | 458 dictionary_entry_count++; |
459 } | 459 } |
460 | 460 |
| 461 std::string vendor_string; |
| 462 if (value->GetString("vendor_string", &vendor_string)) { |
| 463 entry->SetVendorString(vendor_string); |
| 464 dictionary_entry_count++; |
| 465 } |
| 466 std::string device_string; |
| 467 if (value->GetString("device_string", &device_string)) { |
| 468 entry->SetDeviceString(device_string); |
| 469 dictionary_entry_count++; |
| 470 } |
| 471 |
461 const base::ListValue* device_id_list; | 472 const base::ListValue* device_id_list; |
462 if (value->GetList("device_id", &device_id_list)) { | 473 if (value->GetList("device_id", &device_id_list)) { |
463 for (size_t i = 0; i < device_id_list->GetSize(); ++i) { | 474 for (size_t i = 0; i < device_id_list->GetSize(); ++i) { |
464 std::string device_id; | 475 std::string device_id; |
465 if (!device_id_list->GetString(i, &device_id) || | 476 if (!device_id_list->GetString(i, &device_id) || |
466 !entry->AddDeviceId(device_id)) { | 477 !entry->AddDeviceId(device_id)) { |
467 LOG(WARNING) << "Malformed device_id entry " << entry->id(); | 478 LOG(WARNING) << "Malformed device_id entry " << entry->id(); |
468 return NULL; | 479 return NULL; |
469 } | 480 } |
470 } | 481 } |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 return os_info_->IsValid(); | 812 return os_info_->IsValid(); |
802 } | 813 } |
803 | 814 |
804 bool GpuControlList::GpuControlListEntry::SetVendorId( | 815 bool GpuControlList::GpuControlListEntry::SetVendorId( |
805 const std::string& vendor_id_string) { | 816 const std::string& vendor_id_string) { |
806 vendor_id_ = 0; | 817 vendor_id_ = 0; |
807 return base::HexStringToUInt(vendor_id_string, &vendor_id_) && | 818 return base::HexStringToUInt(vendor_id_string, &vendor_id_) && |
808 vendor_id_ != 0; | 819 vendor_id_ != 0; |
809 } | 820 } |
810 | 821 |
| 822 void GpuControlList::GpuControlListEntry::SetVendorString( |
| 823 const std::string& vendor_string) { |
| 824 vendor_string_ = vendor_string; |
| 825 } |
| 826 |
811 bool GpuControlList::GpuControlListEntry::AddDeviceId( | 827 bool GpuControlList::GpuControlListEntry::AddDeviceId( |
812 const std::string& device_id_string) { | 828 const std::string& device_id_string) { |
813 uint32 device_id = 0; | 829 uint32 device_id = 0; |
814 if (base::HexStringToUInt(device_id_string, &device_id) && device_id != 0) { | 830 if (base::HexStringToUInt(device_id_string, &device_id) && device_id != 0) { |
815 device_id_list_.push_back(device_id); | 831 device_id_list_.push_back(device_id); |
816 return true; | 832 return true; |
817 } | 833 } |
818 return false; | 834 return false; |
819 } | 835 } |
820 | 836 |
| 837 void GpuControlList::GpuControlListEntry::SetDeviceString( |
| 838 const std::string& device_string) { |
| 839 device_string_ = device_string; |
| 840 } |
| 841 |
821 bool GpuControlList::GpuControlListEntry::SetMultiGpuStyle( | 842 bool GpuControlList::GpuControlListEntry::SetMultiGpuStyle( |
822 const std::string& multi_gpu_style_string) { | 843 const std::string& multi_gpu_style_string) { |
823 MultiGpuStyle style = StringToMultiGpuStyle(multi_gpu_style_string); | 844 MultiGpuStyle style = StringToMultiGpuStyle(multi_gpu_style_string); |
824 if (style == kMultiGpuStyleNone) | 845 if (style == kMultiGpuStyleNone) |
825 return false; | 846 return false; |
826 multi_gpu_style_ = style; | 847 multi_gpu_style_ = style; |
827 return true; | 848 return true; |
828 } | 849 } |
829 | 850 |
830 bool GpuControlList::GpuControlListEntry::SetMultiGpuCategory( | 851 bool GpuControlList::GpuControlListEntry::SetMultiGpuCategory( |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 if (!gpu_info.amd_switchable) | 1196 if (!gpu_info.amd_switchable) |
1176 return false; | 1197 return false; |
1177 // Assume the integrated GPU is the first in the secondary GPU list. | 1198 // Assume the integrated GPU is the first in the secondary GPU list. |
1178 if (gpu_info.secondary_gpus.size() == 0 || | 1199 if (gpu_info.secondary_gpus.size() == 0 || |
1179 !gpu_info.secondary_gpus[0].active) | 1200 !gpu_info.secondary_gpus[0].active) |
1180 return false; | 1201 return false; |
1181 break; | 1202 break; |
1182 case kMultiGpuStyleNone: | 1203 case kMultiGpuStyleNone: |
1183 break; | 1204 break; |
1184 } | 1205 } |
| 1206 if (StringMismatch(gpu_info.gpu.vendor_string, vendor_string_)) |
| 1207 return false; |
| 1208 if (StringMismatch(gpu_info.gpu.device_string, device_string_)) |
| 1209 return false; |
1185 if (StringMismatch(gpu_info.driver_vendor, driver_vendor_info_)) | 1210 if (StringMismatch(gpu_info.driver_vendor, driver_vendor_info_)) |
1186 return false; | 1211 return false; |
1187 if (driver_version_info_.get() != NULL && !gpu_info.driver_version.empty()) { | 1212 if (driver_version_info_.get() != NULL && !gpu_info.driver_version.empty()) { |
1188 if (!driver_version_info_->Contains(gpu_info.driver_version)) | 1213 if (!driver_version_info_->Contains(gpu_info.driver_version)) |
1189 return false; | 1214 return false; |
1190 } | 1215 } |
1191 if (driver_date_info_.get() != NULL && !gpu_info.driver_date.empty()) { | 1216 if (driver_date_info_.get() != NULL && !gpu_info.driver_date.empty()) { |
1192 if (!driver_date_info_->Contains(gpu_info.driver_date, '-')) | 1217 if (!driver_date_info_->Contains(gpu_info.driver_date, '-')) |
1193 return false; | 1218 return false; |
1194 } | 1219 } |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1510 void GpuControlList::AddSupportedFeature( | 1535 void GpuControlList::AddSupportedFeature( |
1511 const std::string& feature_name, int feature_id) { | 1536 const std::string& feature_name, int feature_id) { |
1512 feature_map_[feature_name] = feature_id; | 1537 feature_map_[feature_name] = feature_id; |
1513 } | 1538 } |
1514 | 1539 |
1515 void GpuControlList::set_supports_feature_type_all(bool supported) { | 1540 void GpuControlList::set_supports_feature_type_all(bool supported) { |
1516 supports_feature_type_all_ = supported; | 1541 supports_feature_type_all_ = supported; |
1517 } | 1542 } |
1518 | 1543 |
1519 } // namespace gpu | 1544 } // namespace gpu |
1520 | |
OLD | NEW |