Don't preload rarely seen large images
[chromium-blink-merge.git] / gpu / config / gpu_info.cc
blob85d26fb584ad4bd2ca795dfff2ae864309ee5ffd
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 #include "gpu/config/gpu_info.h"
7 namespace {
9 void EnumerateGPUDevice(const gpu::GPUInfo::GPUDevice& device,
10 gpu::GPUInfo::Enumerator* enumerator) {
11 enumerator->BeginGPUDevice();
12 enumerator->AddInt("vendorId", device.vendor_id);
13 enumerator->AddInt("deviceId", device.device_id);
14 enumerator->AddBool("active", device.active);
15 enumerator->AddString("vendorString", device.vendor_string);
16 enumerator->AddString("deviceString", device.device_string);
17 enumerator->EndGPUDevice();
20 void EnumerateVideoDecodeAcceleratorSupportedProfile(
21 const gpu::VideoDecodeAcceleratorSupportedProfile& profile,
22 gpu::GPUInfo::Enumerator* enumerator) {
23 enumerator->BeginVideoDecodeAcceleratorSupportedProfile();
24 enumerator->AddInt("profile", profile.profile);
25 enumerator->AddInt("maxResolutionWidth", profile.max_resolution.width());
26 enumerator->AddInt("maxResolutionHeight", profile.max_resolution.height());
27 enumerator->AddInt("minResolutionWidth", profile.min_resolution.width());
28 enumerator->AddInt("minResolutionHeight", profile.min_resolution.height());
29 enumerator->EndVideoDecodeAcceleratorSupportedProfile();
32 void EnumerateVideoEncodeAcceleratorSupportedProfile(
33 const gpu::VideoEncodeAcceleratorSupportedProfile& profile,
34 gpu::GPUInfo::Enumerator* enumerator) {
35 enumerator->BeginVideoEncodeAcceleratorSupportedProfile();
36 enumerator->AddInt("profile", profile.profile);
37 enumerator->AddInt("maxResolutionWidth", profile.max_resolution.width());
38 enumerator->AddInt("maxResolutionHeight", profile.max_resolution.height());
39 enumerator->AddInt("maxFramerateNumerator", profile.max_framerate_numerator);
40 enumerator->AddInt("maxFramerateDenominator",
41 profile.max_framerate_denominator);
42 enumerator->EndVideoEncodeAcceleratorSupportedProfile();
45 } // namespace
47 namespace gpu {
49 GPUInfo::GPUDevice::GPUDevice()
50 : vendor_id(0),
51 device_id(0),
52 active(false) {
55 GPUInfo::GPUDevice::~GPUDevice() { }
57 GPUInfo::GPUInfo()
58 : optimus(false),
59 amd_switchable(false),
60 lenovo_dcute(false),
61 adapter_luid(0),
62 gl_reset_notification_strategy(0),
63 can_lose_context(false),
64 software_rendering(false),
65 direct_rendering(true),
66 sandboxed(false),
67 process_crash_count(0),
68 basic_info_state(kCollectInfoNone),
69 #if defined(OS_WIN)
70 context_info_state(kCollectInfoNone),
71 dx_diagnostics_info_state(kCollectInfoNone) {
72 #else
73 context_info_state(kCollectInfoNone) {
74 #endif
77 GPUInfo::~GPUInfo() { }
79 void GPUInfo::EnumerateFields(Enumerator* enumerator) const {
80 struct GPUInfoKnownFields {
81 base::TimeDelta initialization_time;
82 bool optimus;
83 bool amd_switchable;
84 bool lenovo_dcute;
85 Version display_link_version;
86 GPUDevice gpu;
87 std::vector<GPUDevice> secondary_gpus;
88 uint64 adapter_luid;
89 std::string driver_vendor;
90 std::string driver_version;
91 std::string driver_date;
92 std::string pixel_shader_version;
93 std::string vertex_shader_version;
94 std::string max_msaa_samples;
95 std::string machine_model_name;
96 std::string machine_model_version;
97 std::string gl_version_string;
98 std::string gl_vendor;
99 std::string gl_renderer;
100 std::string gl_extensions;
101 std::string gl_ws_vendor;
102 std::string gl_ws_version;
103 std::string gl_ws_extensions;
104 uint32 gl_reset_notification_strategy;
105 bool can_lose_context;
106 bool software_rendering;
107 bool direct_rendering;
108 bool sandboxed;
109 int process_crash_count;
110 CollectInfoResult basic_info_state;
111 CollectInfoResult context_info_state;
112 #if defined(OS_WIN)
113 CollectInfoResult dx_diagnostics_info_state;
114 DxDiagNode dx_diagnostics;
115 #endif
116 VideoDecodeAcceleratorSupportedProfiles
117 video_decode_accelerator_supported_profiles;
118 VideoEncodeAcceleratorSupportedProfiles
119 video_encode_accelerator_supported_profiles;
122 // If this assert fails then most likely something below needs to be updated.
123 // Note that this assert is only approximate. If a new field is added to
124 // GPUInfo which fits within the current padding then it will not be caught.
125 static_assert(
126 sizeof(GPUInfo) == sizeof(GPUInfoKnownFields),
127 "fields have changed in GPUInfo, GPUInfoKnownFields must be updated");
129 // Required fields (according to DevTools protocol) first.
130 enumerator->AddString("machineModelName", machine_model_name);
131 enumerator->AddString("machineModelVersion", machine_model_version);
132 EnumerateGPUDevice(gpu, enumerator);
133 for (const auto& secondary_gpu: secondary_gpus)
134 EnumerateGPUDevice(secondary_gpu, enumerator);
136 enumerator->BeginAuxAttributes();
137 enumerator->AddTimeDeltaInSecondsF("initializationTime",
138 initialization_time);
139 enumerator->AddBool("optimus", optimus);
140 enumerator->AddBool("amdSwitchable", amd_switchable);
141 enumerator->AddBool("lenovoDcute", lenovo_dcute);
142 if (display_link_version.IsValid()) {
143 enumerator->AddString("displayLinkVersion",
144 display_link_version.GetString());
146 enumerator->AddInt64("adapterLuid", adapter_luid);
147 enumerator->AddString("driverVendor", driver_vendor);
148 enumerator->AddString("driverVersion", driver_version);
149 enumerator->AddString("driverDate", driver_date);
150 enumerator->AddString("pixelShaderVersion", pixel_shader_version);
151 enumerator->AddString("vertexShaderVersion", vertex_shader_version);
152 enumerator->AddString("maxMsaaSamples", max_msaa_samples);
153 enumerator->AddString("glVersion", gl_version);
154 enumerator->AddString("glVendor", gl_vendor);
155 enumerator->AddString("glRenderer", gl_renderer);
156 enumerator->AddString("glExtensions", gl_extensions);
157 enumerator->AddString("glWsVendor", gl_ws_vendor);
158 enumerator->AddString("glWsVersion", gl_ws_version);
159 enumerator->AddString("glWsExtensions", gl_ws_extensions);
160 enumerator->AddInt(
161 "glResetNotificationStrategy",
162 static_cast<int>(gl_reset_notification_strategy));
163 enumerator->AddBool("can_lose_context", can_lose_context);
164 // TODO(kbr): add performance_stats.
165 enumerator->AddBool("softwareRendering", software_rendering);
166 enumerator->AddBool("directRendering", direct_rendering);
167 enumerator->AddBool("sandboxed", sandboxed);
168 enumerator->AddInt("processCrashCount", process_crash_count);
169 enumerator->AddInt("basicInfoState", basic_info_state);
170 enumerator->AddInt("contextInfoState", context_info_state);
171 #if defined(OS_WIN)
172 enumerator->AddInt("DxDiagnosticsInfoState", dx_diagnostics_info_state);
173 #endif
174 // TODO(kbr): add dx_diagnostics on Windows.
175 for (const auto& profile : video_decode_accelerator_supported_profiles)
176 EnumerateVideoDecodeAcceleratorSupportedProfile(profile, enumerator);
177 for (const auto& profile : video_encode_accelerator_supported_profiles)
178 EnumerateVideoEncodeAcceleratorSupportedProfile(profile, enumerator);
179 enumerator->EndAuxAttributes();
182 } // namespace gpu