Bug 1073336 part 5 - Add AnimationPlayerCollection::PlayerUpdated; r=dbaron
[gecko.git] / widget / GfxDriverInfo.cpp
blobbe41415d6fad847575084712b7af679759de850f
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "GfxDriverInfo.h"
8 #include "nsIGfxInfo.h"
9 #include "nsTArray.h"
11 using namespace mozilla::widget;
13 int32_t GfxDriverInfo::allFeatures = 0;
14 uint64_t GfxDriverInfo::allDriverVersions = ~(uint64_t(0));
15 GfxDeviceFamily* const GfxDriverInfo::allDevices = nullptr;
17 GfxDeviceFamily* GfxDriverInfo::mDeviceFamilies[DeviceFamilyMax];
18 nsAString* GfxDriverInfo::mDeviceVendors[DeviceVendorMax];
20 GfxDriverInfo::GfxDriverInfo()
21 : mOperatingSystem(DRIVER_OS_UNKNOWN),
22 mOperatingSystemVersion(0),
23 mAdapterVendor(GfxDriverInfo::GetDeviceVendor(VendorAll)),
24 mDevices(allDevices),
25 mDeleteDevices(false),
26 mFeature(allFeatures),
27 mFeatureStatus(nsIGfxInfo::FEATURE_STATUS_OK),
28 mComparisonOp(DRIVER_COMPARISON_IGNORED),
29 mDriverVersion(0),
30 mDriverVersionMax(0),
31 mSuggestedVersion(nullptr)
34 GfxDriverInfo::GfxDriverInfo(OperatingSystem os, nsAString& vendor,
35 GfxDeviceFamily* devices,
36 int32_t feature, int32_t featureStatus,
37 VersionComparisonOp op,
38 uint64_t driverVersion,
39 const char *suggestedVersion /* = nullptr */,
40 bool ownDevices /* = false */)
41 : mOperatingSystem(os),
42 mOperatingSystemVersion(0),
43 mAdapterVendor(vendor),
44 mDevices(devices),
45 mDeleteDevices(ownDevices),
46 mFeature(feature),
47 mFeatureStatus(featureStatus),
48 mComparisonOp(op),
49 mDriverVersion(driverVersion),
50 mDriverVersionMax(0),
51 mSuggestedVersion(suggestedVersion)
54 GfxDriverInfo::GfxDriverInfo(const GfxDriverInfo& aOrig)
55 : mOperatingSystem(aOrig.mOperatingSystem),
56 mOperatingSystemVersion(aOrig.mOperatingSystemVersion),
57 mAdapterVendor(aOrig.mAdapterVendor),
58 mFeature(aOrig.mFeature),
59 mFeatureStatus(aOrig.mFeatureStatus),
60 mComparisonOp(aOrig.mComparisonOp),
61 mDriverVersion(aOrig.mDriverVersion),
62 mDriverVersionMax(aOrig.mDriverVersionMax),
63 mSuggestedVersion(aOrig.mSuggestedVersion)
65 // If we're managing the lifetime of the device family, we have to make a
66 // copy of the original's device family.
67 if (aOrig.mDeleteDevices && aOrig.mDevices) {
68 mDevices = new GfxDeviceFamily;
69 *mDevices = *aOrig.mDevices;
70 } else {
71 mDevices = aOrig.mDevices;
74 mDeleteDevices = aOrig.mDeleteDevices;
77 GfxDriverInfo::~GfxDriverInfo()
79 if (mDeleteDevices)
80 delete mDevices;
83 // Macros for appending a device to the DeviceFamily.
84 #define APPEND_DEVICE(device) APPEND_DEVICE2(#device)
85 #define APPEND_DEVICE2(device) deviceFamily->AppendElement(NS_LITERAL_STRING(device))
87 const GfxDeviceFamily* GfxDriverInfo::GetDeviceFamily(DeviceFamily id)
89 // The code here is too sensitive to fall through to the default case if the
90 // code is invalid.
91 NS_ASSERTION(id >= 0 && id < DeviceFamilyMax, "DeviceFamily id is out of range");
93 // If it already exists, we must have processed it once, so return it now.
94 if (mDeviceFamilies[id])
95 return mDeviceFamilies[id];
97 mDeviceFamilies[id] = new GfxDeviceFamily;
98 GfxDeviceFamily* deviceFamily = mDeviceFamilies[id];
100 switch (id) {
101 case IntelGMA500:
102 APPEND_DEVICE(0x8108); /* IntelGMA500_1 */
103 APPEND_DEVICE(0x8109); /* IntelGMA500_2 */
104 break;
105 case IntelGMA900:
106 APPEND_DEVICE(0x2582); /* IntelGMA900_1 */
107 APPEND_DEVICE(0x2782); /* IntelGMA900_2 */
108 APPEND_DEVICE(0x2592); /* IntelGMA900_3 */
109 APPEND_DEVICE(0x2792); /* IntelGMA900_4 */
110 break;
111 case IntelGMA950:
112 APPEND_DEVICE(0x2772); /* Intel945G_1 */
113 APPEND_DEVICE(0x2776); /* Intel945G_2 */
114 APPEND_DEVICE(0x27a2); /* Intel945_1 */
115 APPEND_DEVICE(0x27a6); /* Intel945_2 */
116 APPEND_DEVICE(0x27ae); /* Intel945_3 */
117 break;
118 case IntelGMA3150:
119 APPEND_DEVICE(0xa001); /* IntelGMA3150_Nettop_1 */
120 APPEND_DEVICE(0xa002); /* IntelGMA3150_Nettop_2 */
121 APPEND_DEVICE(0xa011); /* IntelGMA3150_Netbook_1 */
122 APPEND_DEVICE(0xa012); /* IntelGMA3150_Netbook_2 */
123 break;
124 case IntelGMAX3000:
125 APPEND_DEVICE(0x2972); /* Intel946GZ_1 */
126 APPEND_DEVICE(0x2973); /* Intel946GZ_2 */
127 APPEND_DEVICE(0x2982); /* IntelG35_1 */
128 APPEND_DEVICE(0x2983); /* IntelG35_2 */
129 APPEND_DEVICE(0x2992); /* IntelQ965_1 */
130 APPEND_DEVICE(0x2993); /* IntelQ965_2 */
131 APPEND_DEVICE(0x29a2); /* IntelG965_1 */
132 APPEND_DEVICE(0x29a3); /* IntelG965_2 */
133 APPEND_DEVICE(0x29b2); /* IntelQ35_1 */
134 APPEND_DEVICE(0x29b3); /* IntelQ35_2 */
135 APPEND_DEVICE(0x29c2); /* IntelG33_1 */
136 APPEND_DEVICE(0x29c3); /* IntelG33_2 */
137 APPEND_DEVICE(0x29d2); /* IntelQ33_1 */
138 APPEND_DEVICE(0x29d3); /* IntelQ33_2 */
139 APPEND_DEVICE(0x2a02); /* IntelGL960_1 */
140 APPEND_DEVICE(0x2a03); /* IntelGL960_2 */
141 APPEND_DEVICE(0x2a12); /* IntelGM965_1 */
142 APPEND_DEVICE(0x2a13); /* IntelGM965_2 */
143 break;
144 case IntelGMAX4500HD:
145 APPEND_DEVICE(0x2a42); /* IntelGMA4500MHD_1 */
146 APPEND_DEVICE(0x2a43); /* IntelGMA4500MHD_2 */
147 APPEND_DEVICE(0x2e42); /* IntelB43_1 */
148 APPEND_DEVICE(0x2e43); /* IntelB43_2 */
149 APPEND_DEVICE(0x2e92); /* IntelB43_3 */
150 APPEND_DEVICE(0x2e93); /* IntelB43_4 */
151 APPEND_DEVICE(0x2e32); /* IntelG41_1 */
152 APPEND_DEVICE(0x2e33); /* IntelG41_2 */
153 APPEND_DEVICE(0x2e22); /* IntelG45_1 */
154 APPEND_DEVICE(0x2e23); /* IntelG45_2 */
155 APPEND_DEVICE(0x2e12); /* IntelQ45_1 */
156 APPEND_DEVICE(0x2e13); /* IntelQ45_2 */
157 APPEND_DEVICE(0x0042); /* IntelHDGraphics */
158 APPEND_DEVICE(0x0046); /* IntelMobileHDGraphics */
159 APPEND_DEVICE(0x0102); /* IntelSandyBridge_1 */
160 APPEND_DEVICE(0x0106); /* IntelSandyBridge_2 */
161 APPEND_DEVICE(0x0112); /* IntelSandyBridge_3 */
162 APPEND_DEVICE(0x0116); /* IntelSandyBridge_4 */
163 APPEND_DEVICE(0x0122); /* IntelSandyBridge_5 */
164 APPEND_DEVICE(0x0126); /* IntelSandyBridge_6 */
165 APPEND_DEVICE(0x010a); /* IntelSandyBridge_7 */
166 APPEND_DEVICE(0x0080); /* IntelIvyBridge */
167 break;
168 case IntelHD3000:
169 APPEND_DEVICE(0x0126);
170 break;
171 case IntelMobileHDGraphics:
172 APPEND_DEVICE(0x0046); /* IntelMobileHDGraphics */
173 break;
174 case NvidiaBlockD3D9Layers:
175 // Glitches whilst scrolling (see bugs 612007, 644787, 645872)
176 APPEND_DEVICE(0x00f3); /* NV43 [GeForce 6200 (TM)] */
177 APPEND_DEVICE(0x0146); /* NV43 [Geforce Go 6600TE/6200TE (TM)] */
178 APPEND_DEVICE(0x014f); /* NV43 [GeForce 6200 (TM)] */
179 APPEND_DEVICE(0x0161); /* NV44 [GeForce 6200 TurboCache (TM)] */
180 APPEND_DEVICE(0x0162); /* NV44 [GeForce 6200SE TurboCache (TM)] */
181 APPEND_DEVICE(0x0163); /* NV44 [GeForce 6200 LE (TM)] */
182 APPEND_DEVICE(0x0164); /* NV44 [GeForce Go 6200 (TM)] */
183 APPEND_DEVICE(0x0167); /* NV43 [GeForce Go 6200/6400 (TM)] */
184 APPEND_DEVICE(0x0168); /* NV43 [GeForce Go 6200/6400 (TM)] */
185 APPEND_DEVICE(0x0169); /* NV44 [GeForce 6250 (TM)] */
186 APPEND_DEVICE(0x0222); /* NV44 [GeForce 6200 A-LE (TM)] */
187 APPEND_DEVICE(0x0240); /* C51PV [GeForce 6150 (TM)] */
188 APPEND_DEVICE(0x0241); /* C51 [GeForce 6150 LE (TM)] */
189 APPEND_DEVICE(0x0244); /* C51 [Geforce Go 6150 (TM)] */
190 APPEND_DEVICE(0x0245); /* C51 [Quadro NVS 210S/GeForce 6150LE (TM)] */
191 APPEND_DEVICE(0x0247); /* C51 [GeForce Go 6100 (TM)] */
192 APPEND_DEVICE(0x03d0); /* C61 [GeForce 6150SE nForce 430 (TM)] */
193 APPEND_DEVICE(0x03d1); /* C61 [GeForce 6100 nForce 405 (TM)] */
194 APPEND_DEVICE(0x03d2); /* C61 [GeForce 6100 nForce 400 (TM)] */
195 APPEND_DEVICE(0x03d5); /* C61 [GeForce 6100 nForce 420 (TM)] */
196 break;
197 case RadeonX1000:
198 // This list is from the ATIRadeonX1000.kext Info.plist
199 APPEND_DEVICE(0x7187);
200 APPEND_DEVICE(0x7210);
201 APPEND_DEVICE(0x71de);
202 APPEND_DEVICE(0x7146);
203 APPEND_DEVICE(0x7142);
204 APPEND_DEVICE(0x7109);
205 APPEND_DEVICE(0x71c5);
206 APPEND_DEVICE(0x71c0);
207 APPEND_DEVICE(0x7240);
208 APPEND_DEVICE(0x7249);
209 APPEND_DEVICE(0x7291);
210 break;
211 case Geforce7300GT:
212 APPEND_DEVICE(0x0393);
213 break;
214 case Nvidia310M:
215 APPEND_DEVICE(0x0A70);
216 break;
217 // This should never happen, but we get a warning if we don't handle this.
218 case DeviceFamilyMax:
219 NS_WARNING("Invalid DeviceFamily id");
220 break;
223 return deviceFamily;
226 // Macro for assigning a device vendor id to a string.
227 #define DECLARE_VENDOR_ID(name, deviceId) \
228 case name: \
229 mDeviceVendors[id]->AssignLiteral(deviceId); \
230 break;
232 const nsAString& GfxDriverInfo::GetDeviceVendor(DeviceVendor id)
234 NS_ASSERTION(id >= 0 && id < DeviceVendorMax, "DeviceVendor id is out of range");
236 if (mDeviceVendors[id])
237 return *mDeviceVendors[id];
239 mDeviceVendors[id] = new nsString();
241 switch (id) {
242 DECLARE_VENDOR_ID(VendorAll, "");
243 DECLARE_VENDOR_ID(VendorIntel, "0x8086");
244 DECLARE_VENDOR_ID(VendorNVIDIA, "0x10de");
245 DECLARE_VENDOR_ID(VendorAMD, "0x1022");
246 DECLARE_VENDOR_ID(VendorATI, "0x1002");
247 DECLARE_VENDOR_ID(VendorMicrosoft, "0x1414");
248 // Suppress a warning.
249 DECLARE_VENDOR_ID(DeviceVendorMax, "");
252 return *mDeviceVendors[id];