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" | 13 #include "base/strings/stringprintf.h" |
14 #include "base/sys_info.h" | 14 #include "base/sys_info.h" |
15 #include "gpu/config/gpu_info.h" | 15 #include "gpu/config/gpu_info.h" |
16 #include "gpu/config/gpu_util.h" | 16 #include "gpu/config/gpu_util.h" |
17 #include "third_party/re2/re2/re2.h" | 17 #include "third_party/re2/re2/re2.h" |
18 | 18 |
19 namespace gpu { | 19 namespace gpu { |
20 namespace { | 20 namespace { |
21 | 21 |
22 // Break a version string into segments. Return true if each segment is | 22 // Break a version string into segments. Return true if each segment is |
23 // a valid number, and not all segment is 0. | 23 // a valid number, and not all segment is 0. |
24 bool ProcessVersionString(const std::string& version_string, | 24 bool ProcessVersionString(const std::string& version_string, |
25 char splitter, | 25 char splitter, |
26 std::vector<std::string>* version) { | 26 std::vector<std::string>* version) { |
| 27 char splitter_string[2] = {splitter, '\0'}; |
27 DCHECK(version); | 28 DCHECK(version); |
28 base::SplitString(version_string, splitter, version); | 29 *version = base::SplitString(version_string, splitter_string, |
| 30 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
29 if (version->size() == 0) | 31 if (version->size() == 0) |
30 return false; | 32 return false; |
31 // If the splitter is '-', we assume it's a date with format "mm-dd-yyyy"; | 33 // If the splitter is '-', we assume it's a date with format "mm-dd-yyyy"; |
32 // we split it into the order of "yyyy", "mm", "dd". | 34 // we split it into the order of "yyyy", "mm", "dd". |
33 if (splitter == '-') { | 35 if (splitter == '-') { |
34 std::string year = (*version)[version->size() - 1]; | 36 std::string year = (*version)[version->size() - 1]; |
35 for (int i = version->size() - 1; i > 0; --i) { | 37 for (int i = version->size() - 1; i > 0; --i) { |
36 (*version)[i] = (*version)[i - 1]; | 38 (*version)[i] = (*version)[i - 1]; |
37 } | 39 } |
38 (*version)[0] = year; | 40 (*version)[0] = year; |
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 } | 999 } |
998 | 1000 |
999 bool GpuControlList::GpuControlListEntry::GLVersionInfoMismatch( | 1001 bool GpuControlList::GpuControlListEntry::GLVersionInfoMismatch( |
1000 const std::string& gl_version) const { | 1002 const std::string& gl_version) const { |
1001 if (gl_version.empty()) | 1003 if (gl_version.empty()) |
1002 return false; | 1004 return false; |
1003 | 1005 |
1004 if (gl_version_info_.get() == NULL && gl_type_ == kGLTypeNone) | 1006 if (gl_version_info_.get() == NULL && gl_type_ == kGLTypeNone) |
1005 return false; | 1007 return false; |
1006 | 1008 |
1007 std::vector<std::string> segments; | 1009 std::vector<std::string> segments = base::SplitString( |
1008 base::SplitString(gl_version, ' ', &segments); | 1010 gl_version, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
1009 std::string number; | 1011 std::string number; |
1010 GLType gl_type = kGLTypeNone; | 1012 GLType gl_type = kGLTypeNone; |
1011 if (segments.size() > 2 && | 1013 if (segments.size() > 2 && |
1012 segments[0] == "OpenGL" && segments[1] == "ES") { | 1014 segments[0] == "OpenGL" && segments[1] == "ES") { |
1013 bool full_match = RE2::FullMatch(segments[2], "([\\d.]+).*", &number); | 1015 bool full_match = RE2::FullMatch(segments[2], "([\\d.]+).*", &number); |
1014 DCHECK(full_match); | 1016 DCHECK(full_match); |
1015 | 1017 |
1016 gl_type = kGLTypeGLES; | 1018 gl_type = kGLTypeGLES; |
1017 if (segments.size() > 3 && | 1019 if (segments.size() > 3 && |
1018 base::StartsWithASCII(segments[3], "(ANGLE", false)) { | 1020 base::StartsWith(segments[3], "(ANGLE", |
| 1021 base::CompareCase::INSENSITIVE_ASCII)) { |
1019 gl_type = kGLTypeANGLE; | 1022 gl_type = kGLTypeANGLE; |
1020 } | 1023 } |
1021 } else { | 1024 } else { |
1022 number = segments[0]; | 1025 number = segments[0]; |
1023 gl_type = kGLTypeGL; | 1026 gl_type = kGLTypeGL; |
1024 } | 1027 } |
1025 | 1028 |
1026 if (gl_type_ != kGLTypeNone && gl_type_ != gl_type) | 1029 if (gl_type_ != kGLTypeNone && gl_type_ != gl_type) |
1027 return true; | 1030 return true; |
1028 if (gl_version_info_.get() != NULL && !gl_version_info_->Contains(number)) | 1031 if (gl_version_info_.get() != NULL && !gl_version_info_->Contains(number)) |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1510 const std::string& feature_name, int feature_id) { | 1513 const std::string& feature_name, int feature_id) { |
1511 feature_map_[feature_name] = feature_id; | 1514 feature_map_[feature_name] = feature_id; |
1512 } | 1515 } |
1513 | 1516 |
1514 void GpuControlList::set_supports_feature_type_all(bool supported) { | 1517 void GpuControlList::set_supports_feature_type_all(bool supported) { |
1515 supports_feature_type_all_ = supported; | 1518 supports_feature_type_all_ = supported; |
1516 } | 1519 } |
1517 | 1520 |
1518 } // namespace gpu | 1521 } // namespace gpu |
1519 | 1522 |
OLD | NEW |