| 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 <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
| 7 #include "base/cpu.h" | 10 #include "base/cpu.h" |
| 8 #include "base/json/json_reader.h" | 11 #include "base/json/json_reader.h" |
| 9 #include "base/logging.h" | 12 #include "base/logging.h" |
| 10 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
| 12 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 13 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 14 #include "base/sys_info.h" | 17 #include "base/sys_info.h" |
| 15 #include "gpu/config/gpu_info.h" | 18 #include "gpu/config/gpu_info.h" |
| 16 #include "gpu/config/gpu_util.h" | 19 #include "gpu/config/gpu_util.h" |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 GpuControlList::GpuControlListEntry::GetEntryFromValue( | 375 GpuControlList::GpuControlListEntry::GetEntryFromValue( |
| 373 const base::DictionaryValue* value, bool top_level, | 376 const base::DictionaryValue* value, bool top_level, |
| 374 const FeatureMap& feature_map, | 377 const FeatureMap& feature_map, |
| 375 bool supports_feature_type_all) { | 378 bool supports_feature_type_all) { |
| 376 DCHECK(value); | 379 DCHECK(value); |
| 377 ScopedGpuControlListEntry entry(new GpuControlListEntry()); | 380 ScopedGpuControlListEntry entry(new GpuControlListEntry()); |
| 378 | 381 |
| 379 size_t dictionary_entry_count = 0; | 382 size_t dictionary_entry_count = 0; |
| 380 | 383 |
| 381 if (top_level) { | 384 if (top_level) { |
| 382 uint32 id; | 385 uint32_t id; |
| 383 if (!value->GetInteger("id", reinterpret_cast<int*>(&id)) || | 386 if (!value->GetInteger("id", reinterpret_cast<int*>(&id)) || |
| 384 !entry->SetId(id)) { | 387 !entry->SetId(id)) { |
| 385 LOG(WARNING) << "Malformed id entry " << entry->id(); | 388 LOG(WARNING) << "Malformed id entry " << entry->id(); |
| 386 return NULL; | 389 return NULL; |
| 387 } | 390 } |
| 388 dictionary_entry_count++; | 391 dictionary_entry_count++; |
| 389 | 392 |
| 390 bool disabled; | 393 bool disabled; |
| 391 if (value->GetBoolean("disabled", &disabled)) { | 394 if (value->GetBoolean("disabled", &disabled)) { |
| 392 entry->SetDisabled(disabled); | 395 entry->SetDisabled(disabled); |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 : id_(0), | 798 : id_(0), |
| 796 disabled_(false), | 799 disabled_(false), |
| 797 vendor_id_(0), | 800 vendor_id_(0), |
| 798 multi_gpu_style_(kMultiGpuStyleNone), | 801 multi_gpu_style_(kMultiGpuStyleNone), |
| 799 multi_gpu_category_(kMultiGpuCategoryActive), | 802 multi_gpu_category_(kMultiGpuCategoryActive), |
| 800 gl_type_(kGLTypeNone) { | 803 gl_type_(kGLTypeNone) { |
| 801 } | 804 } |
| 802 | 805 |
| 803 GpuControlList::GpuControlListEntry::~GpuControlListEntry() { } | 806 GpuControlList::GpuControlListEntry::~GpuControlListEntry() { } |
| 804 | 807 |
| 805 bool GpuControlList::GpuControlListEntry::SetId(uint32 id) { | 808 bool GpuControlList::GpuControlListEntry::SetId(uint32_t id) { |
| 806 if (id != 0) { | 809 if (id != 0) { |
| 807 id_ = id; | 810 id_ = id; |
| 808 return true; | 811 return true; |
| 809 } | 812 } |
| 810 return false; | 813 return false; |
| 811 } | 814 } |
| 812 | 815 |
| 813 void GpuControlList::GpuControlListEntry::SetDisabled(bool disabled) { | 816 void GpuControlList::GpuControlListEntry::SetDisabled(bool disabled) { |
| 814 disabled_ = disabled; | 817 disabled_ = disabled; |
| 815 } | 818 } |
| 816 | 819 |
| 817 bool GpuControlList::GpuControlListEntry::SetOsInfo( | 820 bool GpuControlList::GpuControlListEntry::SetOsInfo( |
| 818 const std::string& os, | 821 const std::string& os, |
| 819 const std::string& version_op, | 822 const std::string& version_op, |
| 820 const std::string& version_string, | 823 const std::string& version_string, |
| 821 const std::string& version_string2) { | 824 const std::string& version_string2) { |
| 822 os_info_.reset(new OsInfo(os, version_op, version_string, version_string2)); | 825 os_info_.reset(new OsInfo(os, version_op, version_string, version_string2)); |
| 823 return os_info_->IsValid(); | 826 return os_info_->IsValid(); |
| 824 } | 827 } |
| 825 | 828 |
| 826 bool GpuControlList::GpuControlListEntry::SetVendorId( | 829 bool GpuControlList::GpuControlListEntry::SetVendorId( |
| 827 const std::string& vendor_id_string) { | 830 const std::string& vendor_id_string) { |
| 828 vendor_id_ = 0; | 831 vendor_id_ = 0; |
| 829 return base::HexStringToUInt(vendor_id_string, &vendor_id_) && | 832 return base::HexStringToUInt(vendor_id_string, &vendor_id_) && |
| 830 vendor_id_ != 0; | 833 vendor_id_ != 0; |
| 831 } | 834 } |
| 832 | 835 |
| 833 bool GpuControlList::GpuControlListEntry::AddDeviceId( | 836 bool GpuControlList::GpuControlListEntry::AddDeviceId( |
| 834 const std::string& device_id_string) { | 837 const std::string& device_id_string) { |
| 835 uint32 device_id = 0; | 838 uint32_t device_id = 0; |
| 836 if (base::HexStringToUInt(device_id_string, &device_id) && device_id != 0) { | 839 if (base::HexStringToUInt(device_id_string, &device_id) && device_id != 0) { |
| 837 device_id_list_.push_back(device_id); | 840 device_id_list_.push_back(device_id); |
| 838 return true; | 841 return true; |
| 839 } | 842 } |
| 840 return false; | 843 return false; |
| 841 } | 844 } |
| 842 | 845 |
| 843 bool GpuControlList::GpuControlListEntry::SetMultiGpuStyle( | 846 bool GpuControlList::GpuControlListEntry::SetMultiGpuStyle( |
| 844 const std::string& multi_gpu_style_string) { | 847 const std::string& multi_gpu_style_string) { |
| 845 MultiGpuStyle style = StringToMultiGpuStyle(multi_gpu_style_string); | 848 MultiGpuStyle style = StringToMultiGpuStyle(multi_gpu_style_string); |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1297 | 1300 |
| 1298 return false; | 1301 return false; |
| 1299 } | 1302 } |
| 1300 | 1303 |
| 1301 GpuControlList::OsType GpuControlList::GpuControlListEntry::GetOsType() const { | 1304 GpuControlList::OsType GpuControlList::GpuControlListEntry::GetOsType() const { |
| 1302 if (os_info_.get() == NULL) | 1305 if (os_info_.get() == NULL) |
| 1303 return kOsAny; | 1306 return kOsAny; |
| 1304 return os_info_->type(); | 1307 return os_info_->type(); |
| 1305 } | 1308 } |
| 1306 | 1309 |
| 1307 uint32 GpuControlList::GpuControlListEntry::id() const { | 1310 uint32_t GpuControlList::GpuControlListEntry::id() const { |
| 1308 return id_; | 1311 return id_; |
| 1309 } | 1312 } |
| 1310 | 1313 |
| 1311 bool GpuControlList::GpuControlListEntry::disabled() const { | 1314 bool GpuControlList::GpuControlListEntry::disabled() const { |
| 1312 return disabled_; | 1315 return disabled_; |
| 1313 } | 1316 } |
| 1314 | 1317 |
| 1315 const std::set<int>& GpuControlList::GpuControlListEntry::features() const { | 1318 const std::set<int>& GpuControlList::GpuControlListEntry::features() const { |
| 1316 return features_; | 1319 return features_; |
| 1317 } | 1320 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1374 | 1377 |
| 1375 parsed_json.GetString("version", &version_); | 1378 parsed_json.GetString("version", &version_); |
| 1376 std::vector<std::string> pieces; | 1379 std::vector<std::string> pieces; |
| 1377 if (!ProcessVersionString(version_, '.', &pieces)) | 1380 if (!ProcessVersionString(version_, '.', &pieces)) |
| 1378 return false; | 1381 return false; |
| 1379 | 1382 |
| 1380 const base::ListValue* list = NULL; | 1383 const base::ListValue* list = NULL; |
| 1381 if (!parsed_json.GetList("entries", &list)) | 1384 if (!parsed_json.GetList("entries", &list)) |
| 1382 return false; | 1385 return false; |
| 1383 | 1386 |
| 1384 uint32 max_entry_id = 0; | 1387 uint32_t max_entry_id = 0; |
| 1385 for (size_t i = 0; i < list->GetSize(); ++i) { | 1388 for (size_t i = 0; i < list->GetSize(); ++i) { |
| 1386 const base::DictionaryValue* list_item = NULL; | 1389 const base::DictionaryValue* list_item = NULL; |
| 1387 bool valid = list->GetDictionary(i, &list_item); | 1390 bool valid = list->GetDictionary(i, &list_item); |
| 1388 if (!valid || list_item == NULL) | 1391 if (!valid || list_item == NULL) |
| 1389 return false; | 1392 return false; |
| 1390 ScopedGpuControlListEntry entry(GpuControlListEntry::GetEntryFromValue( | 1393 ScopedGpuControlListEntry entry(GpuControlListEntry::GetEntryFromValue( |
| 1391 list_item, true, feature_map_, supports_feature_type_all_)); | 1394 list_item, true, feature_map_, supports_feature_type_all_)); |
| 1392 if (entry.get() == NULL) | 1395 if (entry.get() == NULL) |
| 1393 return false; | 1396 return false; |
| 1394 if (entry->id() > max_entry_id) | 1397 if (entry->id() > max_entry_id) |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1457 if (!needs_more_info_main) | 1460 if (!needs_more_info_main) |
| 1458 active_entries_.push_back(entry); | 1461 active_entries_.push_back(entry); |
| 1459 } | 1462 } |
| 1460 } | 1463 } |
| 1461 | 1464 |
| 1462 needs_more_info_ = permanent_features.size() < features.size() || | 1465 needs_more_info_ = permanent_features.size() < features.size() || |
| 1463 !potential_features.empty(); | 1466 !potential_features.empty(); |
| 1464 return features; | 1467 return features; |
| 1465 } | 1468 } |
| 1466 | 1469 |
| 1467 void GpuControlList::GetDecisionEntries( | 1470 void GpuControlList::GetDecisionEntries(std::vector<uint32_t>* entry_ids, |
| 1468 std::vector<uint32>* entry_ids, bool disabled) const { | 1471 bool disabled) const { |
| 1469 DCHECK(entry_ids); | 1472 DCHECK(entry_ids); |
| 1470 entry_ids->clear(); | 1473 entry_ids->clear(); |
| 1471 for (size_t i = 0; i < active_entries_.size(); ++i) { | 1474 for (size_t i = 0; i < active_entries_.size(); ++i) { |
| 1472 if (disabled == active_entries_[i]->disabled()) | 1475 if (disabled == active_entries_[i]->disabled()) |
| 1473 entry_ids->push_back(active_entries_[i]->id()); | 1476 entry_ids->push_back(active_entries_[i]->id()); |
| 1474 } | 1477 } |
| 1475 } | 1478 } |
| 1476 | 1479 |
| 1477 std::vector<std::string> GpuControlList::GetDisabledExtensions() { | 1480 std::vector<std::string> GpuControlList::GetDisabledExtensions() { |
| 1478 std::set<std::string> disabled_extensions; | 1481 std::set<std::string> disabled_extensions; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1519 problem->SetString("tag", tag); | 1522 problem->SetString("tag", tag); |
| 1520 | 1523 |
| 1521 problem_list->Append(problem); | 1524 problem_list->Append(problem); |
| 1522 } | 1525 } |
| 1523 } | 1526 } |
| 1524 | 1527 |
| 1525 size_t GpuControlList::num_entries() const { | 1528 size_t GpuControlList::num_entries() const { |
| 1526 return entries_.size(); | 1529 return entries_.size(); |
| 1527 } | 1530 } |
| 1528 | 1531 |
| 1529 uint32 GpuControlList::max_entry_id() const { | 1532 uint32_t GpuControlList::max_entry_id() const { |
| 1530 return max_entry_id_; | 1533 return max_entry_id_; |
| 1531 } | 1534 } |
| 1532 | 1535 |
| 1533 std::string GpuControlList::version() const { | 1536 std::string GpuControlList::version() const { |
| 1534 return version_; | 1537 return version_; |
| 1535 } | 1538 } |
| 1536 | 1539 |
| 1537 GpuControlList::OsType GpuControlList::GetOsType() { | 1540 GpuControlList::OsType GpuControlList::GetOsType() { |
| 1538 #if defined(OS_CHROMEOS) | 1541 #if defined(OS_CHROMEOS) |
| 1539 return kOsChromeOS; | 1542 return kOsChromeOS; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1580 const std::string& feature_name, int feature_id) { | 1583 const std::string& feature_name, int feature_id) { |
| 1581 feature_map_[feature_name] = feature_id; | 1584 feature_map_[feature_name] = feature_id; |
| 1582 } | 1585 } |
| 1583 | 1586 |
| 1584 void GpuControlList::set_supports_feature_type_all(bool supported) { | 1587 void GpuControlList::set_supports_feature_type_all(bool supported) { |
| 1585 supports_feature_type_all_ = supported; | 1588 supports_feature_type_all_ = supported; |
| 1586 } | 1589 } |
| 1587 | 1590 |
| 1588 } // namespace gpu | 1591 } // namespace gpu |
| 1589 | 1592 |
| OLD | NEW |