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 *version = base::SplitString( | 28 base::SplitString(version_string, splitter, version); |
29 version_string, std::string(1, splitter), | |
30 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | |
31 if (version->size() == 0) | 29 if (version->size() == 0) |
32 return false; | 30 return false; |
33 // If the splitter is '-', we assume it's a date with format "mm-dd-yyyy"; | 31 // If the splitter is '-', we assume it's a date with format "mm-dd-yyyy"; |
34 // we split it into the order of "yyyy", "mm", "dd". | 32 // we split it into the order of "yyyy", "mm", "dd". |
35 if (splitter == '-') { | 33 if (splitter == '-') { |
36 std::string year = (*version)[version->size() - 1]; | 34 std::string year = (*version)[version->size() - 1]; |
37 for (int i = version->size() - 1; i > 0; --i) { | 35 for (int i = version->size() - 1; i > 0; --i) { |
38 (*version)[i] = (*version)[i - 1]; | 36 (*version)[i] = (*version)[i - 1]; |
39 } | 37 } |
40 (*version)[0] = year; | 38 (*version)[0] = year; |
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1023 } | 1021 } |
1024 | 1022 |
1025 bool GpuControlList::GpuControlListEntry::GLVersionInfoMismatch( | 1023 bool GpuControlList::GpuControlListEntry::GLVersionInfoMismatch( |
1026 const std::string& gl_version) const { | 1024 const std::string& gl_version) const { |
1027 if (gl_version.empty()) | 1025 if (gl_version.empty()) |
1028 return false; | 1026 return false; |
1029 | 1027 |
1030 if (gl_version_info_.get() == NULL && gl_type_ == kGLTypeNone) | 1028 if (gl_version_info_.get() == NULL && gl_type_ == kGLTypeNone) |
1031 return false; | 1029 return false; |
1032 | 1030 |
1033 std::vector<std::string> segments = base::SplitString( | 1031 std::vector<std::string> segments; |
1034 gl_version, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 1032 base::SplitString(gl_version, ' ', &segments); |
1035 std::string number; | 1033 std::string number; |
1036 GLType gl_type = kGLTypeNone; | 1034 GLType gl_type = kGLTypeNone; |
1037 if (segments.size() > 2 && | 1035 if (segments.size() > 2 && |
1038 segments[0] == "OpenGL" && segments[1] == "ES") { | 1036 segments[0] == "OpenGL" && segments[1] == "ES") { |
1039 bool full_match = RE2::FullMatch(segments[2], "([\\d.]+).*", &number); | 1037 bool full_match = RE2::FullMatch(segments[2], "([\\d.]+).*", &number); |
1040 DCHECK(full_match); | 1038 DCHECK(full_match); |
1041 | 1039 |
1042 gl_type = kGLTypeGLES; | 1040 gl_type = kGLTypeGLES; |
1043 if (segments.size() > 3 && | 1041 if (segments.size() > 3 && |
1044 base::StartsWith(segments[3], "(ANGLE", | 1042 base::StartsWith(segments[3], "(ANGLE", |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1580 const std::string& feature_name, int feature_id) { | 1578 const std::string& feature_name, int feature_id) { |
1581 feature_map_[feature_name] = feature_id; | 1579 feature_map_[feature_name] = feature_id; |
1582 } | 1580 } |
1583 | 1581 |
1584 void GpuControlList::set_supports_feature_type_all(bool supported) { | 1582 void GpuControlList::set_supports_feature_type_all(bool supported) { |
1585 supports_feature_type_all_ = supported; | 1583 supports_feature_type_all_ = supported; |
1586 } | 1584 } |
1587 | 1585 |
1588 } // namespace gpu | 1586 } // namespace gpu |
1589 | 1587 |
OLD | NEW |