| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 unsigned value2 = number_ref[i] - '0'; | 80 unsigned value2 = number_ref[i] - '0'; |
| 81 if (value1 > value2) | 81 if (value1 > value2) |
| 82 return 1; | 82 return 1; |
| 83 if (value1 < value2) | 83 if (value1 < value2) |
| 84 return -1; | 84 return -1; |
| 85 } | 85 } |
| 86 return 0; | 86 return 0; |
| 87 } | 87 } |
| 88 | 88 |
| 89 const char kMultiGpuStyleStringAMDSwitchable[] = "amd_switchable"; | 89 const char kMultiGpuStyleStringAMDSwitchable[] = "amd_switchable"; |
| 90 const char kMultiGpuStyleStringAMDSwitchableDiscrete[] = |
| 91 "amd_switchable_discrete"; |
| 92 const char kMultiGpuStyleStringAMDSwitchableIntegrated[] = |
| 93 "amd_switchable_integrated"; |
| 90 const char kMultiGpuStyleStringOptimus[] = "optimus"; | 94 const char kMultiGpuStyleStringOptimus[] = "optimus"; |
| 91 | 95 |
| 92 const char kMultiGpuCategoryStringPrimary[] = "primary"; | 96 const char kMultiGpuCategoryStringPrimary[] = "primary"; |
| 93 const char kMultiGpuCategoryStringSecondary[] = "secondary"; | 97 const char kMultiGpuCategoryStringSecondary[] = "secondary"; |
| 94 const char kMultiGpuCategoryStringActive[] = "active"; | 98 const char kMultiGpuCategoryStringActive[] = "active"; |
| 95 const char kMultiGpuCategoryStringAny[] = "any"; | 99 const char kMultiGpuCategoryStringAny[] = "any"; |
| 96 | 100 |
| 97 const char kGLTypeStringGL[] = "gl"; | 101 const char kGLTypeStringGL[] = "gl"; |
| 98 const char kGLTypeStringGLES[] = "gles"; | 102 const char kGLTypeStringGLES[] = "gles"; |
| 99 const char kGLTypeStringANGLE[] = "angle"; | 103 const char kGLTypeStringANGLE[] = "angle"; |
| (...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 } | 1075 } |
| 1072 | 1076 |
| 1073 // static | 1077 // static |
| 1074 GpuControlList::GpuControlListEntry::MultiGpuStyle | 1078 GpuControlList::GpuControlListEntry::MultiGpuStyle |
| 1075 GpuControlList::GpuControlListEntry::StringToMultiGpuStyle( | 1079 GpuControlList::GpuControlListEntry::StringToMultiGpuStyle( |
| 1076 const std::string& style) { | 1080 const std::string& style) { |
| 1077 if (style == kMultiGpuStyleStringOptimus) | 1081 if (style == kMultiGpuStyleStringOptimus) |
| 1078 return kMultiGpuStyleOptimus; | 1082 return kMultiGpuStyleOptimus; |
| 1079 if (style == kMultiGpuStyleStringAMDSwitchable) | 1083 if (style == kMultiGpuStyleStringAMDSwitchable) |
| 1080 return kMultiGpuStyleAMDSwitchable; | 1084 return kMultiGpuStyleAMDSwitchable; |
| 1085 if (style == kMultiGpuStyleStringAMDSwitchableIntegrated) |
| 1086 return kMultiGpuStyleAMDSwitchableIntegrated; |
| 1087 if (style == kMultiGpuStyleStringAMDSwitchableDiscrete) |
| 1088 return kMultiGpuStyleAMDSwitchableDiscrete; |
| 1081 return kMultiGpuStyleNone; | 1089 return kMultiGpuStyleNone; |
| 1082 } | 1090 } |
| 1083 | 1091 |
| 1084 // static | 1092 // static |
| 1085 GpuControlList::GpuControlListEntry::MultiGpuCategory | 1093 GpuControlList::GpuControlListEntry::MultiGpuCategory |
| 1086 GpuControlList::GpuControlListEntry::StringToMultiGpuCategory( | 1094 GpuControlList::GpuControlListEntry::StringToMultiGpuCategory( |
| 1087 const std::string& category) { | 1095 const std::string& category) { |
| 1088 if (category == kMultiGpuCategoryStringPrimary) | 1096 if (category == kMultiGpuCategoryStringPrimary) |
| 1089 return kMultiGpuCategoryPrimary; | 1097 return kMultiGpuCategoryPrimary; |
| 1090 if (category == kMultiGpuCategoryStringSecondary) | 1098 if (category == kMultiGpuCategoryStringSecondary) |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 } | 1200 } |
| 1193 switch (multi_gpu_style_) { | 1201 switch (multi_gpu_style_) { |
| 1194 case kMultiGpuStyleOptimus: | 1202 case kMultiGpuStyleOptimus: |
| 1195 if (!gpu_info.optimus) | 1203 if (!gpu_info.optimus) |
| 1196 return false; | 1204 return false; |
| 1197 break; | 1205 break; |
| 1198 case kMultiGpuStyleAMDSwitchable: | 1206 case kMultiGpuStyleAMDSwitchable: |
| 1199 if (!gpu_info.amd_switchable) | 1207 if (!gpu_info.amd_switchable) |
| 1200 return false; | 1208 return false; |
| 1201 break; | 1209 break; |
| 1210 case kMultiGpuStyleAMDSwitchableDiscrete: |
| 1211 if (!gpu_info.amd_switchable) |
| 1212 return false; |
| 1213 // The discrete GPU is always the primary GPU. |
| 1214 // This is guaranteed by GpuInfoCollector. |
| 1215 if (!gpu_info.gpu.active) |
| 1216 return false; |
| 1217 break; |
| 1218 case kMultiGpuStyleAMDSwitchableIntegrated: |
| 1219 if (!gpu_info.amd_switchable) |
| 1220 return false; |
| 1221 // Assume the integrated GPU is the first in the secondary GPU list. |
| 1222 if (gpu_info.secondary_gpus.size() == 0 || |
| 1223 !gpu_info.secondary_gpus[0].active) |
| 1224 return false; |
| 1225 break; |
| 1202 case kMultiGpuStyleNone: | 1226 case kMultiGpuStyleNone: |
| 1203 break; | 1227 break; |
| 1204 } | 1228 } |
| 1205 if (driver_vendor_info_.get() != NULL && !gpu_info.driver_vendor.empty() && | 1229 if (driver_vendor_info_.get() != NULL && !gpu_info.driver_vendor.empty() && |
| 1206 !driver_vendor_info_->Contains(gpu_info.driver_vendor)) | 1230 !driver_vendor_info_->Contains(gpu_info.driver_vendor)) |
| 1207 return false; | 1231 return false; |
| 1208 if (driver_version_info_.get() != NULL && !gpu_info.driver_version.empty()) { | 1232 if (driver_version_info_.get() != NULL && !gpu_info.driver_version.empty()) { |
| 1209 if (!driver_version_info_->Contains(gpu_info.driver_version)) | 1233 if (!driver_version_info_->Contains(gpu_info.driver_version)) |
| 1210 return false; | 1234 return false; |
| 1211 } | 1235 } |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1551 const std::string& feature_name, int feature_id) { | 1575 const std::string& feature_name, int feature_id) { |
| 1552 feature_map_[feature_name] = feature_id; | 1576 feature_map_[feature_name] = feature_id; |
| 1553 } | 1577 } |
| 1554 | 1578 |
| 1555 void GpuControlList::set_supports_feature_type_all(bool supported) { | 1579 void GpuControlList::set_supports_feature_type_all(bool supported) { |
| 1556 supports_feature_type_all_ = supported; | 1580 supports_feature_type_all_ = supported; |
| 1557 } | 1581 } |
| 1558 | 1582 |
| 1559 } // namespace gpu | 1583 } // namespace gpu |
| 1560 | 1584 |
| OLD | NEW |