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 DCHECK(version); | 27 DCHECK(version); |
28 base::SplitString(version_string, splitter, version); | 28 *version = base::SplitString( |
| 29 version_string, std::string(1, splitter), |
| 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 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 } | 1023 } |
1022 | 1024 |
1023 bool GpuControlList::GpuControlListEntry::GLVersionInfoMismatch( | 1025 bool GpuControlList::GpuControlListEntry::GLVersionInfoMismatch( |
1024 const std::string& gl_version) const { | 1026 const std::string& gl_version) const { |
1025 if (gl_version.empty()) | 1027 if (gl_version.empty()) |
1026 return false; | 1028 return false; |
1027 | 1029 |
1028 if (gl_version_info_.get() == NULL && gl_type_ == kGLTypeNone) | 1030 if (gl_version_info_.get() == NULL && gl_type_ == kGLTypeNone) |
1029 return false; | 1031 return false; |
1030 | 1032 |
1031 std::vector<std::string> segments; | 1033 std::vector<std::string> segments = base::SplitString( |
1032 base::SplitString(gl_version, ' ', &segments); | 1034 gl_version, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
1033 std::string number; | 1035 std::string number; |
1034 GLType gl_type = kGLTypeNone; | 1036 GLType gl_type = kGLTypeNone; |
1035 if (segments.size() > 2 && | 1037 if (segments.size() > 2 && |
1036 segments[0] == "OpenGL" && segments[1] == "ES") { | 1038 segments[0] == "OpenGL" && segments[1] == "ES") { |
1037 bool full_match = RE2::FullMatch(segments[2], "([\\d.]+).*", &number); | 1039 bool full_match = RE2::FullMatch(segments[2], "([\\d.]+).*", &number); |
1038 DCHECK(full_match); | 1040 DCHECK(full_match); |
1039 | 1041 |
1040 gl_type = kGLTypeGLES; | 1042 gl_type = kGLTypeGLES; |
1041 if (segments.size() > 3 && | 1043 if (segments.size() > 3 && |
1042 base::StartsWith(segments[3], "(ANGLE", | 1044 base::StartsWith(segments[3], "(ANGLE", |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1578 const std::string& feature_name, int feature_id) { | 1580 const std::string& feature_name, int feature_id) { |
1579 feature_map_[feature_name] = feature_id; | 1581 feature_map_[feature_name] = feature_id; |
1580 } | 1582 } |
1581 | 1583 |
1582 void GpuControlList::set_supports_feature_type_all(bool supported) { | 1584 void GpuControlList::set_supports_feature_type_all(bool supported) { |
1583 supports_feature_type_all_ = supported; | 1585 supports_feature_type_all_ = supported; |
1584 } | 1586 } |
1585 | 1587 |
1586 } // namespace gpu | 1588 } // namespace gpu |
1587 | 1589 |
OLD | NEW |