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 (StartsWithASCII(line, "ReleaseVersion=", true)) { | 59 if (base::StartsWithASCII(line, "ReleaseVersion=", true)) { |
60 size_t begin = line.find_first_of("0123456789"); | 60 size_t begin = line.find_first_of("0123456789"); |
61 if (begin != std::string::npos) { | 61 if (begin != std::string::npos) { |
62 size_t end = line.find_first_not_of("0123456789.", begin); | 62 size_t end = line.find_first_not_of("0123456789.", begin); |
63 if (end == std::string::npos) | 63 if (end == std::string::npos) |
64 return line.substr(begin); | 64 return line.substr(begin); |
65 else | 65 else |
66 return line.substr(begin, end - begin); | 66 return line.substr(begin, end - begin); |
67 } | 67 } |
68 } | 68 } |
69 } | 69 } |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 } | 237 } |
238 | 238 |
239 gpu_info->basic_info_state = result; | 239 gpu_info->basic_info_state = result; |
240 return result; | 240 return result; |
241 } | 241 } |
242 | 242 |
243 CollectInfoResult CollectDriverInfoGL(GPUInfo* gpu_info) { | 243 CollectInfoResult CollectDriverInfoGL(GPUInfo* gpu_info) { |
244 DCHECK(gpu_info); | 244 DCHECK(gpu_info); |
245 | 245 |
246 std::string gl_version = gpu_info->gl_version; | 246 std::string gl_version = gpu_info->gl_version; |
247 if (StartsWithASCII(gl_version, "OpenGL ES", true)) | 247 if (base::StartsWithASCII(gl_version, "OpenGL ES", true)) |
248 gl_version = gl_version.substr(10); | 248 gl_version = gl_version.substr(10); |
249 std::vector<std::string> pieces; | 249 std::vector<std::string> pieces; |
250 base::SplitStringAlongWhitespace(gl_version, &pieces); | 250 base::SplitStringAlongWhitespace(gl_version, &pieces); |
251 // In linux, the gl version string might be in the format of | 251 // In linux, the gl version string might be in the format of |
252 // GLVersion DriverVendor DriverVersion | 252 // GLVersion DriverVendor DriverVersion |
253 if (pieces.size() < 3) | 253 if (pieces.size() < 3) |
254 return kCollectInfoNonFatalFailure; | 254 return kCollectInfoNonFatalFailure; |
255 | 255 |
256 std::string driver_version = pieces[2]; | 256 std::string driver_version = pieces[2]; |
257 size_t pos = driver_version.find_first_not_of("0123456789."); | 257 size_t pos = driver_version.find_first_not_of("0123456789."); |
258 if (pos == 0) | 258 if (pos == 0) |
259 return kCollectInfoNonFatalFailure; | 259 return kCollectInfoNonFatalFailure; |
260 if (pos != std::string::npos) | 260 if (pos != std::string::npos) |
261 driver_version = driver_version.substr(0, pos); | 261 driver_version = driver_version.substr(0, pos); |
262 | 262 |
263 gpu_info->driver_vendor = pieces[1]; | 263 gpu_info->driver_vendor = pieces[1]; |
264 gpu_info->driver_version = driver_version; | 264 gpu_info->driver_version = driver_version; |
265 return kCollectInfoSuccess; | 265 return kCollectInfoSuccess; |
266 } | 266 } |
267 | 267 |
268 void MergeGPUInfo(GPUInfo* basic_gpu_info, | 268 void MergeGPUInfo(GPUInfo* basic_gpu_info, |
269 const GPUInfo& context_gpu_info) { | 269 const GPUInfo& context_gpu_info) { |
270 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); | 270 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); |
271 } | 271 } |
272 | 272 |
273 } // namespace gpu | 273 } // namespace gpu |
OLD | NEW |