widget/xpwidgets/GfxDriverInfo.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/widget/xpwidgets/GfxDriverInfo.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,247 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "GfxDriverInfo.h"
    1.10 +
    1.11 +#include "nsIGfxInfo.h"
    1.12 +#include "nsTArray.h"
    1.13 +
    1.14 +using namespace mozilla::widget;
    1.15 +
    1.16 +int32_t GfxDriverInfo::allFeatures = 0;
    1.17 +uint64_t GfxDriverInfo::allDriverVersions = ~(uint64_t(0));
    1.18 +GfxDeviceFamily* const GfxDriverInfo::allDevices = nullptr;
    1.19 +
    1.20 +GfxDeviceFamily* GfxDriverInfo::mDeviceFamilies[DeviceFamilyMax];
    1.21 +nsAString* GfxDriverInfo::mDeviceVendors[DeviceVendorMax];
    1.22 +
    1.23 +GfxDriverInfo::GfxDriverInfo()
    1.24 +  : mOperatingSystem(DRIVER_OS_UNKNOWN),
    1.25 +    mOperatingSystemVersion(0),
    1.26 +    mAdapterVendor(GfxDriverInfo::GetDeviceVendor(VendorAll)),
    1.27 +    mDevices(allDevices),
    1.28 +    mDeleteDevices(false),
    1.29 +    mFeature(allFeatures),
    1.30 +    mFeatureStatus(nsIGfxInfo::FEATURE_NO_INFO),
    1.31 +    mComparisonOp(DRIVER_COMPARISON_IGNORED),
    1.32 +    mDriverVersion(0),
    1.33 +    mDriverVersionMax(0),
    1.34 +    mSuggestedVersion(nullptr)
    1.35 +{}
    1.36 +
    1.37 +GfxDriverInfo::GfxDriverInfo(OperatingSystem os, nsAString& vendor,
    1.38 +                             GfxDeviceFamily* devices,
    1.39 +                             int32_t feature, int32_t featureStatus,
    1.40 +                             VersionComparisonOp op,
    1.41 +                             uint64_t driverVersion,
    1.42 +                             const char *suggestedVersion /* = nullptr */,
    1.43 +                             bool ownDevices /* = false */)
    1.44 +  : mOperatingSystem(os),
    1.45 +    mOperatingSystemVersion(0),
    1.46 +    mAdapterVendor(vendor),
    1.47 +    mDevices(devices),
    1.48 +    mDeleteDevices(ownDevices),
    1.49 +    mFeature(feature),
    1.50 +    mFeatureStatus(featureStatus),
    1.51 +    mComparisonOp(op),
    1.52 +    mDriverVersion(driverVersion),
    1.53 +    mDriverVersionMax(0),
    1.54 +    mSuggestedVersion(suggestedVersion)
    1.55 +{}
    1.56 +
    1.57 +GfxDriverInfo::GfxDriverInfo(const GfxDriverInfo& aOrig)
    1.58 +  : mOperatingSystem(aOrig.mOperatingSystem),
    1.59 +    mOperatingSystemVersion(aOrig.mOperatingSystemVersion),
    1.60 +    mAdapterVendor(aOrig.mAdapterVendor),
    1.61 +    mFeature(aOrig.mFeature),
    1.62 +    mFeatureStatus(aOrig.mFeatureStatus),
    1.63 +    mComparisonOp(aOrig.mComparisonOp),
    1.64 +    mDriverVersion(aOrig.mDriverVersion),
    1.65 +    mDriverVersionMax(aOrig.mDriverVersionMax),
    1.66 +    mSuggestedVersion(aOrig.mSuggestedVersion)
    1.67 +{
    1.68 +  // If we're managing the lifetime of the device family, we have to make a
    1.69 +  // copy of the original's device family.
    1.70 +  if (aOrig.mDeleteDevices && aOrig.mDevices) {
    1.71 +    mDevices = new GfxDeviceFamily;
    1.72 +    *mDevices = *aOrig.mDevices;
    1.73 +  } else {
    1.74 +    mDevices = aOrig.mDevices;
    1.75 +  }
    1.76 +
    1.77 +  mDeleteDevices = aOrig.mDeleteDevices;
    1.78 +}
    1.79 +
    1.80 +GfxDriverInfo::~GfxDriverInfo()
    1.81 +{
    1.82 +  if (mDeleteDevices)
    1.83 +    delete mDevices;
    1.84 +}
    1.85 +
    1.86 +// Macros for appending a device to the DeviceFamily.
    1.87 +#define APPEND_DEVICE(device) APPEND_DEVICE2(#device)
    1.88 +#define APPEND_DEVICE2(device) deviceFamily->AppendElement(NS_LITERAL_STRING(device))
    1.89 +
    1.90 +const GfxDeviceFamily* GfxDriverInfo::GetDeviceFamily(DeviceFamily id)
    1.91 +{
    1.92 +  // The code here is too sensitive to fall through to the default case if the
    1.93 +  // code is invalid.
    1.94 +  NS_ASSERTION(id >= 0 && id < DeviceFamilyMax, "DeviceFamily id is out of range");
    1.95 +
    1.96 +  // If it already exists, we must have processed it once, so return it now.
    1.97 +  if (mDeviceFamilies[id])
    1.98 +    return mDeviceFamilies[id];
    1.99 +
   1.100 +  mDeviceFamilies[id] = new GfxDeviceFamily;
   1.101 +  GfxDeviceFamily* deviceFamily = mDeviceFamilies[id];
   1.102 +
   1.103 +  switch (id) {
   1.104 +    case IntelGMA500:
   1.105 +      APPEND_DEVICE(0x8108); /* IntelGMA500_1 */
   1.106 +      APPEND_DEVICE(0x8109); /* IntelGMA500_2 */
   1.107 +      break;
   1.108 +    case IntelGMA900:
   1.109 +      APPEND_DEVICE(0x2582); /* IntelGMA900_1 */
   1.110 +      APPEND_DEVICE(0x2782); /* IntelGMA900_2 */
   1.111 +      APPEND_DEVICE(0x2592); /* IntelGMA900_3 */
   1.112 +      APPEND_DEVICE(0x2792); /* IntelGMA900_4 */
   1.113 +      break;
   1.114 +    case IntelGMA950:
   1.115 +      APPEND_DEVICE(0x2772); /* Intel945G_1 */
   1.116 +      APPEND_DEVICE(0x2776); /* Intel945G_2 */
   1.117 +      APPEND_DEVICE(0x27a2); /* Intel945_1 */
   1.118 +      APPEND_DEVICE(0x27a6); /* Intel945_2 */
   1.119 +      APPEND_DEVICE(0x27ae); /* Intel945_3 */
   1.120 +      break;
   1.121 +    case IntelGMA3150:
   1.122 +      APPEND_DEVICE(0xa001); /* IntelGMA3150_Nettop_1 */
   1.123 +      APPEND_DEVICE(0xa002); /* IntelGMA3150_Nettop_2 */
   1.124 +      APPEND_DEVICE(0xa011); /* IntelGMA3150_Netbook_1 */
   1.125 +      APPEND_DEVICE(0xa012); /* IntelGMA3150_Netbook_2 */
   1.126 +      break;
   1.127 +    case IntelGMAX3000:
   1.128 +      APPEND_DEVICE(0x2972); /* Intel946GZ_1 */
   1.129 +      APPEND_DEVICE(0x2973); /* Intel946GZ_2 */
   1.130 +      APPEND_DEVICE(0x2982); /* IntelG35_1 */
   1.131 +      APPEND_DEVICE(0x2983); /* IntelG35_2 */
   1.132 +      APPEND_DEVICE(0x2992); /* IntelQ965_1 */
   1.133 +      APPEND_DEVICE(0x2993); /* IntelQ965_2 */
   1.134 +      APPEND_DEVICE(0x29a2); /* IntelG965_1 */
   1.135 +      APPEND_DEVICE(0x29a3); /* IntelG965_2 */
   1.136 +      APPEND_DEVICE(0x29b2); /* IntelQ35_1 */
   1.137 +      APPEND_DEVICE(0x29b3); /* IntelQ35_2 */
   1.138 +      APPEND_DEVICE(0x29c2); /* IntelG33_1 */
   1.139 +      APPEND_DEVICE(0x29c3); /* IntelG33_2 */
   1.140 +      APPEND_DEVICE(0x29d2); /* IntelQ33_1 */
   1.141 +      APPEND_DEVICE(0x29d3); /* IntelQ33_2 */
   1.142 +      APPEND_DEVICE(0x2a02); /* IntelGL960_1 */
   1.143 +      APPEND_DEVICE(0x2a03); /* IntelGL960_2 */
   1.144 +      APPEND_DEVICE(0x2a12); /* IntelGM965_1 */
   1.145 +      APPEND_DEVICE(0x2a13); /* IntelGM965_2 */
   1.146 +      break;
   1.147 +    case IntelGMAX4500HD:
   1.148 +      APPEND_DEVICE(0x2a42); /* IntelGMA4500MHD_1 */
   1.149 +      APPEND_DEVICE(0x2a43); /* IntelGMA4500MHD_2 */
   1.150 +      APPEND_DEVICE(0x2e42); /* IntelB43_1 */
   1.151 +      APPEND_DEVICE(0x2e43); /* IntelB43_2 */
   1.152 +      APPEND_DEVICE(0x2e92); /* IntelB43_3 */
   1.153 +      APPEND_DEVICE(0x2e93); /* IntelB43_4 */
   1.154 +      APPEND_DEVICE(0x2e32); /* IntelG41_1 */
   1.155 +      APPEND_DEVICE(0x2e33); /* IntelG41_2 */
   1.156 +      APPEND_DEVICE(0x2e22); /* IntelG45_1 */
   1.157 +      APPEND_DEVICE(0x2e23); /* IntelG45_2 */
   1.158 +      APPEND_DEVICE(0x2e12); /* IntelQ45_1 */
   1.159 +      APPEND_DEVICE(0x2e13); /* IntelQ45_2 */
   1.160 +      APPEND_DEVICE(0x0042); /* IntelHDGraphics */
   1.161 +      APPEND_DEVICE(0x0046); /* IntelMobileHDGraphics */
   1.162 +      APPEND_DEVICE(0x0102); /* IntelSandyBridge_1 */
   1.163 +      APPEND_DEVICE(0x0106); /* IntelSandyBridge_2 */
   1.164 +      APPEND_DEVICE(0x0112); /* IntelSandyBridge_3 */
   1.165 +      APPEND_DEVICE(0x0116); /* IntelSandyBridge_4 */
   1.166 +      APPEND_DEVICE(0x0122); /* IntelSandyBridge_5 */
   1.167 +      APPEND_DEVICE(0x0126); /* IntelSandyBridge_6 */
   1.168 +      APPEND_DEVICE(0x010a); /* IntelSandyBridge_7 */
   1.169 +      APPEND_DEVICE(0x0080); /* IntelIvyBridge */
   1.170 +      break;
   1.171 +    case IntelMobileHDGraphics:
   1.172 +      APPEND_DEVICE(0x0046); /* IntelMobileHDGraphics */
   1.173 +      break;
   1.174 +    case NvidiaBlockD3D9Layers:
   1.175 +      // Glitches whilst scrolling (see bugs 612007, 644787, 645872)
   1.176 +      APPEND_DEVICE(0x00f3); /* NV43 [GeForce 6200 (TM)] */
   1.177 +      APPEND_DEVICE(0x0146); /* NV43 [Geforce Go 6600TE/6200TE (TM)] */
   1.178 +      APPEND_DEVICE(0x014f); /* NV43 [GeForce 6200 (TM)] */
   1.179 +      APPEND_DEVICE(0x0161); /* NV44 [GeForce 6200 TurboCache (TM)] */
   1.180 +      APPEND_DEVICE(0x0162); /* NV44 [GeForce 6200SE TurboCache (TM)] */
   1.181 +      APPEND_DEVICE(0x0163); /* NV44 [GeForce 6200 LE (TM)] */
   1.182 +      APPEND_DEVICE(0x0164); /* NV44 [GeForce Go 6200 (TM)] */
   1.183 +      APPEND_DEVICE(0x0167); /* NV43 [GeForce Go 6200/6400 (TM)] */
   1.184 +      APPEND_DEVICE(0x0168); /* NV43 [GeForce Go 6200/6400 (TM)] */
   1.185 +      APPEND_DEVICE(0x0169); /* NV44 [GeForce 6250 (TM)] */
   1.186 +      APPEND_DEVICE(0x0222); /* NV44 [GeForce 6200 A-LE (TM)] */
   1.187 +      APPEND_DEVICE(0x0240); /* C51PV [GeForce 6150 (TM)] */
   1.188 +      APPEND_DEVICE(0x0241); /* C51 [GeForce 6150 LE (TM)] */
   1.189 +      APPEND_DEVICE(0x0244); /* C51 [Geforce Go 6150 (TM)] */
   1.190 +      APPEND_DEVICE(0x0245); /* C51 [Quadro NVS 210S/GeForce 6150LE (TM)] */
   1.191 +      APPEND_DEVICE(0x0247); /* C51 [GeForce Go 6100 (TM)] */
   1.192 +      APPEND_DEVICE(0x03d0); /* C61 [GeForce 6150SE nForce 430 (TM)] */
   1.193 +      APPEND_DEVICE(0x03d1); /* C61 [GeForce 6100 nForce 405 (TM)] */
   1.194 +      APPEND_DEVICE(0x03d2); /* C61 [GeForce 6100 nForce 400 (TM)] */
   1.195 +      APPEND_DEVICE(0x03d5); /* C61 [GeForce 6100 nForce 420 (TM)] */
   1.196 +      break;
   1.197 +    case RadeonX1000:
   1.198 +      // This list is from the ATIRadeonX1000.kext Info.plist
   1.199 +      APPEND_DEVICE(0x7187);
   1.200 +      APPEND_DEVICE(0x7210);
   1.201 +      APPEND_DEVICE(0x71de);
   1.202 +      APPEND_DEVICE(0x7146);
   1.203 +      APPEND_DEVICE(0x7142);
   1.204 +      APPEND_DEVICE(0x7109);
   1.205 +      APPEND_DEVICE(0x71c5);
   1.206 +      APPEND_DEVICE(0x71c0);
   1.207 +      APPEND_DEVICE(0x7240);
   1.208 +      APPEND_DEVICE(0x7249);
   1.209 +      APPEND_DEVICE(0x7291);
   1.210 +      break;
   1.211 +    case Geforce7300GT:
   1.212 +      APPEND_DEVICE(0x0393);
   1.213 +      break;
   1.214 +    // This should never happen, but we get a warning if we don't handle this.
   1.215 +    case DeviceFamilyMax:
   1.216 +      NS_WARNING("Invalid DeviceFamily id");
   1.217 +      break;
   1.218 +  }
   1.219 +
   1.220 +  return deviceFamily;
   1.221 +}
   1.222 +
   1.223 +// Macro for assigning a device vendor id to a string.
   1.224 +#define DECLARE_VENDOR_ID(name, deviceId) \
   1.225 +  case name: \
   1.226 +    mDeviceVendors[id]->AssignLiteral(deviceId); \
   1.227 +    break;
   1.228 +
   1.229 +const nsAString& GfxDriverInfo::GetDeviceVendor(DeviceVendor id)
   1.230 +{
   1.231 +  NS_ASSERTION(id >= 0 && id < DeviceVendorMax, "DeviceVendor id is out of range");
   1.232 +
   1.233 +  if (mDeviceVendors[id])
   1.234 +    return *mDeviceVendors[id];
   1.235 +
   1.236 +  mDeviceVendors[id] = new nsString();
   1.237 +
   1.238 +  switch (id) {
   1.239 +    DECLARE_VENDOR_ID(VendorAll, "");
   1.240 +    DECLARE_VENDOR_ID(VendorIntel, "0x8086");
   1.241 +    DECLARE_VENDOR_ID(VendorNVIDIA, "0x10de");
   1.242 +    DECLARE_VENDOR_ID(VendorAMD, "0x1022");
   1.243 +    DECLARE_VENDOR_ID(VendorATI, "0x1002");
   1.244 +    DECLARE_VENDOR_ID(VendorMicrosoft, "0x1414");
   1.245 +    // Suppress a warning.
   1.246 +    DECLARE_VENDOR_ID(DeviceVendorMax, "");
   1.247 +  }
   1.248 +
   1.249 +  return *mDeviceVendors[id];
   1.250 +}

mercurial