Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: gpu/config/gpu_info_collector_linux.cc

Issue 2153373002: On Linux rework driver_version/vendor extraction from gl version (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and add unit test Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | gpu/config/gpu_info_collector_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 } 240 }
241 241
242 gpu_info->basic_info_state = result; 242 gpu_info->basic_info_state = result;
243 return result; 243 return result;
244 } 244 }
245 245
246 CollectInfoResult CollectDriverInfoGL(GPUInfo* gpu_info) { 246 CollectInfoResult CollectDriverInfoGL(GPUInfo* gpu_info) {
247 DCHECK(gpu_info); 247 DCHECK(gpu_info);
248 248
249 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)) 250 if (base::StartsWith(gl_version, "OpenGL ES", base::CompareCase::SENSITIVE)) {
251 gl_version = gl_version.substr(10); 251 gl_version = gl_version.substr(10);
252 } else {
253 std::string core_profile = "(Core Profile)";
Zhenyao Mo 2016/07/21 13:30:44 I guess this is ok, but a more generic fix is you
Julien Isorce Samsung 2016/07/21 13:56:36 Good idea, thx, and driver_vendor would be the las
Zhenyao Mo 2016/07/21 13:59:47 right
254 size_t position = gl_version.find(core_profile);
255 if (position != std::string::npos)
256 gl_version.erase(position, core_profile.length());
257 }
258
252 std::vector<std::string> pieces = base::SplitString( 259 std::vector<std::string> pieces = base::SplitString(
253 gl_version, base::kWhitespaceASCII, base::KEEP_WHITESPACE, 260 gl_version, base::kWhitespaceASCII, base::KEEP_WHITESPACE,
254 base::SPLIT_WANT_NONEMPTY); 261 base::SPLIT_WANT_NONEMPTY);
255 // In linux, the gl version string might be in the format of 262 // In linux, the gl version string might be in the format of
256 // GLVersion DriverVendor DriverVersion 263 // GLVersion DriverVendor DriverVersion
257 if (pieces.size() < 3) 264 if (pieces.size() < 3)
258 return kCollectInfoNonFatalFailure; 265 return kCollectInfoNonFatalFailure;
259 266
260 std::string driver_version = pieces[2]; 267 std::string driver_version = pieces[2];
261 size_t pos = driver_version.find_first_not_of("0123456789."); 268 size_t pos = driver_version.find_first_not_of("0123456789.");
262 if (pos == 0) 269 if (pos == 0)
263 return kCollectInfoNonFatalFailure; 270 return kCollectInfoNonFatalFailure;
264 if (pos != std::string::npos) 271 if (pos != std::string::npos)
265 driver_version = driver_version.substr(0, pos); 272 driver_version = driver_version.substr(0, pos);
266 273
267 gpu_info->driver_vendor = pieces[1]; 274 gpu_info->driver_vendor = pieces[1];
268 gpu_info->driver_version = driver_version; 275 gpu_info->driver_version = driver_version;
269 return kCollectInfoSuccess; 276 return kCollectInfoSuccess;
270 } 277 }
271 278
272 void MergeGPUInfo(GPUInfo* basic_gpu_info, 279 void MergeGPUInfo(GPUInfo* basic_gpu_info,
273 const GPUInfo& context_gpu_info) { 280 const GPUInfo& context_gpu_info) {
274 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); 281 MergeGPUInfoGL(basic_gpu_info, context_gpu_info);
275 } 282 }
276 283
277 } // namespace gpu 284 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | gpu/config/gpu_info_collector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698