3828b44be4995f4530ede924b713a754cadf7c10
[platform/framework/web/crosswalk.git] / src / gpu / config / gpu_info.h
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
3 // found in the LICENSE file.
4
5 #ifndef GPU_CONFIG_GPU_INFO_H_
6 #define GPU_CONFIG_GPU_INFO_H_
7
8 // Provides access to the GPU information for the system
9 // on which chrome is currently running.
10
11 #include <string>
12 #include <vector>
13
14 #include "base/basictypes.h"
15 #include "base/time/time.h"
16 #include "base/version.h"
17 #include "build/build_config.h"
18 #include "gpu/config/dx_diag_node.h"
19 #include "gpu/config/gpu_performance_stats.h"
20 #include "gpu/gpu_export.h"
21
22 namespace gpu {
23
24 struct GPU_EXPORT GPUInfo {
25   struct GPU_EXPORT GPUDevice {
26     GPUDevice();
27     ~GPUDevice();
28
29     // The DWORD (uint32) representing the graphics card vendor id.
30     uint32 vendor_id;
31
32     // The DWORD (uint32) representing the graphics card device id.
33     // Device ids are unique to vendor, not to one another.
34     uint32 device_id;
35
36     // The strings that describe the GPU.
37     // In Linux these strings are obtained through libpci.
38     // In Win/MacOSX, these two strings are not filled at the moment.
39     // In Android, these are respectively GL_VENDOR and GL_RENDERER.
40     std::string vendor_string;
41     std::string device_string;
42   };
43
44   GPUInfo();
45   ~GPUInfo();
46
47   bool SupportsAccelerated2dCanvas() const {
48     return !can_lose_context && !software_rendering;
49   }
50
51   // Whether more GPUInfo fields might be collected in the future.
52   bool finalized;
53
54   // The amount of time taken to get from the process starting to the message
55   // loop being pumped.
56   base::TimeDelta initialization_time;
57
58   // Computer has NVIDIA Optimus
59   bool optimus;
60
61   // Computer has AMD Dynamic Switchable Graphics
62   bool amd_switchable;
63
64   // Lenovo dCute is installed. http://crbug.com/181665.
65   bool lenovo_dcute;
66
67   // Version of DisplayLink driver installed. Zero if not installed.
68   // http://crbug.com/177611.
69   Version display_link_version;
70
71   // Primary GPU, for exmaple, the discrete GPU in a dual GPU machine.
72   GPUDevice gpu;
73
74   // Secondary GPUs, for example, the integrated GPU in a dual GPU machine.
75   std::vector<GPUDevice> secondary_gpus;
76
77   // On Windows, the unique identifier of the adapter the GPU process uses.
78   // The default is zero, which makes the browser process create its D3D device
79   // on the primary adapter. Note that the primary adapter can change at any
80   // time so it is better to specify a particular LUID. Note that valid LUIDs
81   // are always non-zero.
82   uint64 adapter_luid;
83
84   // The vendor of the graphics driver currently installed.
85   std::string driver_vendor;
86
87   // The version of the graphics driver currently installed.
88   std::string driver_version;
89
90   // The date of the graphics driver currently installed.
91   std::string driver_date;
92
93   // The version of the pixel/fragment shader used by the gpu.
94   std::string pixel_shader_version;
95
96   // The version of the vertex shader used by the gpu.
97   std::string vertex_shader_version;
98
99   // The machine model identifier with format "name major.minor".
100   // Name should not contain any whitespaces.
101   std::string machine_model;
102
103   // The version of OpenGL we are using.
104   // TODO(zmo): should be able to tell if it's GL or GLES.
105   std::string gl_version;
106
107   // The GL_VERSION string.  "" if we are not using OpenGL.
108   std::string gl_version_string;
109
110   // The GL_VENDOR string.  "" if we are not using OpenGL.
111   std::string gl_vendor;
112
113   // The GL_RENDERER string.  "" if we are not using OpenGL.
114   std::string gl_renderer;
115
116   // The GL_EXTENSIONS string.  "" if we are not using OpenGL.
117   std::string gl_extensions;
118
119   // GL window system binding vendor.  "" if not available.
120   std::string gl_ws_vendor;
121
122   // GL window system binding version.  "" if not available.
123   std::string gl_ws_version;
124
125   // GL window system binding extensions.  "" if not available.
126   std::string gl_ws_extensions;
127
128   // GL reset notification strategy as defined by GL_ARB_robustness. 0 if GPU
129   // reset detection or notification not available.
130   uint32 gl_reset_notification_strategy;
131
132   // The device semantics, i.e. whether the Vista and Windows 7 specific
133   // semantics are available.
134   bool can_lose_context;
135
136   // By default all values are 0.
137   GpuPerformanceStats performance_stats;
138
139   bool software_rendering;
140
141   // Whether the driver uses direct rendering. True on most platforms, false on
142   // X11 when using remote X.
143   bool direct_rendering;
144
145   // Whether the gpu process is running in a sandbox.
146   bool sandboxed;
147
148 #if defined(OS_WIN)
149   // The information returned by the DirectX Diagnostics Tool.
150   DxDiagNode dx_diagnostics;
151 #endif
152   // Note: when adding new members, please remember to update EnumerateFields
153   // in gpu_info.cc.
154
155   // In conjunction with EnumerateFields, this allows the embedder to
156   // enumerate the values in this structure without having to embed
157   // references to its specific member variables. This simplifies the
158   // addition of new fields to this type.
159   class Enumerator {
160    public:
161     // The following methods apply to the "current" object. Initially this
162     // is the root object, but calls to BeginGPUDevice/EndGPUDevice and
163     // BeginAuxAttributes/EndAuxAttributes change the object to which these
164     // calls should apply.
165     virtual void AddInt64(const char* name, int64 value) = 0;
166     virtual void AddInt(const char* name, int value) = 0;
167     virtual void AddString(const char* name, const std::string& value) = 0;
168     virtual void AddBool(const char* name, bool value) = 0;
169     virtual void AddTimeDeltaInSecondsF(const char* name,
170                                         const base::TimeDelta& value) = 0;
171
172     // Markers indicating that a GPUDevice is being described.
173     virtual void BeginGPUDevice() = 0;
174     virtual void EndGPUDevice() = 0;
175
176     // Markers indicating that "auxiliary" attributes of the GPUInfo
177     // (according to the DevTools protocol) are being described.
178     virtual void BeginAuxAttributes() = 0;
179     virtual void EndAuxAttributes() = 0;
180
181    protected:
182     virtual ~Enumerator() {}
183   };
184
185   // Outputs the fields in this structure to the provided enumerator.
186   void EnumerateFields(Enumerator* enumerator) const;
187 };
188
189 }  // namespace gpu
190
191 #endif  // GPU_CONFIG_GPU_INFO_H_