[SyncFS] Build indexes from FileTracker entries on disk.
[chromium-blink-merge.git] / gpu / config / gpu_info_collector_ozone.cc
blobb8dac8478af2e5fb37c3e24809de0c12f45ba671
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "gpu/config/gpu_info_collector.h"
7 #include "base/command_line.h"
8 #include "base/debug/trace_event.h"
9 #include "base/logging.h"
10 #include "base/strings/string_split.h"
11 #include "ui/gl/gl_surface_egl.h"
12 #include "ui/gl/gl_switches.h"
14 namespace gpu {
16 CollectInfoResult CollectContextGraphicsInfo(GPUInfo* gpu_info) {
17 DCHECK(gpu_info);
18 TRACE_EVENT0("gpu", "gpu_info_collector::CollectGraphicsInfo");
19 CollectInfoResult result = CollectGraphicsInfoGL(gpu_info);
20 if (CommandLine::ForCurrentProcess()->HasSwitch(
21 switches::kGpuNoContextLost)) {
22 gpu_info->can_lose_context = false;
23 } else {
24 #if defined(OS_CHROMEOS)
25 gpu_info->can_lose_context = false;
26 #else
27 gpu_info->can_lose_context =
28 !gfx::GLSurfaceEGL::IsCreateContextRobustnessSupported();
29 #endif
32 gpu_info->finalized = true;
33 return result;
36 GpuIDResult CollectGpuID(uint32* vendor_id, uint32* device_id) {
37 DCHECK(vendor_id && device_id);
38 *vendor_id = 0;
39 *device_id = 0;
40 return kGpuIDNotSupported;
43 CollectInfoResult CollectBasicGraphicsInfo(GPUInfo* gpu_info) {
44 gpu_info->can_lose_context = false;
45 return kCollectInfoSuccess;
48 CollectInfoResult CollectDriverInfoGL(GPUInfo* gpu_info) {
49 DCHECK(gpu_info);
50 // Extract driver vendor, version from a string like:
51 // "OpenGL ES 3.0 V@6.0 AU@ (CL@2946718)"
52 size_t begin = gpu_info->gl_version.find_first_of("0123456789");
53 if (begin == std::string::npos)
54 return kCollectInfoNonFatalFailure;
56 std::string sub_string = gpu_info->gl_version.substr(begin);
57 std::vector<std::string> pieces;
58 base::SplitStringAlongWhitespace(sub_string, &pieces);
59 if (pieces.size() < 3)
60 return kCollectInfoNonFatalFailure;
62 std::string driver_version = pieces[2];
63 size_t pos = driver_version.find_first_not_of("0123456789.");
64 if (pos == 0)
65 return kCollectInfoNonFatalFailure;
67 if (pos != std::string::npos)
68 driver_version = driver_version.substr(0, pos);
70 gpu_info->driver_vendor = pieces[1];
71 gpu_info->driver_version = driver_version;
72 return kCollectInfoSuccess;
75 void MergeGPUInfo(GPUInfo* basic_gpu_info,
76 const GPUInfo& context_gpu_info) {
77 MergeGPUInfoGL(basic_gpu_info, context_gpu_info);
80 } // namespace gpu