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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
16 #include "base/strings/string_piece.h" | 16 #include "base/strings/string_piece.h" |
17 #include "base/strings/string_split.h" | 17 #include "base/strings/string_split.h" |
18 #include "base/strings/string_tokenizer.h" | 18 #include "base/strings/string_tokenizer.h" |
19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
20 #include "base/trace_event/trace_event.h" | 20 #include "base/trace_event/trace_event.h" |
21 #include "gpu/config/gpu_info_collector.h" | 21 #include "gpu/config/gpu_info_collector.h" |
22 #include "third_party/re2/src/re2/re2.h" | |
23 #include "ui/gl/gl_bindings.h" | 22 #include "ui/gl/gl_bindings.h" |
24 #include "ui/gl/gl_context.h" | 23 #include "ui/gl/gl_context.h" |
25 #include "ui/gl/gl_implementation.h" | 24 #include "ui/gl/gl_implementation.h" |
26 #include "ui/gl/gl_surface.h" | 25 #include "ui/gl/gl_surface.h" |
27 #include "ui/gl/gl_switches.h" | 26 #include "ui/gl/gl_switches.h" |
28 | 27 |
29 #if defined(USE_LIBPCI) | 28 #if defined(USE_LIBPCI) |
30 #include "library_loaders/libpci.h" // nogncheck | 29 #include "library_loaders/libpci.h" // nogncheck |
31 #endif | 30 #endif |
32 | 31 |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 } | 240 } |
242 | 241 |
243 gpu_info->basic_info_state = result; | 242 gpu_info->basic_info_state = result; |
244 return result; | 243 return result; |
245 } | 244 } |
246 | 245 |
247 CollectInfoResult CollectDriverInfoGL(GPUInfo* gpu_info) { | 246 CollectInfoResult CollectDriverInfoGL(GPUInfo* gpu_info) { |
248 DCHECK(gpu_info); | 247 DCHECK(gpu_info); |
249 | 248 |
250 std::string gl_version = gpu_info->gl_version; | 249 std::string gl_version = gpu_info->gl_version; |
| 250 if (base::StartsWith(gl_version, "OpenGL ES", base::CompareCase::SENSITIVE)) |
| 251 gl_version = gl_version.substr(10); |
251 std::vector<std::string> pieces = base::SplitString( | 252 std::vector<std::string> pieces = base::SplitString( |
252 gl_version, base::kWhitespaceASCII, base::KEEP_WHITESPACE, | 253 gl_version, base::kWhitespaceASCII, base::KEEP_WHITESPACE, |
253 base::SPLIT_WANT_NONEMPTY); | 254 base::SPLIT_WANT_NONEMPTY); |
254 // In linux, the gl version string might be in the format of | 255 // In linux, the gl version string might be in the format of |
255 // GLVersion DriverVendor DriverVersion | 256 // GLVersion DriverVendor DriverVersion |
256 if (pieces.size() < 3) | 257 if (pieces.size() < 3) |
257 return kCollectInfoNonFatalFailure; | 258 return kCollectInfoNonFatalFailure; |
258 | 259 |
259 // Search from the end for the first piece that starts with major.minor or | 260 std::string driver_version = pieces[2]; |
260 // major.minor.micro but assume the driver version cannot be in the first two | 261 size_t pos = driver_version.find_first_not_of("0123456789."); |
261 // pieces. | 262 if (pos == 0) |
262 re2::RE2 pattern("([\\d]+\\.[\\d]+(\\.[\\d]+)?).*"); | 263 return kCollectInfoNonFatalFailure; |
263 std::string driver_version; | 264 if (pos != std::string::npos) |
264 auto it = pieces.rbegin(); | 265 driver_version = driver_version.substr(0, pos); |
265 while (pieces.rend() - it > 2) { | |
266 bool parsed = re2::RE2::FullMatch(*it, pattern, &driver_version); | |
267 if (parsed) | |
268 break; | |
269 ++it; | |
270 } | |
271 | 266 |
272 if (driver_version.empty()) | 267 gpu_info->driver_vendor = pieces[1]; |
273 return kCollectInfoNonFatalFailure; | |
274 | |
275 gpu_info->driver_vendor = *(++it); | |
276 gpu_info->driver_version = driver_version; | 268 gpu_info->driver_version = driver_version; |
277 return kCollectInfoSuccess; | 269 return kCollectInfoSuccess; |
278 } | 270 } |
279 | 271 |
280 void MergeGPUInfo(GPUInfo* basic_gpu_info, | 272 void MergeGPUInfo(GPUInfo* basic_gpu_info, |
281 const GPUInfo& context_gpu_info) { | 273 const GPUInfo& context_gpu_info) { |
282 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); | 274 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); |
283 } | 275 } |
284 | 276 |
285 } // namespace gpu | 277 } // namespace gpu |
OLD | NEW |