OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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.h" | 5 #include "gpu/config/gpu_info_collector.h" |
6 | 6 |
7 #include "base/android/build_info.h" | 7 #include "base/android/build_info.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.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_piece.h" | 11 #include "base/strings/string_piece.h" |
12 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "ui/gl/gl_bindings.h" | 14 #include "ui/gl/gl_bindings.h" |
15 #include "ui/gl/gl_context.h" | 15 #include "ui/gl/gl_context.h" |
16 #include "ui/gl/gl_surface.h" | 16 #include "ui/gl/gl_surface.h" |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 std::string GetDriverVersionFromString(const std::string& version_string) { | 20 std::string GetDriverVersionFromString(const std::string& version_string) { |
21 // Extract driver version from the second number in a string like: | 21 // We expect that android GL_VERSION strings will be of a form |
22 // "OpenGL ES 2.0 V@6.0 AU@ (CL@2946718)" | 22 // similar to: "OpenGL ES 2.0 V@6.0 AU@ (CL@2946718)" where the |
23 | 23 // first match to [0-9][0-9.]* is the OpenGL ES version number, and |
24 // Exclude first "2.0". | 24 // the second match to [0-9][0-9.]* is the driver version (in this |
| 25 // case, 6.0). |
| 26 // It is currently assumed that the driver version has at least one |
| 27 // period in it, and only the first two components are significant. |
25 size_t begin = version_string.find_first_of("0123456789"); | 28 size_t begin = version_string.find_first_of("0123456789"); |
26 if (begin == std::string::npos) | 29 if (begin == std::string::npos) |
27 return "0"; | 30 return "0"; |
28 size_t end = version_string.find_first_not_of("01234567890.", begin); | 31 size_t end = version_string.find_first_not_of("01234567890.", begin); |
29 | 32 |
30 // Extract number of the form "%d.%d" | 33 // Extract number of the form "%d.%d" |
31 begin = version_string.find_first_of("0123456789", end); | 34 begin = version_string.find_first_of("0123456789", end); |
32 if (begin == std::string::npos) | 35 if (begin == std::string::npos) |
33 return "0"; | 36 return "0"; |
34 end = version_string.find_first_not_of("01234567890.", begin); | 37 end = version_string.find_first_not_of("01234567890.", begin); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 gpu_info->gpu.device_string = gpu_info->gl_renderer; | 120 gpu_info->gpu.device_string = gpu_info->gl_renderer; |
118 return kCollectInfoSuccess; | 121 return kCollectInfoSuccess; |
119 } | 122 } |
120 | 123 |
121 void MergeGPUInfo(GPUInfo* basic_gpu_info, | 124 void MergeGPUInfo(GPUInfo* basic_gpu_info, |
122 const GPUInfo& context_gpu_info) { | 125 const GPUInfo& context_gpu_info) { |
123 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); | 126 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); |
124 } | 127 } |
125 | 128 |
126 } // namespace gpu | 129 } // namespace gpu |
OLD | NEW |