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> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/cpu.h" | 10 #include "base/cpu.h" |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 bool in_process_gpu; | 731 bool in_process_gpu; |
732 if (value->GetBoolean("in_process_gpu", &in_process_gpu)) { | 732 if (value->GetBoolean("in_process_gpu", &in_process_gpu)) { |
733 entry->SetInProcessGPUInfo(in_process_gpu); | 733 entry->SetInProcessGPUInfo(in_process_gpu); |
734 dictionary_entry_count++; | 734 dictionary_entry_count++; |
735 } | 735 } |
736 | 736 |
737 if (top_level) { | 737 if (top_level) { |
738 const base::ListValue* feature_value = NULL; | 738 const base::ListValue* feature_value = NULL; |
739 if (value->GetList("features", &feature_value)) { | 739 if (value->GetList("features", &feature_value)) { |
740 std::vector<std::string> feature_list; | 740 std::vector<std::string> feature_list; |
| 741 std::vector<std::string> feature_exception_list; |
741 for (size_t i = 0; i < feature_value->GetSize(); ++i) { | 742 for (size_t i = 0; i < feature_value->GetSize(); ++i) { |
742 std::string feature; | 743 std::string feature; |
| 744 const base::DictionaryValue* features_info_value = NULL; |
743 if (feature_value->GetString(i, &feature)) { | 745 if (feature_value->GetString(i, &feature)) { |
744 feature_list.push_back(feature); | 746 feature_list.push_back(feature); |
| 747 } else if (feature_value->GetDictionary(i, &features_info_value)) { |
| 748 const base::ListValue* exception_list_value = NULL; |
| 749 if (features_info_value->size() > 1) { |
| 750 LOG(WARNING) << "Malformed feature entry " << entry->id(); |
| 751 return NULL; |
| 752 } |
| 753 if (features_info_value->GetList("exceptions", |
| 754 &exception_list_value)) { |
| 755 for (size_t i = 0; i < exception_list_value->GetSize(); ++i) { |
| 756 std::string exception_feature; |
| 757 if (exception_list_value->GetString(i, &exception_feature)) { |
| 758 feature_exception_list.push_back(exception_feature); |
| 759 } else { |
| 760 LOG(WARNING) << "Malformed feature entry " << entry->id(); |
| 761 return NULL; |
| 762 } |
| 763 } |
| 764 } else { |
| 765 LOG(WARNING) << "Malformed feature entry " << entry->id(); |
| 766 return NULL; |
| 767 } |
745 } else { | 768 } else { |
746 LOG(WARNING) << "Malformed feature entry " << entry->id(); | 769 LOG(WARNING) << "Malformed feature entry " << entry->id(); |
747 return NULL; | 770 return NULL; |
748 } | 771 } |
749 } | 772 } |
750 if (!entry->SetFeatures( | 773 if (!entry->SetFeatures(feature_list, feature_exception_list, feature_map, |
751 feature_list, feature_map, supports_feature_type_all)) { | 774 supports_feature_type_all)) { |
752 LOG(WARNING) << "Malformed feature entry " << entry->id(); | 775 LOG(WARNING) << "Malformed feature entry " << entry->id(); |
753 return NULL; | 776 return NULL; |
754 } | 777 } |
755 dictionary_entry_count++; | 778 dictionary_entry_count++; |
756 } | 779 } |
757 } | 780 } |
758 | 781 |
759 if (top_level) { | 782 if (top_level) { |
760 const base::ListValue* exception_list_value = NULL; | 783 const base::ListValue* exception_list_value = NULL; |
761 if (value->GetList("exceptions", &exception_list_value)) { | 784 if (value->GetList("exceptions", &exception_list_value)) { |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
990 void GpuControlList::GpuControlListEntry::SetDirectRenderingInfo(bool value) { | 1013 void GpuControlList::GpuControlListEntry::SetDirectRenderingInfo(bool value) { |
991 direct_rendering_info_.reset(new BoolInfo(value)); | 1014 direct_rendering_info_.reset(new BoolInfo(value)); |
992 } | 1015 } |
993 | 1016 |
994 void GpuControlList::GpuControlListEntry::SetInProcessGPUInfo(bool value) { | 1017 void GpuControlList::GpuControlListEntry::SetInProcessGPUInfo(bool value) { |
995 in_process_gpu_info_.reset(new BoolInfo(value)); | 1018 in_process_gpu_info_.reset(new BoolInfo(value)); |
996 } | 1019 } |
997 | 1020 |
998 bool GpuControlList::GpuControlListEntry::SetFeatures( | 1021 bool GpuControlList::GpuControlListEntry::SetFeatures( |
999 const std::vector<std::string>& feature_strings, | 1022 const std::vector<std::string>& feature_strings, |
| 1023 const std::vector<std::string>& exception_strings, |
1000 const FeatureMap& feature_map, | 1024 const FeatureMap& feature_map, |
1001 bool supports_feature_type_all) { | 1025 bool supports_feature_type_all) { |
1002 size_t size = feature_strings.size(); | 1026 size_t size = feature_strings.size(); |
1003 if (size == 0) | 1027 if (size == 0) |
1004 return false; | 1028 return false; |
1005 features_.clear(); | 1029 features_.clear(); |
1006 for (size_t i = 0; i < size; ++i) { | 1030 for (size_t i = 0; i < size; ++i) { |
1007 int feature = 0; | 1031 int feature = 0; |
1008 if (supports_feature_type_all && feature_strings[i] == "all") { | 1032 if (supports_feature_type_all && feature_strings[i] == "all") { |
1009 for (FeatureMap::const_iterator iter = feature_map.begin(); | 1033 for (FeatureMap::const_iterator iter = feature_map.begin(); |
1010 iter != feature_map.end(); ++iter) | 1034 iter != feature_map.end(); ++iter) { |
1011 features_.insert(iter->second); | 1035 if (std::find(exception_strings.begin(), exception_strings.end(), |
| 1036 iter->first) == exception_strings.end()) |
| 1037 features_.insert(iter->second); |
| 1038 } |
1012 continue; | 1039 continue; |
1013 } | 1040 } |
1014 if (!StringToFeature(feature_strings[i], &feature, feature_map)) { | 1041 if (!StringToFeature(feature_strings[i], &feature, feature_map)) { |
1015 features_.clear(); | 1042 features_.clear(); |
1016 return false; | 1043 return false; |
1017 } | 1044 } |
1018 features_.insert(feature); | 1045 if (std::find(exception_strings.begin(), exception_strings.end(), |
| 1046 feature_strings[i]) == exception_strings.end()) |
| 1047 features_.insert(feature); |
1019 } | 1048 } |
1020 return true; | 1049 return true; |
1021 } | 1050 } |
1022 | 1051 |
1023 void GpuControlList::GpuControlListEntry::AddException( | 1052 void GpuControlList::GpuControlListEntry::AddException( |
1024 ScopedGpuControlListEntry exception) { | 1053 ScopedGpuControlListEntry exception) { |
1025 exceptions_.push_back(exception); | 1054 exceptions_.push_back(exception); |
1026 } | 1055 } |
1027 | 1056 |
1028 bool GpuControlList::GpuControlListEntry::GLVersionInfoMismatch( | 1057 bool GpuControlList::GpuControlListEntry::GLVersionInfoMismatch( |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1585 const std::string& feature_name, int feature_id) { | 1614 const std::string& feature_name, int feature_id) { |
1586 feature_map_[feature_name] = feature_id; | 1615 feature_map_[feature_name] = feature_id; |
1587 } | 1616 } |
1588 | 1617 |
1589 void GpuControlList::set_supports_feature_type_all(bool supported) { | 1618 void GpuControlList::set_supports_feature_type_all(bool supported) { |
1590 supports_feature_type_all_ = supported; | 1619 supports_feature_type_all_ = supported; |
1591 } | 1620 } |
1592 | 1621 |
1593 } // namespace gpu | 1622 } // namespace gpu |
1594 | 1623 |
OLD | NEW |