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" |
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" | |
14 #include "base/sys_info.h" | 13 #include "base/sys_info.h" |
15 #include "gpu/config/gpu_info.h" | 14 #include "gpu/config/gpu_info.h" |
16 #include "gpu/config/gpu_util.h" | 15 #include "gpu/config/gpu_util.h" |
17 | 16 |
18 namespace gpu { | 17 namespace gpu { |
19 namespace { | 18 namespace { |
20 | 19 |
21 // Break a version string into segments. Return true if each segment is | 20 // Break a version string into segments. Return true if each segment is |
22 // a valid number. | 21 // a valid number. |
23 bool ProcessVersionString(const std::string& version_string, | 22 bool ProcessVersionString(const std::string& version_string, |
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1024 const std::string& category) { | 1023 const std::string& category) { |
1025 if (category == kMultiGpuCategoryStringPrimary) | 1024 if (category == kMultiGpuCategoryStringPrimary) |
1026 return kMultiGpuCategoryPrimary; | 1025 return kMultiGpuCategoryPrimary; |
1027 if (category == kMultiGpuCategoryStringSecondary) | 1026 if (category == kMultiGpuCategoryStringSecondary) |
1028 return kMultiGpuCategorySecondary; | 1027 return kMultiGpuCategorySecondary; |
1029 if (category == kMultiGpuCategoryStringAny) | 1028 if (category == kMultiGpuCategoryStringAny) |
1030 return kMultiGpuCategoryAny; | 1029 return kMultiGpuCategoryAny; |
1031 return kMultiGpuCategoryNone; | 1030 return kMultiGpuCategoryNone; |
1032 } | 1031 } |
1033 | 1032 |
1034 void GpuControlList::GpuControlListEntry::LogControlListMatch( | |
1035 const std::string& control_list_logging_name) const { | |
1036 static const char kControlListMatchMessage[] = | |
1037 "Control list match for rule #%u in %s."; | |
1038 LOG(INFO) << base::StringPrintf(kControlListMatchMessage, id_, | |
1039 control_list_logging_name.c_str()); | |
1040 } | |
1041 | |
1042 bool GpuControlList::GpuControlListEntry::Contains( | 1033 bool GpuControlList::GpuControlListEntry::Contains( |
1043 OsType os_type, const std::string& os_version, | 1034 OsType os_type, const std::string& os_version, |
1044 const GPUInfo& gpu_info) const { | 1035 const GPUInfo& gpu_info) const { |
1045 DCHECK(os_type != kOsAny); | 1036 DCHECK(os_type != kOsAny); |
1046 if (os_info_.get() != NULL && !os_info_->Contains(os_type, os_version)) | 1037 if (os_info_.get() != NULL && !os_info_->Contains(os_type, os_version)) |
1047 return false; | 1038 return false; |
1048 bool is_not_primary_gpu = | 1039 bool is_not_primary_gpu = |
1049 GpuUnmatched(vendor_id_, device_id_list_, gpu_info.gpu); | 1040 GpuUnmatched(vendor_id_, device_id_list_, gpu_info.gpu); |
1050 bool is_not_secondary_gpu = true; | 1041 bool is_not_secondary_gpu = true; |
1051 for (size_t i = 0; i < gpu_info.secondary_gpus.size(); ++i) { | 1042 for (size_t i = 0; i < gpu_info.secondary_gpus.size(); ++i) { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 if (iter != feature_map.end()) { | 1178 if (iter != feature_map.end()) { |
1188 *feature_id = iter->second; | 1179 *feature_id = iter->second; |
1189 return true; | 1180 return true; |
1190 } | 1181 } |
1191 return false; | 1182 return false; |
1192 } | 1183 } |
1193 | 1184 |
1194 GpuControlList::GpuControlList() | 1185 GpuControlList::GpuControlList() |
1195 : max_entry_id_(0), | 1186 : max_entry_id_(0), |
1196 needs_more_info_(false), | 1187 needs_more_info_(false), |
1197 supports_feature_type_all_(false), | 1188 supports_feature_type_all_(false) { |
1198 control_list_logging_enabled_(false) { | |
1199 } | 1189 } |
1200 | 1190 |
1201 GpuControlList::~GpuControlList() { | 1191 GpuControlList::~GpuControlList() { |
1202 Clear(); | 1192 Clear(); |
1203 } | 1193 } |
1204 | 1194 |
1205 bool GpuControlList::LoadList( | 1195 bool GpuControlList::LoadList( |
1206 const std::string& json_context, GpuControlList::OsFilter os_filter) { | 1196 const std::string& json_context, GpuControlList::OsFilter os_filter) { |
1207 const std::string browser_version_string = "0"; | 1197 const std::string browser_version_string = "0"; |
1208 return LoadList(browser_version_string, json_context, os_filter); | 1198 return LoadList(browser_version_string, json_context, os_filter); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1295 if (pos != std::string::npos) | 1285 if (pos != std::string::npos) |
1296 os_version = os_version.substr(0, pos); | 1286 os_version = os_version.substr(0, pos); |
1297 } | 1287 } |
1298 std::vector<std::string> pieces; | 1288 std::vector<std::string> pieces; |
1299 if (!ProcessVersionString(os_version, '.', &pieces)) | 1289 if (!ProcessVersionString(os_version, '.', &pieces)) |
1300 os_version = "0"; | 1290 os_version = "0"; |
1301 | 1291 |
1302 for (size_t i = 0; i < entries_.size(); ++i) { | 1292 for (size_t i = 0; i < entries_.size(); ++i) { |
1303 if (entries_[i]->Contains(os, os_version, gpu_info)) { | 1293 if (entries_[i]->Contains(os, os_version, gpu_info)) { |
1304 if (!entries_[i]->disabled()) { | 1294 if (!entries_[i]->disabled()) { |
1305 if (control_list_logging_enabled_) | |
1306 entries_[i]->LogControlListMatch(control_list_logging_name_); | |
1307 MergeFeatureSets(&possible_features, entries_[i]->features()); | 1295 MergeFeatureSets(&possible_features, entries_[i]->features()); |
1308 if (!entries_[i]->NeedsMoreInfo(gpu_info)) | 1296 if (!entries_[i]->NeedsMoreInfo(gpu_info)) |
1309 MergeFeatureSets(&features, entries_[i]->features()); | 1297 MergeFeatureSets(&features, entries_[i]->features()); |
1310 } | 1298 } |
1311 active_entries_.push_back(entries_[i]); | 1299 active_entries_.push_back(entries_[i]); |
1312 } | 1300 } |
1313 } | 1301 } |
1314 | 1302 |
1315 if (possible_features.size() > features.size()) | 1303 if (possible_features.size() > features.size()) |
1316 needs_more_info_ = true; | 1304 needs_more_info_ = true; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1435 const std::string& feature_name, int feature_id) { | 1423 const std::string& feature_name, int feature_id) { |
1436 feature_map_[feature_name] = feature_id; | 1424 feature_map_[feature_name] = feature_id; |
1437 } | 1425 } |
1438 | 1426 |
1439 void GpuControlList::set_supports_feature_type_all(bool supported) { | 1427 void GpuControlList::set_supports_feature_type_all(bool supported) { |
1440 supports_feature_type_all_ = supported; | 1428 supports_feature_type_all_ = supported; |
1441 } | 1429 } |
1442 | 1430 |
1443 } // namespace gpu | 1431 } // namespace gpu |
1444 | 1432 |
OLD | NEW |