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

Unified 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: Make it generic 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gpu/config/gpu_info_collector_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/config/gpu_info_collector_linux.cc
diff --git a/gpu/config/gpu_info_collector_linux.cc b/gpu/config/gpu_info_collector_linux.cc
index 050c33d246d391afb8edea0fbd0ed753fdd4c8ee..c16ee9cd8614905f48bfba62e9d52735ae4b7d87 100644
--- a/gpu/config/gpu_info_collector_linux.cc
+++ b/gpu/config/gpu_info_collector_linux.cc
@@ -247,8 +247,6 @@ CollectInfoResult CollectDriverInfoGL(GPUInfo* gpu_info) {
DCHECK(gpu_info);
std::string gl_version = gpu_info->gl_version;
- if (base::StartsWith(gl_version, "OpenGL ES", base::CompareCase::SENSITIVE))
- gl_version = gl_version.substr(10);
std::vector<std::string> pieces = base::SplitString(
gl_version, base::kWhitespaceASCII, base::KEEP_WHITESPACE,
base::SPLIT_WANT_NONEMPTY);
@@ -257,14 +255,23 @@ CollectInfoResult CollectDriverInfoGL(GPUInfo* gpu_info) {
if (pieces.size() < 3)
return kCollectInfoNonFatalFailure;
- std::string driver_version = pieces[2];
- size_t pos = driver_version.find_first_not_of("0123456789.");
- if (pos == 0)
+ // Search from the end for the first piece that contains at least one digit.
Ken Russell (switch to Gerrit) 2016/07/21 23:54:54 Why not just use a regexp? Something which matches
Julien Isorce Samsung 2016/07/22 07:38:29 Done.
+ // But assume the driver version cannot be the first two pieces.
+ std::string driver_version;
+ auto it = pieces.rbegin();
+ while (it + 2 != pieces.rend()) {
Ken Russell (switch to Gerrit) 2016/07/21 23:54:54 This looks risky. Please do something else which i
Julien Isorce Samsung 2016/07/22 07:38:29 Done.
+ size_t pos = it->find_first_not_of("0123456789.");
+ if (pos != 0) {
+ driver_version = it->substr(0, pos);
+ break;
+ }
+ ++it;
+ }
+
+ if (driver_version.empty())
return kCollectInfoNonFatalFailure;
- if (pos != std::string::npos)
- driver_version = driver_version.substr(0, pos);
- gpu_info->driver_vendor = pieces[1];
+ gpu_info->driver_vendor = *(++it);
gpu_info->driver_version = driver_version;
return kCollectInfoSuccess;
}
« 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