OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_info_collector_linux.h" | 5 #include "gpu/config/gpu_info_collector_linux.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 FILE_PATH_LITERAL("/etc/ati/amdpcsdb.default"); | 49 FILE_PATH_LITERAL("/etc/ati/amdpcsdb.default"); |
50 base::FilePath ati_file_path(kATIFileName); | 50 base::FilePath ati_file_path(kATIFileName); |
51 if (!base::PathExists(ati_file_path)) | 51 if (!base::PathExists(ati_file_path)) |
52 return std::string(); | 52 return std::string(); |
53 std::string contents; | 53 std::string contents; |
54 if (!base::ReadFileToString(ati_file_path, &contents)) | 54 if (!base::ReadFileToString(ati_file_path, &contents)) |
55 return std::string(); | 55 return std::string(); |
56 base::StringTokenizer t(contents, "\r\n"); | 56 base::StringTokenizer t(contents, "\r\n"); |
57 while (t.GetNext()) { | 57 while (t.GetNext()) { |
58 std::string line = t.token(); | 58 std::string line = t.token(); |
59 if (base::StartsWithASCII(line, "ReleaseVersion=", true)) { | 59 if (base::StartsWith(line, "ReleaseVersion=", |
| 60 base::CompareCase::SENSITIVE)) { |
60 size_t begin = line.find_first_of("0123456789"); | 61 size_t begin = line.find_first_of("0123456789"); |
61 if (begin != std::string::npos) { | 62 if (begin != std::string::npos) { |
62 size_t end = line.find_first_not_of("0123456789.", begin); | 63 size_t end = line.find_first_not_of("0123456789.", begin); |
63 if (end == std::string::npos) | 64 if (end == std::string::npos) |
64 return line.substr(begin); | 65 return line.substr(begin); |
65 else | 66 else |
66 return line.substr(begin, end - begin); | 67 return line.substr(begin, end - begin); |
67 } | 68 } |
68 } | 69 } |
69 } | 70 } |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 } | 238 } |
238 | 239 |
239 gpu_info->basic_info_state = result; | 240 gpu_info->basic_info_state = result; |
240 return result; | 241 return result; |
241 } | 242 } |
242 | 243 |
243 CollectInfoResult CollectDriverInfoGL(GPUInfo* gpu_info) { | 244 CollectInfoResult CollectDriverInfoGL(GPUInfo* gpu_info) { |
244 DCHECK(gpu_info); | 245 DCHECK(gpu_info); |
245 | 246 |
246 std::string gl_version = gpu_info->gl_version; | 247 std::string gl_version = gpu_info->gl_version; |
247 if (base::StartsWithASCII(gl_version, "OpenGL ES", true)) | 248 if (base::StartsWith(gl_version, "OpenGL ES", base::CompareCase::SENSITIVE)) |
248 gl_version = gl_version.substr(10); | 249 gl_version = gl_version.substr(10); |
249 std::vector<std::string> pieces; | 250 std::vector<std::string> pieces = |
250 base::SplitStringAlongWhitespace(gl_version, &pieces); | 251 base::SplitString(gl_version, base::kWhitespaceASCII, |
| 252 base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
251 // In linux, the gl version string might be in the format of | 253 // In linux, the gl version string might be in the format of |
252 // GLVersion DriverVendor DriverVersion | 254 // GLVersion DriverVendor DriverVersion |
253 if (pieces.size() < 3) | 255 if (pieces.size() < 3) |
254 return kCollectInfoNonFatalFailure; | 256 return kCollectInfoNonFatalFailure; |
255 | 257 |
256 std::string driver_version = pieces[2]; | 258 std::string driver_version = pieces[2]; |
257 size_t pos = driver_version.find_first_not_of("0123456789."); | 259 size_t pos = driver_version.find_first_not_of("0123456789."); |
258 if (pos == 0) | 260 if (pos == 0) |
259 return kCollectInfoNonFatalFailure; | 261 return kCollectInfoNonFatalFailure; |
260 if (pos != std::string::npos) | 262 if (pos != std::string::npos) |
261 driver_version = driver_version.substr(0, pos); | 263 driver_version = driver_version.substr(0, pos); |
262 | 264 |
263 gpu_info->driver_vendor = pieces[1]; | 265 gpu_info->driver_vendor = pieces[1]; |
264 gpu_info->driver_version = driver_version; | 266 gpu_info->driver_version = driver_version; |
265 return kCollectInfoSuccess; | 267 return kCollectInfoSuccess; |
266 } | 268 } |
267 | 269 |
268 void MergeGPUInfo(GPUInfo* basic_gpu_info, | 270 void MergeGPUInfo(GPUInfo* basic_gpu_info, |
269 const GPUInfo& context_gpu_info) { | 271 const GPUInfo& context_gpu_info) { |
270 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); | 272 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); |
271 } | 273 } |
272 | 274 |
273 } // namespace gpu | 275 } // namespace gpu |
OLD | NEW |