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

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: Just rebase Created 4 years, 4 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 | « content/test/gpu/page_sets/gpu_process_tests.py ('k') | 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..1f380474f792e134d7f7589418e34ebc9a65e220 100644
--- a/gpu/config/gpu_info_collector_linux.cc
+++ b/gpu/config/gpu_info_collector_linux.cc
@@ -19,6 +19,8 @@
#include "base/strings/string_util.h"
#include "base/trace_event/trace_event.h"
#include "gpu/config/gpu_info_collector.h"
+#include "gpu/config/gpu_switches.h"
+#include "third_party/re2/src/re2/re2.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_implementation.h"
@@ -246,9 +248,15 @@ CollectInfoResult CollectBasicGraphicsInfo(GPUInfo* gpu_info) {
CollectInfoResult CollectDriverInfoGL(GPUInfo* gpu_info) {
DCHECK(gpu_info);
+ // Driver vendor and version are always expected to be extracted from the
+ // testing gl version.
+ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kGpuTestingGLVersion) &&
+ !gpu_info->driver_vendor.empty() && !gpu_info->driver_version.empty()) {
+ return kCollectInfoSuccess;
+ }
+
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 +265,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 starts with major.minor or
+ // major.minor.micro but assume the driver version cannot be in the first two
+ // pieces.
+ re2::RE2 pattern("([\\d]+\\.[\\d]+(\\.[\\d]+)?).*");
+ std::string driver_version;
+ auto it = pieces.rbegin();
+ while (pieces.rend() - it > 2) {
+ bool parsed = re2::RE2::FullMatch(*it, pattern, &driver_version);
+ if (parsed)
+ 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 | « content/test/gpu/page_sets/gpu_process_tests.py ('k') | gpu/config/gpu_info_collector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698