Add ICU message format support
[chromium-blink-merge.git] / gpu / config / gpu_info.h
blobd6f61fd60f79e027655477675c041937c3919cd0
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.
5 #ifndef GPU_CONFIG_GPU_INFO_H_
6 #define GPU_CONFIG_GPU_INFO_H_
8 // Provides access to the GPU information for the system
9 // on which chrome is currently running.
11 #include <string>
12 #include <vector>
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/gpu_export.h"
20 #include "ui/gfx/geometry/size.h"
22 namespace gpu {
24 // Result for the various Collect*Info* functions below.
25 // Fatal failures are for cases where we can't create a context at all or
26 // something, making the use of the GPU impossible.
27 // Non-fatal failures are for cases where we could gather most info, but maybe
28 // some is missing (e.g. unable to parse a version string or to detect the exact
29 // model).
30 enum CollectInfoResult {
31 kCollectInfoNone = 0,
32 kCollectInfoSuccess = 1,
33 kCollectInfoNonFatalFailure = 2,
34 kCollectInfoFatalFailure = 3
37 // Video profile. This *must* match media::VideoCodecProfile.
38 enum VideoCodecProfile {
39 VIDEO_CODEC_PROFILE_UNKNOWN = -1,
40 VIDEO_CODEC_PROFILE_MIN = VIDEO_CODEC_PROFILE_UNKNOWN,
41 H264PROFILE_BASELINE = 0,
42 H264PROFILE_MAIN = 1,
43 H264PROFILE_EXTENDED = 2,
44 H264PROFILE_HIGH = 3,
45 H264PROFILE_HIGH10PROFILE = 4,
46 H264PROFILE_HIGH422PROFILE = 5,
47 H264PROFILE_HIGH444PREDICTIVEPROFILE = 6,
48 H264PROFILE_SCALABLEBASELINE = 7,
49 H264PROFILE_SCALABLEHIGH = 8,
50 H264PROFILE_STEREOHIGH = 9,
51 H264PROFILE_MULTIVIEWHIGH = 10,
52 VP8PROFILE_ANY = 11,
53 VP9PROFILE_ANY = 12,
54 VIDEO_CODEC_PROFILE_MAX = VP9PROFILE_ANY,
57 // Specification of a decoding profile supported by a hardware decoder.
58 struct GPU_EXPORT VideoDecodeAcceleratorSupportedProfile {
59 VideoCodecProfile profile;
60 gfx::Size max_resolution;
61 gfx::Size min_resolution;
63 using VideoDecodeAcceleratorSupportedProfiles =
64 std::vector<VideoDecodeAcceleratorSupportedProfile>;
66 // Specification of an encoding profile supported by a hardware encoder.
67 struct GPU_EXPORT VideoEncodeAcceleratorSupportedProfile {
68 VideoCodecProfile profile;
69 gfx::Size max_resolution;
70 uint32 max_framerate_numerator;
71 uint32 max_framerate_denominator;
73 using VideoEncodeAcceleratorSupportedProfiles =
74 std::vector<VideoEncodeAcceleratorSupportedProfile>;
76 struct GPU_EXPORT GPUInfo {
77 struct GPU_EXPORT GPUDevice {
78 GPUDevice();
79 ~GPUDevice();
81 // The DWORD (uint32) representing the graphics card vendor id.
82 uint32 vendor_id;
84 // The DWORD (uint32) representing the graphics card device id.
85 // Device ids are unique to vendor, not to one another.
86 uint32 device_id;
88 // Whether this GPU is the currently used one.
89 // Currently this field is only supported and meaningful on OS X.
90 bool active;
92 // The strings that describe the GPU.
93 // In Linux these strings are obtained through libpci.
94 // In Win/MacOSX, these two strings are not filled at the moment.
95 // In Android, these are respectively GL_VENDOR and GL_RENDERER.
96 std::string vendor_string;
97 std::string device_string;
100 GPUInfo();
101 ~GPUInfo();
103 bool SupportsAccelerated2dCanvas() const {
104 return !can_lose_context && !software_rendering;
107 // The amount of time taken to get from the process starting to the message
108 // loop being pumped.
109 base::TimeDelta initialization_time;
111 // Computer has NVIDIA Optimus
112 bool optimus;
114 // Computer has AMD Dynamic Switchable Graphics
115 bool amd_switchable;
117 // Lenovo dCute is installed. http://crbug.com/181665.
118 bool lenovo_dcute;
120 // Version of DisplayLink driver installed. Zero if not installed.
121 // http://crbug.com/177611.
122 Version display_link_version;
124 // Primary GPU, for exmaple, the discrete GPU in a dual GPU machine.
125 GPUDevice gpu;
127 // Secondary GPUs, for example, the integrated GPU in a dual GPU machine.
128 std::vector<GPUDevice> secondary_gpus;
130 // On Windows, the unique identifier of the adapter the GPU process uses.
131 // The default is zero, which makes the browser process create its D3D device
132 // on the primary adapter. Note that the primary adapter can change at any
133 // time so it is better to specify a particular LUID. Note that valid LUIDs
134 // are always non-zero.
135 uint64 adapter_luid;
137 // The vendor of the graphics driver currently installed.
138 std::string driver_vendor;
140 // The version of the graphics driver currently installed.
141 std::string driver_version;
143 // The date of the graphics driver currently installed.
144 std::string driver_date;
146 // The version of the pixel/fragment shader used by the gpu.
147 std::string pixel_shader_version;
149 // The version of the vertex shader used by the gpu.
150 std::string vertex_shader_version;
152 // The maximum multisapling sample count, either through ES3 or
153 // EXT_multisampled_render_to_texture MSAA.
154 std::string max_msaa_samples;
156 // The machine model identifier. They can contain any character, including
157 // whitespaces. Currently it is supported on MacOSX and Android.
158 // Android examples: "Naxus 5", "XT1032".
159 // On MacOSX, the version is stripped out of the model identifier, for
160 // example, the original identifier is "MacBookPro7,2", and we put
161 // "MacBookPro" as machine_model_name, and "7.2" as machine_model_version.
162 std::string machine_model_name;
164 // The version of the machine model. Currently it is supported on MacOSX.
165 // See machine_model_name's comment.
166 std::string machine_model_version;
168 // The GL_VERSION string.
169 std::string gl_version;
171 // The GL_VENDOR string.
172 std::string gl_vendor;
174 // The GL_RENDERER string.
175 std::string gl_renderer;
177 // The GL_EXTENSIONS string.
178 std::string gl_extensions;
180 // GL window system binding vendor. "" if not available.
181 std::string gl_ws_vendor;
183 // GL window system binding version. "" if not available.
184 std::string gl_ws_version;
186 // GL window system binding extensions. "" if not available.
187 std::string gl_ws_extensions;
189 // GL reset notification strategy as defined by GL_ARB_robustness. 0 if GPU
190 // reset detection or notification not available.
191 uint32 gl_reset_notification_strategy;
193 // The device semantics, i.e. whether the Vista and Windows 7 specific
194 // semantics are available.
195 bool can_lose_context;
197 bool software_rendering;
199 // Whether the driver uses direct rendering. True on most platforms, false on
200 // X11 when using remote X.
201 bool direct_rendering;
203 // Whether the gpu process is running in a sandbox.
204 bool sandboxed;
206 // Number of GPU process crashes recorded.
207 int process_crash_count;
209 // True if the GPU is running in the browser process instead of its own.
210 bool in_process_gpu;
212 // The state of whether the basic/context/DxDiagnostics info is collected and
213 // if the collection fails or not.
214 CollectInfoResult basic_info_state;
215 CollectInfoResult context_info_state;
216 #if defined(OS_WIN)
217 CollectInfoResult dx_diagnostics_info_state;
219 // The information returned by the DirectX Diagnostics Tool.
220 DxDiagNode dx_diagnostics;
221 #endif
223 VideoDecodeAcceleratorSupportedProfiles
224 video_decode_accelerator_supported_profiles;
225 VideoEncodeAcceleratorSupportedProfiles
226 video_encode_accelerator_supported_profiles;
227 bool jpeg_decode_accelerator_supported;
229 // Note: when adding new members, please remember to update EnumerateFields
230 // in gpu_info.cc.
232 // In conjunction with EnumerateFields, this allows the embedder to
233 // enumerate the values in this structure without having to embed
234 // references to its specific member variables. This simplifies the
235 // addition of new fields to this type.
236 class Enumerator {
237 public:
238 // The following methods apply to the "current" object. Initially this
239 // is the root object, but calls to BeginGPUDevice/EndGPUDevice and
240 // BeginAuxAttributes/EndAuxAttributes change the object to which these
241 // calls should apply.
242 virtual void AddInt64(const char* name, int64 value) = 0;
243 virtual void AddInt(const char* name, int value) = 0;
244 virtual void AddString(const char* name, const std::string& value) = 0;
245 virtual void AddBool(const char* name, bool value) = 0;
246 virtual void AddTimeDeltaInSecondsF(const char* name,
247 const base::TimeDelta& value) = 0;
249 // Markers indicating that a GPUDevice is being described.
250 virtual void BeginGPUDevice() = 0;
251 virtual void EndGPUDevice() = 0;
253 // Markers indicating that a VideoDecodeAcceleratorSupportedProfile is
254 // being described.
255 virtual void BeginVideoDecodeAcceleratorSupportedProfile() = 0;
256 virtual void EndVideoDecodeAcceleratorSupportedProfile() = 0;
258 // Markers indicating that a VideoEncodeAcceleratorSupportedProfile is
259 // being described.
260 virtual void BeginVideoEncodeAcceleratorSupportedProfile() = 0;
261 virtual void EndVideoEncodeAcceleratorSupportedProfile() = 0;
263 // Markers indicating that "auxiliary" attributes of the GPUInfo
264 // (according to the DevTools protocol) are being described.
265 virtual void BeginAuxAttributes() = 0;
266 virtual void EndAuxAttributes() = 0;
268 protected:
269 virtual ~Enumerator() {}
272 // Outputs the fields in this structure to the provided enumerator.
273 void EnumerateFields(Enumerator* enumerator) const;
276 } // namespace gpu
278 #endif // GPU_CONFIG_GPU_INFO_H_