From 44ee4e573ed80f8d3004c9f5bda344f2fd11bb8d Mon Sep 17 00:00:00 2001 From: Doug Sherk Date: Wed, 14 Dec 2011 21:03:01 -0800 Subject: [PATCH] Bug 704710: refactor GfxDriverInfo/GfxInfo(Base) to support string-based vendor and device id r=joe --- toolkit/content/aboutSupport.js | 8 +- widget/public/nsIGfxInfo.idl | 8 +- widget/src/android/GfxInfo.cpp | 49 +++-- widget/src/android/GfxInfo.h | 9 +- widget/src/cocoa/GfxInfo.h | 12 +- widget/src/cocoa/GfxInfo.mm | 68 +++--- widget/src/windows/GfxInfo.cpp | 232 +++++++++---------- widget/src/windows/GfxInfo.h | 16 +- widget/src/xpwidgets/GfxDriverInfo.cpp | 294 +++++++++++++------------ widget/src/xpwidgets/GfxDriverInfo.h | 37 ++-- widget/src/xpwidgets/GfxInfoBase.cpp | 88 ++++---- widget/src/xpwidgets/GfxInfoX11.cpp | 20 +- widget/src/xpwidgets/GfxInfoX11.h | 8 +- 13 files changed, 439 insertions(+), 410 deletions(-) diff --git a/toolkit/content/aboutSupport.js b/toolkit/content/aboutSupport.js index 89f1e10fade9..9349d20baa47 100644 --- a/toolkit/content/aboutSupport.js +++ b/toolkit/content/aboutSupport.js @@ -249,8 +249,8 @@ function populateGraphicsSection() { if (gfxInfo) { let trGraphics = []; pushInfoRow(trGraphics, "adapterDescription", gfxInfo.adapterDescription); - pushInfoRow(trGraphics, "adapterVendorID", hexValueToString(gfxInfo.adapterVendorID)); - pushInfoRow(trGraphics, "adapterDeviceID", hexValueToString(gfxInfo.adapterDeviceID)); + pushInfoRow(trGraphics, "adapterVendorID", gfxInfo.adapterVendorID); + pushInfoRow(trGraphics, "adapterDeviceID", gfxInfo.adapterDeviceID); pushInfoRow(trGraphics, "adapterRAM", gfxInfo.adapterRAM); pushInfoRow(trGraphics, "adapterDrivers", gfxInfo.adapterDriver); pushInfoRow(trGraphics, "driverVersion", gfxInfo.adapterDriverVersion); @@ -258,8 +258,8 @@ function populateGraphicsSection() { #ifdef XP_WIN pushInfoRow(trGraphics, "adapterDescription2", gfxInfo.adapterDescription2); - pushInfoRow(trGraphics, "adapterVendorID2", hexValueToString(gfxInfo.adapterVendorID2)); - pushInfoRow(trGraphics, "adapterDeviceID2", hexValueToString(gfxInfo.adapterDeviceID2)); + pushInfoRow(trGraphics, "adapterVendorID2", gfxInfo.adapterVendorID2); + pushInfoRow(trGraphics, "adapterDeviceID2", gfxInfo.adapterDeviceID2); pushInfoRow(trGraphics, "adapterRAM2", gfxInfo.adapterRAM2); pushInfoRow(trGraphics, "adapterDrivers2", gfxInfo.adapterDriver2); pushInfoRow(trGraphics, "driverVersion2", gfxInfo.adapterDriverVersion2); diff --git a/widget/public/nsIGfxInfo.idl b/widget/public/nsIGfxInfo.idl index 2f3f6ae17a3f..891dd61e658b 100644 --- a/widget/public/nsIGfxInfo.idl +++ b/widget/public/nsIGfxInfo.idl @@ -64,11 +64,11 @@ interface nsIGfxInfo : nsISupports readonly attribute DOMString adapterDriver2; /* These types are inspired by DXGI_ADAPTER_DESC */ - readonly attribute unsigned long adapterVendorID; - readonly attribute unsigned long adapterVendorID2; + readonly attribute DOMString adapterVendorID; + readonly attribute DOMString adapterVendorID2; - readonly attribute unsigned long adapterDeviceID; - readonly attribute unsigned long adapterDeviceID2; + readonly attribute DOMString adapterDeviceID; + readonly attribute DOMString adapterDeviceID2; /** * The amount of RAM in MB in the display adapter. diff --git a/widget/src/android/GfxInfo.cpp b/widget/src/android/GfxInfo.cpp index 95ceb91677e6..9c9ff2e31640 100644 --- a/widget/src/android/GfxInfo.cpp +++ b/widget/src/android/GfxInfo.cpp @@ -188,47 +188,47 @@ GfxInfo::GetAdapterDriverDate2(nsAString & aAdapterDriverDate) return NS_ERROR_FAILURE; } -/* readonly attribute unsigned long adapterVendorID; */ +/* readonly attribute DOMString adapterVendorID; */ NS_IMETHODIMP -GfxInfo::GetAdapterVendorID(PRUint32 *aAdapterVendorID) +GfxInfo::GetAdapterVendorID(nsAString & aAdapterVendorID) { nsAutoString str; PRInt32 version; // the HARDWARE field isn't available on Android SDK < 8 if (!mozilla::AndroidBridge::Bridge()->GetStaticIntField("android/os/Build$VERSION", "SDK_INT", &version)) version = 0; if (version >= 8 && mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "HARDWARE", str)) { - *aAdapterVendorID = HashString(str); + aAdapterVendorID = str; return NS_OK; } - *aAdapterVendorID = 0; + aAdapterVendorID = NS_LITERAL_STRING(""); return NS_OK; } -/* readonly attribute unsigned long adapterVendorID2; */ +/* readonly attribute DOMString adapterVendorID2; */ NS_IMETHODIMP -GfxInfo::GetAdapterVendorID2(PRUint32 *aAdapterVendorID) +GfxInfo::GetAdapterVendorID2(nsAString & aAdapterVendorID) { return NS_ERROR_FAILURE; } -/* readonly attribute unsigned long adapterDeviceID; */ +/* readonly attribute DOMString adapterDeviceID; */ NS_IMETHODIMP -GfxInfo::GetAdapterDeviceID(PRUint32 *aAdapterDeviceID) +GfxInfo::GetAdapterDeviceID(nsAString & aAdapterDeviceID) { nsAutoString str; if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "MODEL", str)) { - *aAdapterDeviceID = HashString(str); + aAdapterDeviceID = str; return NS_OK; } - *aAdapterDeviceID = 0; + aAdapterDeviceID = NS_LITERAL_STRING(""); return NS_OK; } -/* readonly attribute unsigned long adapterDeviceID2; */ +/* readonly attribute DOMString adapterDeviceID2; */ NS_IMETHODIMP -GfxInfo::GetAdapterDeviceID2(PRUint32 *aAdapterDeviceID) +GfxInfo::GetAdapterDeviceID2(nsAString & aAdapterDeviceID) { return NS_ERROR_FAILURE; } @@ -244,29 +244,30 @@ void GfxInfo::AddOpenGLCrashReportAnnotations() { #if defined(MOZ_CRASHREPORTER) - nsCAutoString deviceIDString, vendorIDString; - nsAutoString adapterDescriptionString; - PRUint32 deviceID, vendorID; + nsAutoString adapterDescriptionString, deviceID, vendorID; + nsCAutoString narrowDeviceID, narrowVendorID; - GetAdapterDeviceID(&deviceID); - GetAdapterVendorID(&vendorID); + GetAdapterDeviceID(deviceID); + GetAdapterVendorID(vendorID); GetAdapterDescription(adapterDescriptionString); - deviceIDString.AppendPrintf("%04x", deviceID); - vendorIDString.AppendPrintf("%04x", vendorID); + narrowDeviceID = NS_ConvertUTF16toUTF8(deviceID); + narrowVendorID = NS_ConvertUTF16toUTF8(vendorID); CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterVendorID"), - vendorIDString); + narrowVendorID); CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterDeviceID"), - deviceIDString); + narrowDeviceID); /* Add an App Note for now so that we get the data immediately. These * can go away after we store the above in the socorro db */ nsCAutoString note; /* AppendPrintf only supports 32 character strings, mrghh. */ - note.AppendPrintf("AdapterVendorID: %04x, ", vendorID); - note.AppendPrintf("AdapterDeviceID: %04x.", deviceID); - note.Append("\n"); + note.Append("AdapterVendorID: "); + note.Append(narrowVendorID); + note.Append(", AdapterDeviceID: "); + note.Append(narrowDeviceID); + note.Append(".\n"); note.AppendPrintf("AdapterDescription: '%s'.", NS_ConvertUTF16toUTF8(adapterDescriptionString).get()); note.Append("\n"); diff --git a/widget/src/android/GfxInfo.h b/widget/src/android/GfxInfo.h index d54f6ed192b4..82f892e3bd48 100644 --- a/widget/src/android/GfxInfo.h +++ b/widget/src/android/GfxInfo.h @@ -41,6 +41,7 @@ #define __mozilla_widget_GfxInfo_h__ #include "GfxInfoBase.h" +#include "GfxDriverInfo.h" #include "nsString.h" @@ -59,15 +60,15 @@ public: NS_SCRIPTABLE NS_IMETHOD GetCleartypeParameters(nsAString & aCleartypeParams); NS_SCRIPTABLE NS_IMETHOD GetAdapterDescription(nsAString & aAdapterDescription); NS_SCRIPTABLE NS_IMETHOD GetAdapterDriver(nsAString & aAdapterDriver); - NS_SCRIPTABLE NS_IMETHOD GetAdapterVendorID(PRUint32 *aAdapterVendorID); - NS_SCRIPTABLE NS_IMETHOD GetAdapterDeviceID(PRUint32 *aAdapterDeviceID); + NS_SCRIPTABLE NS_IMETHOD GetAdapterVendorID(nsAString & aAdapterVendorID); + NS_SCRIPTABLE NS_IMETHOD GetAdapterDeviceID(nsAString & aAdapterDeviceID); NS_SCRIPTABLE NS_IMETHOD GetAdapterRAM(nsAString & aAdapterRAM); NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverVersion(nsAString & aAdapterDriverVersion); NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverDate(nsAString & aAdapterDriverDate); NS_SCRIPTABLE NS_IMETHOD GetAdapterDescription2(nsAString & aAdapterDescription); NS_SCRIPTABLE NS_IMETHOD GetAdapterDriver2(nsAString & aAdapterDriver); - NS_SCRIPTABLE NS_IMETHOD GetAdapterVendorID2(PRUint32 *aAdapterVendorID); - NS_SCRIPTABLE NS_IMETHOD GetAdapterDeviceID2(PRUint32 *aAdapterDeviceID); + NS_SCRIPTABLE NS_IMETHOD GetAdapterVendorID2(nsAString & aAdapterVendorID); + NS_SCRIPTABLE NS_IMETHOD GetAdapterDeviceID2(nsAString & aAdapterDeviceID); NS_SCRIPTABLE NS_IMETHOD GetAdapterRAM2(nsAString & aAdapterRAM); NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverVersion2(nsAString & aAdapterDriverVersion); NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverDate2(nsAString & aAdapterDriverDate); diff --git a/widget/src/cocoa/GfxInfo.h b/widget/src/cocoa/GfxInfo.h index d07f2637a79a..f112a2a8f3a6 100644 --- a/widget/src/cocoa/GfxInfo.h +++ b/widget/src/cocoa/GfxInfo.h @@ -61,15 +61,15 @@ public: NS_SCRIPTABLE NS_IMETHOD GetCleartypeParameters(nsAString & aCleartypeParams); NS_SCRIPTABLE NS_IMETHOD GetAdapterDescription(nsAString & aAdapterDescription); NS_SCRIPTABLE NS_IMETHOD GetAdapterDriver(nsAString & aAdapterDriver); - NS_SCRIPTABLE NS_IMETHOD GetAdapterVendorID(PRUint32 *aAdapterVendorID); - NS_SCRIPTABLE NS_IMETHOD GetAdapterDeviceID(PRUint32 *aAdapterDeviceID); + NS_SCRIPTABLE NS_IMETHOD GetAdapterVendorID(nsAString & aAdapterVendorID); + NS_SCRIPTABLE NS_IMETHOD GetAdapterDeviceID(nsAString & aAdapterDeviceID); NS_SCRIPTABLE NS_IMETHOD GetAdapterRAM(nsAString & aAdapterRAM); NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverVersion(nsAString & aAdapterDriverVersion); NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverDate(nsAString & aAdapterDriverDate); NS_SCRIPTABLE NS_IMETHOD GetAdapterDescription2(nsAString & aAdapterDescription); NS_SCRIPTABLE NS_IMETHOD GetAdapterDriver2(nsAString & aAdapterDriver); - NS_SCRIPTABLE NS_IMETHOD GetAdapterVendorID2(PRUint32 *aAdapterVendorID); - NS_SCRIPTABLE NS_IMETHOD GetAdapterDeviceID2(PRUint32 *aAdapterDeviceID); + NS_SCRIPTABLE NS_IMETHOD GetAdapterVendorID2(nsAString & aAdapterVendorID); + NS_SCRIPTABLE NS_IMETHOD GetAdapterDeviceID2(nsAString & aAdapterDeviceID); NS_SCRIPTABLE NS_IMETHOD GetAdapterRAM2(nsAString & aAdapterRAM); NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverVersion2(nsAString & aAdapterDriverVersion); NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverDate2(nsAString & aAdapterDriverDate); @@ -101,8 +101,8 @@ private: nsString mDriverDate; nsString mDeviceKey; - PRUint32 mAdapterVendorID; - PRUint32 mAdapterDeviceID; + nsString mAdapterVendorID; + nsString mAdapterDeviceID; PRUint32 mRendererIDs[16]; diff --git a/widget/src/cocoa/GfxInfo.mm b/widget/src/cocoa/GfxInfo.mm index bdd1604523d4..65835bbf835b 100644 --- a/widget/src/cocoa/GfxInfo.mm +++ b/widget/src/cocoa/GfxInfo.mm @@ -68,8 +68,6 @@ using namespace mozilla; using namespace mozilla::widget; GfxInfo::GfxInfo() - : mAdapterVendorID(0), - mAdapterDeviceID(0) { } @@ -104,24 +102,25 @@ GfxInfo::GetDeviceInfo() io_registry_entry_t dsp_port = CGDisplayIOServicePort(kCGDirectMainDisplay); CFTypeRef vendor_id_ref = SearchPortForProperty(dsp_port, CFSTR("vendor-id")); if (vendor_id_ref) { - mAdapterVendorID = IntValueOfCFData((CFDataRef)vendor_id_ref); + mAdapterVendorID.AppendPrintf("0x%4x", IntValueOfCFData((CFDataRef)vendor_id_ref)); CFRelease(vendor_id_ref); } CFTypeRef device_id_ref = SearchPortForProperty(dsp_port, CFSTR("device-id")); if (device_id_ref) { - mAdapterDeviceID = IntValueOfCFData((CFDataRef)device_id_ref); + mAdapterDeviceID.AppendPrintf("0x%4x", IntValueOfCFData((CFDataRef)device_id_ref)); CFRelease(device_id_ref); } } +// TODO dRdR FIXME static bool -IsATIRadeonX1000(PRUint32 aVendorID, PRUint32 aDeviceID) +IsATIRadeonX1000(nsAString& aVendorID, nsAString& aDeviceID) { - if (aVendorID == 0x1002) { + if (aVendorID.LowerCaseEqualsLiteral("0x1002")) { // this list is from the ATIRadeonX1000.kext Info.plist - PRUint32 devices[] = {0x7187, 0x7210, 0x71DE, 0x7146, 0x7142, 0x7109, 0x71C5, 0x71C0, 0x7240, 0x7249, 0x7291}; + const char * devices[] = {"0x7187", "0x7210", "0x71de", "0x7146", "0x7142", "0x7109", "0x71c5", "0x71c0", "0x7240", "0x7249", "0x7291"}; for (size_t i = 0; i < ArrayLength(devices); i++) { - if (aDeviceID == devices[i]) + if (aDeviceID.LowerCaseEqualsASCII(devices[i])) return true; } } @@ -292,32 +291,32 @@ GfxInfo::GetAdapterDriverDate2(nsAString & aAdapterDriverDate) return NS_ERROR_FAILURE; } -/* readonly attribute unsigned long adapterVendorID; */ +/* readonly attribute DOMString adapterVendorID; */ NS_IMETHODIMP -GfxInfo::GetAdapterVendorID(PRUint32 *aAdapterVendorID) +GfxInfo::GetAdapterVendorID(nsAString & aAdapterVendorID) { - *aAdapterVendorID = mAdapterVendorID; + aAdapterVendorID = mAdapterVendorID; return NS_OK; } -/* readonly attribute unsigned long adapterVendorID2; */ +/* readonly attribute DOMString adapterVendorID2; */ NS_IMETHODIMP -GfxInfo::GetAdapterVendorID2(PRUint32 *aAdapterVendorID) +GfxInfo::GetAdapterVendorID2(nsAString & aAdapterVendorID) { return NS_ERROR_FAILURE; } -/* readonly attribute unsigned long adapterDeviceID; */ +/* readonly attribute DOMString adapterDeviceID; */ NS_IMETHODIMP -GfxInfo::GetAdapterDeviceID(PRUint32 *aAdapterDeviceID) +GfxInfo::GetAdapterDeviceID(nsAString & aAdapterDeviceID) { - *aAdapterDeviceID = mAdapterDeviceID; + aAdapterDeviceID = mAdapterDeviceID; return NS_OK; } -/* readonly attribute unsigned long adapterDeviceID2; */ +/* readonly attribute DOMString adapterDeviceID2; */ NS_IMETHODIMP -GfxInfo::GetAdapterDeviceID2(PRUint32 *aAdapterDeviceID) +GfxInfo::GetAdapterDeviceID2(nsAString & aAdapterDeviceID) { return NS_ERROR_FAILURE; } @@ -333,25 +332,26 @@ void GfxInfo::AddCrashReportAnnotations() { #if defined(MOZ_CRASHREPORTER) - nsCAutoString deviceIDString, vendorIDString; - PRUint32 deviceID, vendorID; + nsString deviceID, vendorID; + nsCAutoString narrowDeviceID, narrowVendorID; - GetAdapterDeviceID(&deviceID); - GetAdapterVendorID(&vendorID); - - deviceIDString.AppendPrintf("%04x", deviceID); - vendorIDString.AppendPrintf("%04x", vendorID); + GetAdapterDeviceID(deviceID); + CopyUTF16toUTF8(deviceID, narrowDeviceID); + GetAdapterVendorID(vendorID); + CopyUTF16toUTF8(vendorID, narrowVendorID); CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterVendorID"), - vendorIDString); + narrowVendorID); CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterDeviceID"), - deviceIDString); + narrowDeviceID); /* Add an App Note for now so that we get the data immediately. These * can go away after we store the above in the socorro db */ nsCAutoString note; /* AppendPrintf only supports 32 character strings, mrghh. */ - note.AppendPrintf("AdapterVendorID: %04x, ", vendorID); - note.AppendPrintf("AdapterDeviceID: %04x", deviceID); + note.Append("AdapterVendorID: "); + note.Append(narrowVendorID); + note.Append(", AdapterDeviceID: "); + note.Append(narrowDeviceID); CrashReporter::AppendAppNotesToCrashReport(note); #endif } @@ -367,7 +367,7 @@ GfxInfo::GetGfxDriverInfo() { if (!mDriverInfo->Length()) { IMPLEMENT_MAC_DRIVER_BLOCKLIST(DRIVER_OS_ALL, - GfxDriverInfo::vendorATI, GfxDriverInfo::allDevices, + (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorATI), GfxDriverInfo::allDevices, nsIGfxInfo::FEATURE_WEBGL_MSAA, nsIGfxInfo::FEATURE_BLOCKED_OS_VERSION); } return *mDriverInfo; @@ -464,7 +464,8 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, bool foundGoodDevice = true; // Blacklist the Geforce 7300 GT because of bug 678053 - if (mAdapterVendorID == 0x10de && mAdapterDeviceID == 0x0393) { + if (mAdapterVendorID.LowerCaseEqualsLiteral("0x10de") && + mAdapterDeviceID.LowerCaseEqualsLiteral("0x0393")) { foundGoodDevice = false; } @@ -475,8 +476,9 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, if (aFeature == nsIGfxInfo::FEATURE_WEBGL_MSAA) { // Blacklist all ATI cards on OSX, except for // 0x6760 and 0x9488 - if (mAdapterVendorID == GfxDriverInfo::vendorATI && - (mAdapterDeviceID == 0x6760 || mAdapterDeviceID == 0x9488)) { + if (mAdapterVendorID == GfxDriverInfo::GetDeviceVendor(VendorATI) && + (mAdapterDeviceID.LowerCaseEqualsLiteral("0x6760") || + mAdapterDeviceID.LowerCaseEqualsLiteral("0x9488"))) { *aStatus = nsIGfxInfo::FEATURE_NO_INFO; return NS_OK; } diff --git a/widget/src/windows/GfxInfo.cpp b/widget/src/windows/GfxInfo.cpp index 4a92ed7c1e7f..775b40f7f2f7 100644 --- a/widget/src/windows/GfxInfo.cpp +++ b/widget/src/windows/GfxInfo.cpp @@ -49,6 +49,7 @@ #include "prprf.h" #include "GfxDriverInfo.h" #include "mozilla/Preferences.h" +#include "nsPrintfCString.h" #if defined(MOZ_CRASHREPORTER) #include "nsExceptionHandler.h" @@ -69,11 +70,7 @@ static const PRUint32 allWindowsVersions = 0xffffffff; GfxInfo::GfxInfo() - : mAdapterVendorID(0), - mAdapterDeviceID(0), - mAdapterVendorID2(0), - mAdapterDeviceID2(0), - mWindowsVersion(0), + : mWindowsVersion(0), mHasDualGPU(false), mIsGPU2Active(false) { @@ -428,8 +425,8 @@ GfxInfo::Init() setupDestroyDeviceInfoList(devinfo); } - mAdapterVendorID = ParseIDFromDeviceID(mDeviceID, "VEN_", 4); - mAdapterDeviceID = ParseIDFromDeviceID(mDeviceID, "&DEV_", 4); + mAdapterVendorID.AppendPrintf("0x%04x", ParseIDFromDeviceID(mDeviceID, "VEN_", 4)); + mAdapterDeviceID.AppendPrintf("0x%04x", ParseIDFromDeviceID(mDeviceID, "&DEV_", 4)); mAdapterSubsysID = ParseIDFromDeviceID(mDeviceID, "&SUBSYS_", 8); // We now check for second display adapter. @@ -479,10 +476,14 @@ GfxInfo::Init() continue; } deviceID2 = value; + nsAutoString adapterVendorID2String; + nsAutoString adapterDeviceID2String; adapterVendorID2 = ParseIDFromDeviceID(deviceID2, "VEN_", 4); + adapterVendorID2String.AppendPrintf("0x%04x", adapterVendorID2); adapterDeviceID2 = ParseIDFromDeviceID(deviceID2, "&DEV_", 4); - if ((adapterVendorID2 == mAdapterVendorID) && - (adapterDeviceID2 == mAdapterDeviceID)) { + adapterDeviceID2String.AppendPrintf("0x%04x", adapterDeviceID2); + if (mAdapterVendorID == adapterVendorID2String && + mAdapterDeviceID == adapterDeviceID2String) { RegCloseKey(key); continue; } @@ -518,8 +519,8 @@ GfxInfo::Init() mDeviceKey2 = driverKey2; mDriverVersion2 = driverVersion2; mDriverDate2 = driverDate2; - mAdapterVendorID2 = adapterVendorID2; - mAdapterDeviceID2 = adapterDeviceID2; + mAdapterVendorID2.AppendPrintf("0x%04x", adapterVendorID2); + mAdapterDeviceID2.AppendPrintf("0x%04x", adapterDeviceID2); mAdapterSubsysID2 = ParseIDFromDeviceID(mDeviceID2, "&SUBSYS_", 8); break; } @@ -544,11 +545,11 @@ GfxInfo::Init() const char *spoofedVendor = PR_GetEnv("MOZ_GFX_SPOOF_VENDOR_ID"); if (spoofedVendor) { - PR_sscanf(spoofedVendor, "%x", &mAdapterVendorID); + mAdapterVendorID.AssignASCII(spoofedVendor); } mHasDriverVersionMismatch = false; - if (mAdapterVendorID == GfxDriverInfo::vendorIntel) { + if (mAdapterVendorID == GfxDriverInfo::GetDeviceVendor(VendorIntel)) { // we've had big crashers (bugs 590373 and 595364) apparently correlated // with bad Intel driver installations where the DriverVersion reported // by the registry was not the version of the DLL. @@ -572,7 +573,7 @@ GfxInfo::Init() const char *spoofedDevice = PR_GetEnv("MOZ_GFX_SPOOF_DEVICE_ID"); if (spoofedDevice) { - PR_sscanf(spoofedDevice, "%x", &mAdapterDeviceID); + mAdapterDeviceID.AssignASCII(spoofedDevice); } const char *spoofedWindowsVersion = PR_GetEnv("MOZ_GFX_SPOOF_WINDOWS_VERSION"); @@ -677,35 +678,35 @@ GfxInfo::GetAdapterDriverDate2(nsAString & aAdapterDriverDate) return NS_OK; } -/* readonly attribute unsigned long adapterVendorID; */ +/* readonly attribute DOMString adapterVendorID; */ NS_IMETHODIMP -GfxInfo::GetAdapterVendorID(PRUint32 *aAdapterVendorID) +GfxInfo::GetAdapterVendorID(nsAString & aAdapterVendorID) { - *aAdapterVendorID = mAdapterVendorID; + aAdapterVendorID = mAdapterVendorID; return NS_OK; } -/* readonly attribute unsigned long adapterVendorID2; */ +/* readonly attribute DOMString adapterVendorID2; */ NS_IMETHODIMP -GfxInfo::GetAdapterVendorID2(PRUint32 *aAdapterVendorID) +GfxInfo::GetAdapterVendorID2(nsAString & aAdapterVendorID) { - *aAdapterVendorID = mAdapterVendorID2; + aAdapterVendorID = mAdapterVendorID2; return NS_OK; } -/* readonly attribute unsigned long adapterDeviceID; */ +/* readonly attribute DOMString adapterDeviceID; */ NS_IMETHODIMP -GfxInfo::GetAdapterDeviceID(PRUint32 *aAdapterDeviceID) +GfxInfo::GetAdapterDeviceID(nsAString & aAdapterDeviceID) { - *aAdapterDeviceID = mAdapterDeviceID; + aAdapterDeviceID = mAdapterDeviceID; return NS_OK; } -/* readonly attribute unsigned long adapterDeviceID2; */ +/* readonly attribute DOMString adapterDeviceID2; */ NS_IMETHODIMP -GfxInfo::GetAdapterDeviceID2(PRUint32 *aAdapterDeviceID) +GfxInfo::GetAdapterDeviceID2(nsAString & aAdapterDeviceID) { - *aAdapterDeviceID = mAdapterDeviceID2; + aAdapterDeviceID = mAdapterDeviceID2; return NS_OK; } @@ -740,52 +741,59 @@ GfxInfo::AddCrashReportAnnotations() #if defined(MOZ_CRASHREPORTER) CheckForCiscoVPN(); - nsCAutoString deviceIDString, vendorIDString; - PRUint32 deviceID, vendorID; + nsString deviceID, vendorID; + nsCString narrowDeviceID, narrowVendorID; nsAutoString adapterDriverVersionString; - GetAdapterDeviceID(&deviceID); - GetAdapterVendorID(&vendorID); + GetAdapterDeviceID(deviceID); + CopyUTF16toUTF8(deviceID, narrowDeviceID); + GetAdapterVendorID(vendorID); + CopyUTF16toUTF8(vendorID, narrowVendorID); GetAdapterDriverVersion(adapterDriverVersionString); - deviceIDString.AppendPrintf("%04x", deviceID); - vendorIDString.AppendPrintf("%04x", vendorID); - CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterVendorID"), - vendorIDString); + narrowVendorID); CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterDeviceID"), - deviceIDString); + narrowDeviceID); /* Add an App Note for now so that we get the data immediately. These * can go away after we store the above in the socorro db */ nsCAutoString note; /* AppendPrintf only supports 32 character strings, mrghh. */ - note.AppendPrintf("AdapterVendorID: %04x, ", vendorID); - note.AppendPrintf("AdapterDeviceID: %04x, ", deviceID); - note.AppendPrintf("AdapterSubsysID: %08x, ", mAdapterSubsysID); - note.AppendPrintf("AdapterDriverVersion: "); + note.Append("AdapterVendorID: "); + note.Append(narrowVendorID); + note.Append(", AdapterDeviceID: "); + note.Append(narrowDeviceID); + note.AppendPrintf(", AdapterSubsysID: %08x, ", mAdapterSubsysID); + note.Append("AdapterDriverVersion: "); note.Append(NS_LossyConvertUTF16toASCII(adapterDriverVersionString)); - if (vendorID == 0) { - /* if we didn't find a valid vendorID lets append the mDeviceID string to try to find out why */ - note.AppendLiteral(", "); - LossyAppendUTF16toASCII(mDeviceID, note); - note.AppendLiteral(", "); - LossyAppendUTF16toASCII(mDeviceKeyDebug, note); + if (vendorID == GfxDriverInfo::GetDeviceVendor(VendorAll)) { + /* if we didn't find a valid vendorID lets append the mDeviceID string to try to find out why */ + note.Append(", "); + note.AppendWithConversion(mDeviceID); + note.Append(", "); + note.AppendWithConversion(mDeviceKeyDebug); + LossyAppendUTF16toASCII(mDeviceKeyDebug, note); } note.Append("\n"); if (mHasDualGPU) { - PRUint32 deviceID2, vendorID2; + nsString deviceID2, vendorID2; nsAutoString adapterDriverVersionString2; + nsCString narrowDeviceID2, narrowVendorID2; note.AppendLiteral("Has dual GPUs. GPU #2: "); - GetAdapterDeviceID2(&deviceID2); - GetAdapterVendorID2(&vendorID2); + GetAdapterDeviceID2(deviceID2); + CopyUTF16toUTF8(deviceID2, narrowDeviceID2); + GetAdapterVendorID2(vendorID2); + CopyUTF16toUTF8(vendorID2, narrowVendorID2); GetAdapterDriverVersion2(adapterDriverVersionString2); - note.AppendPrintf("AdapterVendorID2: %04x, ", vendorID2); - note.AppendPrintf("AdapterDeviceID2: %04x, ", deviceID2); - note.AppendPrintf("AdapterSubsysID2: %08x, ", mAdapterSubsysID2); + note.Append("AdapterVendorID2: "); + note.Append(narrowVendorID2); + note.Append(", AdapterDeviceID2: "); + note.Append(narrowDeviceID2); + note.AppendPrintf(", AdapterSubsysID2: %08x, ", mAdapterSubsysID2); note.AppendPrintf("AdapterDriverVersion2: "); note.Append(NS_LossyConvertUTF16toASCII(adapterDriverVersionString2)); } @@ -818,39 +826,31 @@ const nsTArray& GfxInfo::GetGfxDriverInfo() { if (!mDriverInfo->Length()) { - /* + /* * NVIDIA entries */ APPEND_TO_DRIVER_BLOCKLIST( DRIVER_OS_WINDOWS_XP, - GfxDriverInfo::vendorNVIDIA, GfxDriverInfo::allDevices, + (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorNVIDIA), GfxDriverInfo::allDevices, GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN, V(6,14,12,5721), "257.21" ); APPEND_TO_DRIVER_BLOCKLIST( DRIVER_OS_WINDOWS_VISTA, - GfxDriverInfo::vendorNVIDIA, GfxDriverInfo::allDevices, + (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorNVIDIA), GfxDriverInfo::allDevices, GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN, V(8,17,12,5721), "257.21" ); APPEND_TO_DRIVER_BLOCKLIST( DRIVER_OS_WINDOWS_7, - GfxDriverInfo::vendorNVIDIA, GfxDriverInfo::allDevices, + (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorNVIDIA), GfxDriverInfo::allDevices, GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN, V(8,17,12,5721), "257.21" ); - /* Disable D3D9 layers on NVIDIA 6100/6150/6200 series due to glitches - * whilst scrolling. See bugs: 612007, 644787 & 645872. - */ - APPEND_TO_DRIVER_BLOCKLIST2( DRIVER_OS_ALL, - GfxDriverInfo::vendorNVIDIA, (GfxDeviceFamily) GfxDriverInfo::GetDeviceFamily(DeviceFamily::NvidiaBlockD3D9Layers), - nsIGfxInfo::FEATURE_DIRECT3D_9_LAYERS, nsIGfxInfo::FEATURE_BLOCKED_DEVICE, - DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions ); - /* * AMD/ATI entries */ APPEND_TO_DRIVER_BLOCKLIST( DRIVER_OS_ALL, - GfxDriverInfo::vendorATI, GfxDriverInfo::allDevices, + (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorATI), GfxDriverInfo::allDevices, GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN, V(8,741,0,0), "10.6" ); APPEND_TO_DRIVER_BLOCKLIST( DRIVER_OS_ALL, - GfxDriverInfo::vendorAMD, GfxDriverInfo::allDevices, + (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorAMD), GfxDriverInfo::allDevices, GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN, V(8,741,0,0), "10.6" ); @@ -861,19 +861,19 @@ GfxInfo::GetGfxDriverInfo() * + many complaints about incorrect rendering */ APPEND_TO_DRIVER_BLOCKLIST2( DRIVER_OS_ALL, - GfxDriverInfo::vendorATI, GfxDriverInfo::allDevices, + (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorATI), GfxDriverInfo::allDevices, nsIGfxInfo::FEATURE_OPENGL_LAYERS, nsIGfxInfo::FEATURE_DISCOURAGED, DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions ); APPEND_TO_DRIVER_BLOCKLIST2( DRIVER_OS_ALL, - GfxDriverInfo::vendorATI, GfxDriverInfo::allDevices, + (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorATI), GfxDriverInfo::allDevices, nsIGfxInfo::FEATURE_WEBGL_OPENGL, nsIGfxInfo::FEATURE_DISCOURAGED, DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions ); APPEND_TO_DRIVER_BLOCKLIST2( DRIVER_OS_ALL, - GfxDriverInfo::vendorAMD, GfxDriverInfo::allDevices, + (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorAMD), GfxDriverInfo::allDevices, nsIGfxInfo::FEATURE_OPENGL_LAYERS, nsIGfxInfo::FEATURE_DISCOURAGED, DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions ); APPEND_TO_DRIVER_BLOCKLIST2( DRIVER_OS_ALL, - GfxDriverInfo::vendorAMD, GfxDriverInfo::allDevices, + (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorAMD), GfxDriverInfo::allDevices, nsIGfxInfo::FEATURE_WEBGL_OPENGL, nsIGfxInfo::FEATURE_DISCOURAGED, DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions ); @@ -885,48 +885,56 @@ GfxInfo::GetGfxDriverInfo() * Block all features on any drivers before this, as there's a crash when a MS Hotfix is installed. * The crash itself is Direct2D-related, but for safety we block all features. */ - #define IMPLEMENT_INTEL_DRIVER_BLOCKLIST(winVer, devFamily, driverVer) \ - APPEND_TO_DRIVER_BLOCKLIST2( winVer, \ - GfxDriverInfo::vendorIntel, (GfxDeviceFamily) GfxDriverInfo::GetDeviceFamily(devFamily), \ - GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, \ + #define IMPLEMENT_INTEL_DRIVER_BLOCKLIST(winVer, devFamily, driverVer) \ + APPEND_TO_DRIVER_BLOCKLIST2( winVer, \ + (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorIntel), (GfxDeviceFamily*) GfxDriverInfo::GetDeviceFamily(devFamily), \ + GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, \ DRIVER_LESS_THAN, driverVer ) - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_XP, DeviceFamily::IntelGMA500, V(6,14,11,1018)); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_XP, DeviceFamily::IntelGMA900, V(6,14,10,4764)); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_XP, DeviceFamily::IntelGMA950, V(6,14,10,4926)); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_XP, DeviceFamily::IntelGMA3150, V(6,14,10,5260)); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_XP, DeviceFamily::IntelGMAX3000, V(6,14,10,5218)); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_XP, DeviceFamily::IntelGMAX4500HD, V(6,14,10,5284)); + IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_XP, IntelGMA500, V(6,14,11,1018)); + IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_XP, IntelGMA900, V(6,14,10,4764)); + IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_XP, IntelGMA950, V(6,14,10,4926)); + IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_XP, IntelGMA3150, V(6,14,10,5260)); + IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_XP, IntelGMAX3000, V(6,14,10,5218)); + IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_XP, IntelGMAX4500HD, V(6,14,10,5284)); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_VISTA, DeviceFamily::IntelGMA500, V(7,14,10,1006)); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_VISTA, DeviceFamily::IntelGMA900, GfxDriverInfo::allDriverVersions); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_VISTA, DeviceFamily::IntelGMA950, V(7,14,10,1504)); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_VISTA, DeviceFamily::IntelGMA3150, V(7,14,10,2124)); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_VISTA, DeviceFamily::IntelGMAX3000, V(7,15,10,1666)); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_VISTA, DeviceFamily::IntelGMAX4500HD, V(8,15,10,2202)); + IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_VISTA, IntelGMA500, V(7,14,10,1006)); + IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_VISTA, IntelGMA900, GfxDriverInfo::allDriverVersions); + IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_VISTA, IntelGMA950, V(7,14,10,1504)); + IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_VISTA, IntelGMA3150, V(7,14,10,2124)); + IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_VISTA, IntelGMAX3000, V(7,15,10,1666)); + IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_VISTA, IntelGMAX4500HD, V(8,15,10,2202)); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_7, DeviceFamily::IntelGMA500, V(5,0,0,2026)); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_7, DeviceFamily::IntelGMA900, GfxDriverInfo::allDriverVersions); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_7, DeviceFamily::IntelGMA950, V(8,15,10,1930)); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_7, DeviceFamily::IntelGMA3150, V(8,14,10,2117)); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_7, DeviceFamily::IntelGMAX3000, V(8,15,10,1930)); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_7, DeviceFamily::IntelGMAX4500HD, V(8,15,10,2202)); + IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_7, IntelGMA500, V(5,0,0,2026)); + IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_7, IntelGMA900, GfxDriverInfo::allDriverVersions); + IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_7, IntelGMA950, V(8,15,10,1930)); + IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_7, IntelGMA3150, V(8,14,10,2117)); + IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_7, IntelGMAX3000, V(8,15,10,1930)); + IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_7, IntelGMAX4500HD, V(8,15,10,2202)); - /* OpenGL on any Intel hardware is discouraged */ + /* OpenGL on any Intel hardware is discouraged */ APPEND_TO_DRIVER_BLOCKLIST2( DRIVER_OS_ALL, - GfxDriverInfo::vendorIntel, GfxDriverInfo::allDevices, + (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorIntel), GfxDriverInfo::allDevices, nsIGfxInfo::FEATURE_OPENGL_LAYERS, nsIGfxInfo::FEATURE_DISCOURAGED, DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions ); APPEND_TO_DRIVER_BLOCKLIST2( DRIVER_OS_ALL, - GfxDriverInfo::vendorIntel, GfxDriverInfo::allDevices, + (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorIntel), GfxDriverInfo::allDevices, nsIGfxInfo::FEATURE_WEBGL_OPENGL, nsIGfxInfo::FEATURE_DISCOURAGED, DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions ); + + /* Disable D3D9 layers on NVIDIA 6100/6150/6200 series due to glitches + * whilst scrolling. See bugs: 612007, 644787 & 645872. + */ + APPEND_TO_DRIVER_BLOCKLIST2( DRIVER_OS_ALL, + (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorNVIDIA), (GfxDeviceFamily*) GfxDriverInfo::GetDeviceFamily(NvidiaBlockD3D9Layers), + nsIGfxInfo::FEATURE_DIRECT3D_9_LAYERS, nsIGfxInfo::FEATURE_BLOCKED_DEVICE, + DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions ); } return *mDriverInfo; } nsresult -GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, +GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, PRInt32 *aStatus, nsAString & aSuggestedDriverVersion, const nsTArray& aDriverInfo, @@ -936,27 +944,27 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, PRInt32 status = nsIGfxInfo::FEATURE_STATUS_UNKNOWN; - PRUint32 adapterVendorID = 0; - PRUint32 adapterDeviceID = 0; + nsAutoString adapterVendorID; + nsAutoString adapterDeviceID; nsAutoString adapterDriverVersionString; - if (NS_FAILED(GetAdapterVendorID(&adapterVendorID)) || - NS_FAILED(GetAdapterDeviceID(&adapterDeviceID)) || + if (NS_FAILED(GetAdapterVendorID(adapterVendorID)) || + NS_FAILED(GetAdapterDeviceID(adapterDeviceID)) || NS_FAILED(GetAdapterDriverVersion(adapterDriverVersionString))) { return NS_ERROR_FAILURE; } - if (adapterVendorID != GfxDriverInfo::vendorIntel && - adapterVendorID != GfxDriverInfo::vendorNVIDIA && - adapterVendorID != GfxDriverInfo::vendorAMD && - adapterVendorID != GfxDriverInfo::vendorATI && + if (adapterVendorID != GfxDriverInfo::GetDeviceVendor(VendorIntel) && + adapterVendorID != GfxDriverInfo::GetDeviceVendor(VendorNVIDIA) && + adapterVendorID != GfxDriverInfo::GetDeviceVendor(VendorAMD) && + adapterVendorID != GfxDriverInfo::GetDeviceVendor(VendorATI) && // FIXME - these special hex values are currently used in xpcshell tests introduced by // bug 625160 patch 8/8. Maybe these tests need to be adjusted now that we're only whitelisting // intel/ati/nvidia. - adapterVendorID != 0xabcd && - adapterVendorID != 0xdcba && - adapterVendorID != 0xabab && - adapterVendorID != 0xdcdc) + !adapterVendorID.LowerCaseEqualsLiteral("0xabcd") && + !adapterVendorID.LowerCaseEqualsLiteral("0xdcba") && + !adapterVendorID.LowerCaseEqualsLiteral("0xabab") && + !adapterVendorID.LowerCaseEqualsLiteral("0xdcdc")) { *aStatus = FEATURE_BLOCKED_DEVICE; return NS_OK; @@ -971,8 +979,8 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, // whitelist them, actually we do know that this combination of device and driver version // works well. if (mWindowsVersion == gfxWindowsPlatform::kWindowsXP && - adapterVendorID == GfxDriverInfo::vendorNVIDIA && - adapterDeviceID == 0x0861 && // GeForce 9400 + adapterVendorID == GfxDriverInfo::GetDeviceVendor(VendorNVIDIA) && + adapterDeviceID.LowerCaseEqualsLiteral("0x0861") && // GeForce 9400 driverVersion == V(6,14,11,7756)) { *aStatus = FEATURE_NO_INFO; @@ -1026,14 +1034,16 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, /* void spoofVendorID (in unsigned long aVendorID); */ NS_IMETHODIMP GfxInfo::SpoofVendorID(PRUint32 aVendorID) { - mAdapterVendorID = aVendorID; + mAdapterVendorID.Truncate(0); + mAdapterVendorID.AppendPrintf("0x%04x", aVendorID); return NS_OK; } /* void spoofDeviceID (in unsigned long aDeviceID); */ NS_IMETHODIMP GfxInfo::SpoofDeviceID(PRUint32 aDeviceID) { - mAdapterDeviceID = aDeviceID; + mAdapterDeviceID.Truncate(0); + mAdapterDeviceID.AppendPrintf("0x%04x", aDeviceID); return NS_OK; } diff --git a/widget/src/windows/GfxInfo.h b/widget/src/windows/GfxInfo.h index 178e9c015e84..a75604ef88f8 100644 --- a/widget/src/windows/GfxInfo.h +++ b/widget/src/windows/GfxInfo.h @@ -63,15 +63,15 @@ public: NS_SCRIPTABLE NS_IMETHOD GetCleartypeParameters(nsAString & aCleartypeParams); NS_SCRIPTABLE NS_IMETHOD GetAdapterDescription(nsAString & aAdapterDescription); NS_SCRIPTABLE NS_IMETHOD GetAdapterDriver(nsAString & aAdapterDriver); - NS_SCRIPTABLE NS_IMETHOD GetAdapterVendorID(PRUint32 *aAdapterVendorID); - NS_SCRIPTABLE NS_IMETHOD GetAdapterDeviceID(PRUint32 *aAdapterDeviceID); + NS_SCRIPTABLE NS_IMETHOD GetAdapterVendorID(nsAString & aAdapterVendorID); + NS_SCRIPTABLE NS_IMETHOD GetAdapterDeviceID(nsAString & aAdapterDeviceID); NS_SCRIPTABLE NS_IMETHOD GetAdapterRAM(nsAString & aAdapterRAM); NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverVersion(nsAString & aAdapterDriverVersion); NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverDate(nsAString & aAdapterDriverDate); NS_SCRIPTABLE NS_IMETHOD GetAdapterDescription2(nsAString & aAdapterDescription); NS_SCRIPTABLE NS_IMETHOD GetAdapterDriver2(nsAString & aAdapterDriver); - NS_SCRIPTABLE NS_IMETHOD GetAdapterVendorID2(PRUint32 *aAdapterVendorID); - NS_SCRIPTABLE NS_IMETHOD GetAdapterDeviceID2(PRUint32 *aAdapterDeviceID); + NS_SCRIPTABLE NS_IMETHOD GetAdapterVendorID2(nsAString & aAdapterVendorID); + NS_SCRIPTABLE NS_IMETHOD GetAdapterDeviceID2(nsAString & aAdapterDeviceID); NS_SCRIPTABLE NS_IMETHOD GetAdapterRAM2(nsAString & aAdapterRAM); NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverVersion2(nsAString & aAdapterDriverVersion); NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverDate2(nsAString & aAdapterDriverDate); @@ -105,16 +105,16 @@ private: nsString mDriverDate; nsString mDeviceKey; nsString mDeviceKeyDebug; - PRUint32 mAdapterVendorID; - PRUint32 mAdapterDeviceID; + nsString mAdapterVendorID; + nsString mAdapterDeviceID; PRUint32 mAdapterSubsysID; nsString mDeviceString2; nsString mDriverVersion2; nsString mDeviceID2; nsString mDriverDate2; nsString mDeviceKey2; - PRUint32 mAdapterVendorID2; - PRUint32 mAdapterDeviceID2; + nsString mAdapterVendorID2; + nsString mAdapterDeviceID2; PRUint32 mAdapterSubsysID2; PRUint32 mWindowsVersion; bool mHasDualGPU; diff --git a/widget/src/xpwidgets/GfxDriverInfo.cpp b/widget/src/xpwidgets/GfxDriverInfo.cpp index 12dcc497b2d2..063f39985b8d 100644 --- a/widget/src/xpwidgets/GfxDriverInfo.cpp +++ b/widget/src/xpwidgets/GfxDriverInfo.cpp @@ -40,20 +40,16 @@ using namespace mozilla::widget; -PRUint32 GfxDriverInfo::allAdapterVendors = 0; PRInt32 GfxDriverInfo::allFeatures = 0; PRUint64 GfxDriverInfo::allDriverVersions = ~(PRUint64(0)); +GfxDeviceFamily* const GfxDriverInfo::allDevices = nsnull; -PRUint32 GfxDriverInfo::vendorIntel = 0x8086; -PRUint32 GfxDriverInfo::vendorNVIDIA = 0x10de; -PRUint32 GfxDriverInfo::vendorAMD = 0x1022; -PRUint32 GfxDriverInfo::vendorATI = 0x1002; - -GfxDeviceFamily GfxDriverInfo::allDevices = nsnull; +GfxDeviceFamily* GfxDriverInfo::mDeviceFamilies[DeviceFamilyMax]; +nsAString* GfxDriverInfo::mDeviceVendors[DeviceVendorMax]; GfxDriverInfo::GfxDriverInfo() : mOperatingSystem(DRIVER_OS_UNKNOWN), - mAdapterVendor(allAdapterVendors), + mAdapterVendor(GfxDriverInfo::GetDeviceVendor(VendorAll)), mDevices(allDevices), mDeleteDevices(false), mFeature(allFeatures), @@ -64,8 +60,8 @@ GfxDriverInfo::GfxDriverInfo() mSuggestedVersion(nsnull) {} -GfxDriverInfo::GfxDriverInfo(OperatingSystem os, PRUint32 vendor, - GfxDeviceFamily devices, +GfxDriverInfo::GfxDriverInfo(OperatingSystem os, nsAString& vendor, + GfxDeviceFamily* devices, PRInt32 feature, PRInt32 featureStatus, VersionComparisonOp op, PRUint64 driverVersion, @@ -93,18 +89,11 @@ GfxDriverInfo::GfxDriverInfo(const GfxDriverInfo& aOrig) mDriverVersionMax(aOrig.mDriverVersionMax), mSuggestedVersion(aOrig.mSuggestedVersion) { - // If we're managing the lifetime of the devices array, we have to make a - // copy of the original's array. - if (aOrig.mDeleteDevices) { - PRUint32 count = 0; - const PRUint32 *device = aOrig.mDevices; - while (*device) { - count++; - device++; - } - - mDevices = new PRUint32[count + 1]; - memcpy(mDevices, aOrig.mDevices, sizeof(PRUint32) * (count + 1)); + // If we're managing the lifetime of the device family, we have to make a + // copy of the original's device family. + if (aOrig.mDeleteDevices && aOrig.mDevices) { + mDevices = new GfxDeviceFamily; + *mDevices = *aOrig.mDevices; } else { mDevices = aOrig.mDevices; } @@ -115,133 +104,150 @@ GfxDriverInfo::GfxDriverInfo(const GfxDriverInfo& aOrig) GfxDriverInfo::~GfxDriverInfo() { if (mDeleteDevices) - delete[] mDevices; + delete mDevices; } -const GfxDeviceFamily GfxDriverInfo::GetDeviceFamily(DeviceFamily id) +// Macros for appending a device to the DeviceFamily. +#define APPEND_DEVICE(device) APPEND_DEVICE2(#device) +#define APPEND_DEVICE2(device) deviceFamily->AppendElement(NS_LITERAL_STRING(device)) + +const GfxDeviceFamily* GfxDriverInfo::GetDeviceFamily(DeviceFamily id) { + // The code here is too sensitive to fall through to the default case if the + // code is invalid. + NS_ASSERTION(id >= 0 && id < DeviceFamilyMax, "DeviceFamily id is out of range"); + + // If it already exists, we must have processed it once, so return it now. + if (mDeviceFamilies[id]) + return mDeviceFamilies[id]; + + mDeviceFamilies[id] = new GfxDeviceFamily; + GfxDeviceFamily* deviceFamily = mDeviceFamilies[id]; + switch (id) { - case IntelGMA500: { - static const PRUint32 intelGMA500[] = { - 0x8108, /* IntelGMA500_1 */ - 0x8109, /* IntelGMA500_2 */ - 0 - }; - return (const GfxDeviceFamily) &intelGMA500[0]; - } - case IntelGMA900: { - static const PRUint32 intelGMA900[] = { - 0x2582, /* IntelGMA900_1 */ - 0x2782, /* IntelGMA900_2 */ - 0x2592, /* IntelGMA900_3 */ - 0x2792, /* IntelGMA900_4 */ - 0 - }; - return (const GfxDeviceFamily) &intelGMA900[0]; - } - case IntelGMA950: { - static const PRUint32 intelGMA950[] = { - 0x2772, /* Intel945G_1 */ - 0x2776, /* Intel945G_2 */ - 0x27A2, /* Intel945_1 */ - 0x27A6, /* Intel945_2 */ - 0x27AE, /* Intel945_3 */ - 0 - }; - return (const GfxDeviceFamily) &intelGMA950[0]; - } - case IntelGMA3150: { - static const PRUint32 intelGMA3150[] = { - 0xA001, /* IntelGMA3150_Nettop_1 */ - 0xA002, /* IntelGMA3150_Nettop_2 */ - 0xA011, /* IntelGMA3150_Netbook_1 */ - 0xA012, /* IntelGMA3150_Netbook_2 */ - 0 - }; - return (const GfxDeviceFamily) &intelGMA3150[0]; - } - case IntelGMAX3000: { - static const PRUint32 intelGMAX3000[] = { - 0x2972, /* Intel946GZ_1 */ - 0x2973, /* Intel946GZ_2 */ - 0x2982, /* IntelG35_1 */ - 0x2983, /* IntelG35_2 */ - 0x2992, /* IntelQ965_1 */ - 0x2993, /* IntelQ965_2 */ - 0x29A2, /* IntelG965_1 */ - 0x29A3, /* IntelG965_2 */ - 0x29B2, /* IntelQ35_1 */ - 0x29B3, /* IntelQ35_2 */ - 0x29C2, /* IntelG33_1 */ - 0x29C3, /* IntelG33_2 */ - 0x29D2, /* IntelQ33_1 */ - 0x29D3, /* IntelQ33_2 */ - 0x2A02, /* IntelGL960_1 */ - 0x2A03, /* IntelGL960_2 */ - 0x2A12, /* IntelGM965_1 */ - 0x2A13, /* IntelGM965_2 */ - 0 - }; - return (const GfxDeviceFamily) &intelGMAX3000[0]; - } - case IntelGMAX4500HD: { - static const PRUint32 intelGMAX4500HD[] = { - 0x2A42, /* IntelGMA4500MHD_1 */ - 0x2A43, /* IntelGMA4500MHD_2 */ - 0x2E42, /* IntelB43_1 */ - 0x2E43, /* IntelB43_2 */ - 0x2E92, /* IntelB43_3 */ - 0x2E93, /* IntelB43_4 */ - 0x2E32, /* IntelG41_1 */ - 0x2E33, /* IntelG41_2 */ - 0x2E22, /* IntelG45_1 */ - 0x2E23, /* IntelG45_2 */ - 0x2E12, /* IntelQ45_1 */ - 0x2E13, /* IntelQ45_2 */ - 0x0042, /* IntelHDGraphics */ - 0x0046, /* IntelMobileHDGraphics */ - 0x0102, /* IntelSandyBridge_1 */ - 0x0106, /* IntelSandyBridge_2 */ - 0x0112, /* IntelSandyBridge_3 */ - 0x0116, /* IntelSandyBridge_4 */ - 0x0122, /* IntelSandyBridge_5 */ - 0x0126, /* IntelSandyBridge_6 */ - 0x010A, /* IntelSandyBridge_7 */ - 0x0080, /* IntelIvyBridge */ - 0 - }; - return (const GfxDeviceFamily) &intelGMAX4500HD[0]; - } - case NvidiaBlockD3D9Layers: { + case IntelGMA500: + APPEND_DEVICE(0x8108); /* IntelGMA500_1 */ + APPEND_DEVICE(0x8109); /* IntelGMA500_2 */ + break; + case IntelGMA900: + APPEND_DEVICE(0x2582); /* IntelGMA900_1 */ + APPEND_DEVICE(0x2782); /* IntelGMA900_2 */ + APPEND_DEVICE(0x2592); /* IntelGMA900_3 */ + APPEND_DEVICE(0x2792); /* IntelGMA900_4 */ + break; + case IntelGMA950: + APPEND_DEVICE(0x2772); /* Intel945G_1 */ + APPEND_DEVICE(0x2776); /* Intel945G_2 */ + APPEND_DEVICE(0x27a2); /* Intel945_1 */ + APPEND_DEVICE(0x27a6); /* Intel945_2 */ + APPEND_DEVICE(0x27ae); /* Intel945_3 */ + break; + case IntelGMA3150: + APPEND_DEVICE(0xa001); /* IntelGMA3150_Nettop_1 */ + APPEND_DEVICE(0xa002); /* IntelGMA3150_Nettop_2 */ + APPEND_DEVICE(0xa011); /* IntelGMA3150_Netbook_1 */ + APPEND_DEVICE(0xa012); /* IntelGMA3150_Netbook_2 */ + break; + case IntelGMAX3000: + APPEND_DEVICE(0x2972); /* Intel946GZ_1 */ + APPEND_DEVICE(0x2973); /* Intel946GZ_2 */ + APPEND_DEVICE(0x2982); /* IntelG35_1 */ + APPEND_DEVICE(0x2983); /* IntelG35_2 */ + APPEND_DEVICE(0x2992); /* IntelQ965_1 */ + APPEND_DEVICE(0x2993); /* IntelQ965_2 */ + APPEND_DEVICE(0x29a2); /* IntelG965_1 */ + APPEND_DEVICE(0x29a3); /* IntelG965_2 */ + APPEND_DEVICE(0x29b2); /* IntelQ35_1 */ + APPEND_DEVICE(0x29b3); /* IntelQ35_2 */ + APPEND_DEVICE(0x29c2); /* IntelG33_1 */ + APPEND_DEVICE(0x29c3); /* IntelG33_2 */ + APPEND_DEVICE(0x29d2); /* IntelQ33_1 */ + APPEND_DEVICE(0x29d3); /* IntelQ33_2 */ + APPEND_DEVICE(0x2a02); /* IntelGL960_1 */ + APPEND_DEVICE(0x2a03); /* IntelGL960_2 */ + APPEND_DEVICE(0x2a12); /* IntelGM965_1 */ + APPEND_DEVICE(0x2a13); /* IntelGM965_2 */ + break; + case IntelGMAX4500HD: + APPEND_DEVICE(0x2a42); /* IntelGMA4500MHD_1 */ + APPEND_DEVICE(0x2a43); /* IntelGMA4500MHD_2 */ + APPEND_DEVICE(0x2e42); /* IntelB43_1 */ + APPEND_DEVICE(0x2e43); /* IntelB43_2 */ + APPEND_DEVICE(0x2e92); /* IntelB43_3 */ + APPEND_DEVICE(0x2e93); /* IntelB43_4 */ + APPEND_DEVICE(0x2e32); /* IntelG41_1 */ + APPEND_DEVICE(0x2e33); /* IntelG41_2 */ + APPEND_DEVICE(0x2e22); /* IntelG45_1 */ + APPEND_DEVICE(0x2e23); /* IntelG45_2 */ + APPEND_DEVICE(0x2e12); /* IntelQ45_1 */ + APPEND_DEVICE(0x2e13); /* IntelQ45_2 */ + APPEND_DEVICE(0x0042); /* IntelHDGraphics */ + APPEND_DEVICE(0x0046); /* IntelMobileHDGraphics */ + APPEND_DEVICE(0x0102); /* IntelSandyBridge_1 */ + APPEND_DEVICE(0x0106); /* IntelSandyBridge_2 */ + APPEND_DEVICE(0x0112); /* IntelSandyBridge_3 */ + APPEND_DEVICE(0x0116); /* IntelSandyBridge_4 */ + APPEND_DEVICE(0x0122); /* IntelSandyBridge_5 */ + APPEND_DEVICE(0x0126); /* IntelSandyBridge_6 */ + APPEND_DEVICE(0x010a); /* IntelSandyBridge_7 */ + APPEND_DEVICE(0x0080); /* IntelIvyBridge */ + break; + case NvidiaBlockD3D9Layers: // Glitches whilst scrolling (see bugs 612007, 644787, 645872) - static const PRUint32 nvidiaBlockD3D9Layers[] = { - 0x00f3, /* NV43 [GeForce 6200 (TM)] */ - 0x0146, /* NV43 [Geforce Go 6600TE/6200TE (TM)] */ - 0x014f, /* NV43 [GeForce 6200 (TM)] */ - 0x0161, /* NV44 [GeForce 6200 TurboCache (TM)] */ - 0x0162, /* NV44 [GeForce 6200SE TurboCache (TM)] */ - 0x0163, /* NV44 [GeForce 6200 LE (TM)] */ - 0x0164, /* NV44 [GeForce Go 6200 (TM)] */ - 0x0167, /* NV43 [GeForce Go 6200/6400 (TM)] */ - 0x0168, /* NV43 [GeForce Go 6200/6400 (TM)] */ - 0x0169, /* NV44 [GeForce 6250 (TM)] */ - 0x0222, /* NV44 [GeForce 6200 A-LE (TM)] */ - 0x0240, /* C51PV [GeForce 6150 (TM)] */ - 0x0241, /* C51 [GeForce 6150 LE (TM)] */ - 0x0244, /* C51 [Geforce Go 6150 (TM)] */ - 0x0245, /* C51 [Quadro NVS 210S/GeForce 6150LE (TM)] */ - 0x0247, /* C51 [GeForce Go 6100 (TM)] */ - 0x03d0, /* C61 [GeForce 6150SE nForce 430 (TM)] */ - 0x03d1, /* C61 [GeForce 6100 nForce 405 (TM)] */ - 0x03d2, /* C61 [GeForce 6100 nForce 400 (TM)] */ - 0x03d5, /* C61 [GeForce 6100 nForce 420 (TM)] */ - 0 - }; - return (const GfxDeviceFamily) &nvidiaBlockD3D9Layers[0]; - } - default: - NS_WARNING("Invalid device family"); + APPEND_DEVICE(0x00f3); /* NV43 [GeForce 6200 (TM)] */ + APPEND_DEVICE(0x0146); /* NV43 [Geforce Go 6600TE/6200TE (TM)] */ + APPEND_DEVICE(0x014f); /* NV43 [GeForce 6200 (TM)] */ + APPEND_DEVICE(0x0161); /* NV44 [GeForce 6200 TurboCache (TM)] */ + APPEND_DEVICE(0x0162); /* NV44 [GeForce 6200SE TurboCache (TM)] */ + APPEND_DEVICE(0x0163); /* NV44 [GeForce 6200 LE (TM)] */ + APPEND_DEVICE(0x0164); /* NV44 [GeForce Go 6200 (TM)] */ + APPEND_DEVICE(0x0167); /* NV43 [GeForce Go 6200/6400 (TM)] */ + APPEND_DEVICE(0x0168); /* NV43 [GeForce Go 6200/6400 (TM)] */ + APPEND_DEVICE(0x0169); /* NV44 [GeForce 6250 (TM)] */ + APPEND_DEVICE(0x0222); /* NV44 [GeForce 6200 A-LE (TM)] */ + APPEND_DEVICE(0x0240); /* C51PV [GeForce 6150 (TM)] */ + APPEND_DEVICE(0x0241); /* C51 [GeForce 6150 LE (TM)] */ + APPEND_DEVICE(0x0244); /* C51 [Geforce Go 6150 (TM)] */ + APPEND_DEVICE(0x0245); /* C51 [Quadro NVS 210S/GeForce 6150LE (TM)] */ + APPEND_DEVICE(0x0247); /* C51 [GeForce Go 6100 (TM)] */ + APPEND_DEVICE(0x03d0); /* C61 [GeForce 6150SE nForce 430 (TM)] */ + APPEND_DEVICE(0x03d1); /* C61 [GeForce 6100 nForce 405 (TM)] */ + APPEND_DEVICE(0x03d2); /* C61 [GeForce 6100 nForce 400 (TM)] */ + APPEND_DEVICE(0x03d5); /* C61 [GeForce 6100 nForce 420 (TM)] */ + break; + // This should never happen, but we get a warning if we don't handle this. + case DeviceFamilyMax: + NS_WARNING("Invalid DeviceFamily id"); + break; } - return nsnull; + return deviceFamily; +} + +// Macro for assigning a device vendor id to a string. +#define DECLARE_VENDOR_ID(name, deviceId) \ + case name: \ + mDeviceVendors[id]->AssignLiteral(deviceId); \ + break; + +const nsAString& GfxDriverInfo::GetDeviceVendor(DeviceVendor id) +{ + NS_ASSERTION(id >= 0 && id < DeviceVendorMax, "DeviceVendor id is out of range"); + + if (mDeviceVendors[id]) + return *mDeviceVendors[id]; + + mDeviceVendors[id] = new nsString(); + + switch (id) { + DECLARE_VENDOR_ID(VendorAll, ""); + DECLARE_VENDOR_ID(VendorIntel, "0x8086"); + DECLARE_VENDOR_ID(VendorNVIDIA, "0x10de"); + DECLARE_VENDOR_ID(VendorAMD, "0x1022"); + DECLARE_VENDOR_ID(VendorATI, "0x1002"); + // Suppress a warning. + DECLARE_VENDOR_ID(DeviceVendorMax, ""); + } + + return *mDeviceVendors[id]; } diff --git a/widget/src/xpwidgets/GfxDriverInfo.h b/widget/src/xpwidgets/GfxDriverInfo.h index c446e45bbd5a..22a406222aab 100644 --- a/widget/src/xpwidgets/GfxDriverInfo.h +++ b/widget/src/xpwidgets/GfxDriverInfo.h @@ -43,6 +43,7 @@ #define V(a,b,c,d) GFX_DRIVER_VERSION(a,b,c,d) +// Macros for adding a blocklist item to the static list. #define APPEND_TO_DRIVER_BLOCKLIST(os, vendor, devices, feature, featureStatus, driverComparator, driverVersion, suggestedVersion) \ mDriverInfo->AppendElement(GfxDriverInfo(os, vendor, devices, feature, featureStatus, driverComparator, driverVersion, suggestedVersion)) #define APPEND_TO_DRIVER_BLOCKLIST2(os, vendor, devices, feature, featureStatus, driverComparator, driverVersion) \ @@ -86,17 +87,27 @@ enum DeviceFamily { IntelGMA3150, IntelGMAX3000, IntelGMAX4500HD, - NvidiaBlockD3D9Layers + NvidiaBlockD3D9Layers, + DeviceFamilyMax }; -/* A zero-terminated array of devices to match, or all devices */ -typedef PRUint32* GfxDeviceFamily; +enum DeviceVendor { + VendorAll, + VendorIntel, + VendorNVIDIA, + VendorAMD, + VendorATI, + DeviceVendorMax +}; + +/* Array of devices to match, or an empty array for all devices */ +typedef nsTArray GfxDeviceFamily; struct GfxDriverInfo { // If |ownDevices| is true, you are transferring ownership of the devices // array, and it will be deleted when this GfxDriverInfo is destroyed. - GfxDriverInfo(OperatingSystem os, PRUint32 vendor, GfxDeviceFamily devices, + GfxDriverInfo(OperatingSystem os, nsAString& vendor, GfxDeviceFamily* devices, PRInt32 feature, PRInt32 featureStatus, VersionComparisonOp op, PRUint64 driverVersion, const char *suggestedVersion = nsnull, bool ownDevices = false); @@ -107,11 +118,10 @@ struct GfxDriverInfo OperatingSystem mOperatingSystem; - PRUint32 mAdapterVendor; - static PRUint32 allAdapterVendors; + nsString mAdapterVendor; - GfxDeviceFamily mDevices; - static GfxDeviceFamily allDevices; + static GfxDeviceFamily* const allDevices; + GfxDeviceFamily* mDevices; // Whether the mDevices array should be deleted when this structure is // deallocated. False by default. @@ -131,14 +141,13 @@ struct GfxDriverInfo PRUint64 mDriverVersionMax; static PRUint64 allDriverVersions; - static PRUint32 vendorIntel; - static PRUint32 vendorNVIDIA; - static PRUint32 vendorAMD; - static PRUint32 vendorATI; - const char *mSuggestedVersion; - static const GfxDeviceFamily GetDeviceFamily(DeviceFamily id); + static const GfxDeviceFamily* GetDeviceFamily(DeviceFamily id); + static GfxDeviceFamily* mDeviceFamilies[DeviceFamilyMax]; + + static const nsAString& GetDeviceVendor(DeviceVendor id); + static nsAString* mDeviceVendors[DeviceVendorMax]; }; #define GFX_DRIVER_VERSION(a,b,c,d) \ diff --git a/widget/src/xpwidgets/GfxInfoBase.cpp b/widget/src/xpwidgets/GfxInfoBase.cpp index a436cb21b231..15acbeccb12d 100644 --- a/widget/src/xpwidgets/GfxInfoBase.cpp +++ b/widget/src/xpwidgets/GfxInfoBase.cpp @@ -80,10 +80,16 @@ public: const PRUnichar *aData) { MOZ_ASSERT(strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0); - if (GfxInfoBase::mDriverInfo) { - delete GfxInfoBase::mDriverInfo; - GfxInfoBase::mDriverInfo = nsnull; - } + + delete GfxInfoBase::mDriverInfo; + GfxInfoBase::mDriverInfo = nsnull; + + for (PRUint32 i = 0; i < DeviceFamilyMax; i++) + delete GfxDriverInfo::mDeviceFamilies[i]; + + for (PRUint32 i = 0; i < DeviceVendorMax; i++) + delete GfxDriverInfo::mDeviceVendors[i]; + return NS_OK; } }; @@ -307,29 +313,16 @@ BlacklistOSToOperatingSystem(const nsAString& os) return DRIVER_OS_UNKNOWN; } -static PRUint32 -BlacklistHexToInt(const nsAString& aHex) -{ - PRInt32 err; - // nsAString doesn't have .ToInteger() :( - nsAutoString hex(aHex); - PRInt32 value = hex.ToInteger(&err, 16); - if (NS_FAILED(err)) - return 0; - return (PRUint32) value; -} - -static PRUint32* +static GfxDeviceFamily* BlacklistDevicesToDeviceFamily(nsIDOMNodeList* aDevices) { PRUint32 length; if (NS_FAILED(aDevices->GetLength(&length))) return nsnull; - // For each , get its device ID, and return a freshly-allocated array - // with the contents of that array. - nsAutoArrayPtr deviceIds(new PRUint32[length + 1]); - memset(deviceIds, 0, sizeof(PRUint32) * (length + 1)); + // For each , get its device ID, and return a freshly-allocated + // GfxDeviceFamily with the contents of that array. + GfxDeviceFamily* deviceIds = new GfxDeviceFamily; for (PRUint32 i = 0; i < length; ++i) { nsCOMPtr node; @@ -340,10 +333,10 @@ BlacklistDevicesToDeviceFamily(nsIDOMNodeList* aDevices) if (!BlacklistNodeToTextValue(node, deviceValue)) continue; - deviceIds[i] = BlacklistHexToInt(deviceValue); + deviceIds->AppendElement(deviceValue); } - return deviceIds.forget(); + return deviceIds; } static PRInt32 @@ -478,7 +471,7 @@ BlacklistEntryToDriverInfo(nsIDOMNode* aBlacklistEntry, if (BlacklistNodeGetChildByName(element, NS_LITERAL_STRING("vendor"), getter_AddRefs(dataNode))) { BlacklistNodeToTextValue(dataNode, dataValue); - aDriverInfo.mAdapterVendor = BlacklistHexToInt(dataValue); + aDriverInfo.mAdapterVendor = dataValue; } // @@ -495,7 +488,7 @@ BlacklistEntryToDriverInfo(nsIDOMNode* aBlacklistEntry, nsCOMPtr devices; if (NS_SUCCEEDED(devicesElement->GetElementsByTagName(NS_LITERAL_STRING("device"), getter_AddRefs(devices)))) { - PRUint32* deviceIds = BlacklistDevicesToDeviceFamily(devices); + GfxDeviceFamily* deviceIds = BlacklistDevicesToDeviceFamily(devices); if (deviceIds) { // Get GfxDriverInfo to adopt the devices array we created. aDriverInfo.mDeleteDevices = true; @@ -548,6 +541,8 @@ BlacklistEntriesToDriverInfo(nsIDOMNodeList* aBlacklistEntries, if (NS_FAILED(aBlacklistEntries->GetLength(&length))) return; + aDriverInfo.Clear(); + aDriverInfo.SetLength(length); for (PRUint32 i = 0; i < length; ++i) { nsCOMPtr blacklistEntry; if (NS_SUCCEEDED(aBlacklistEntries->Item(i, @@ -555,8 +550,10 @@ BlacklistEntriesToDriverInfo(nsIDOMNodeList* aBlacklistEntries, blacklistEntry) { GfxDriverInfo di; if (BlacklistEntryToDriverInfo(blacklistEntry, di)) { - aDriverInfo.AppendElement(di); + aDriverInfo[i] = di; } + // Prevent di falling out of scope from destroying the devices. + di.mDeleteDevices = false; } } } @@ -576,7 +573,6 @@ GfxInfoBase::Observe(nsISupports* aSubject, const char* aTopic, { nsTArray driverInfo; BlacklistEntriesToDriverInfo(blacklistEntries, driverInfo); - EvaluateDownloadedBlacklist(driverInfo); } } @@ -597,6 +593,8 @@ GfxInfoBase::~GfxInfoBase() nsresult GfxInfoBase::Init() { + InitGfxDriverInfoShutdownObserver(); + nsCOMPtr os = mozilla::services::GetObserverService(); if (os) { os->AddObserver(this, "blocklist-data-gfxItems", true); @@ -624,11 +622,11 @@ GfxInfoBase::FindBlocklistedDeviceInList(const nsTArray& info, { PRInt32 status = nsIGfxInfo::FEATURE_STATUS_UNKNOWN; - PRUint32 adapterVendorID = 0; - PRUint32 adapterDeviceID = 0; + nsAutoString adapterVendorID; + nsAutoString adapterDeviceID; nsAutoString adapterDriverVersionString; - if (NS_FAILED(GetAdapterVendorID(&adapterVendorID)) || - NS_FAILED(GetAdapterDeviceID(&adapterDeviceID)) || + if (NS_FAILED(GetAdapterVendorID(adapterVendorID)) || + NS_FAILED(GetAdapterDeviceID(adapterDeviceID)) || NS_FAILED(GetAdapterDriverVersion(adapterDriverVersionString))) { return NS_OK; @@ -645,15 +643,15 @@ GfxInfoBase::FindBlocklistedDeviceInList(const nsTArray& info, continue; } - if (info[i].mAdapterVendor != GfxDriverInfo::allAdapterVendors && + if (info[i].mAdapterVendor != GfxDriverInfo::GetDeviceVendor(VendorAll) && info[i].mAdapterVendor != adapterVendorID) { continue; } - if (info[i].mDevices != GfxDriverInfo::allDevices) { + if (info[i].mDevices != GfxDriverInfo::allDevices && info[i].mDevices->Length()) { bool deviceMatches = false; - for (const PRUint32 *devices = info[i].mDevices; *devices; ++devices) { - if (*devices == adapterDeviceID) { + for (PRUint32 j = 0; j < info[i].mDevices->Length(); j++) { + if ((*info[i].mDevices)[j] == adapterDeviceID) { deviceMatches = true; break; } @@ -755,11 +753,11 @@ GfxInfoBase::GetFeatureStatusImpl(PRInt32 aFeature, if (aOS) os = *aOS; - PRUint32 adapterVendorID = 0; - PRUint32 adapterDeviceID = 0; + nsAutoString adapterVendorID; + nsAutoString adapterDeviceID; nsAutoString adapterDriverVersionString; - if (NS_FAILED(GetAdapterVendorID(&adapterVendorID)) || - NS_FAILED(GetAdapterDeviceID(&adapterDeviceID)) || + if (NS_FAILED(GetAdapterVendorID(adapterVendorID)) || + NS_FAILED(GetAdapterDeviceID(adapterDeviceID)) || NS_FAILED(GetAdapterDriverVersion(adapterDriverVersionString))) { return NS_OK; @@ -772,11 +770,13 @@ GfxInfoBase::GetFeatureStatusImpl(PRInt32 aFeature, // the static list after that. This order is used so that we can later escape // out of static blocks (i.e. if we were wrong or something was patched, we // can back out our static block without doing a release). - InitGfxDriverInfoShutdownObserver(); - if (!mDriverInfo) - mDriverInfo = new nsTArray(); - PRInt32 status = FindBlocklistedDeviceInList(aDriverInfo, aSuggestedVersion, aFeature, os); - if (status == nsIGfxInfo::FEATURE_STATUS_UNKNOWN) { + PRInt32 status; + if (aDriverInfo.Length()) { + status = FindBlocklistedDeviceInList(aDriverInfo, aSuggestedVersion, aFeature, os); + } else { + if (!mDriverInfo) { + mDriverInfo = new nsTArray(); + } status = FindBlocklistedDeviceInList(GetGfxDriverInfo(), aSuggestedVersion, aFeature, os); } diff --git a/widget/src/xpwidgets/GfxInfoX11.cpp b/widget/src/xpwidgets/GfxInfoX11.cpp index 1c7b94b2f87e..f0e2c94e63ea 100644 --- a/widget/src/xpwidgets/GfxInfoX11.cpp +++ b/widget/src/xpwidgets/GfxInfoX11.cpp @@ -434,32 +434,32 @@ GfxInfo::GetAdapterDriverDate2(nsAString & aAdapterDriverDate) return NS_ERROR_FAILURE; } -/* readonly attribute unsigned long adapterVendorID; */ +/* readonly attribute DOMString adapterVendorID; */ NS_IMETHODIMP -GfxInfo::GetAdapterVendorID(PRUint32 *aAdapterVendorID) +GfxInfo::GetAdapterVendorID(nsAString & aAdapterVendorID) { - *aAdapterVendorID = 0; + aAdapterVendorID.AssignLiteral(""); return NS_OK; } -/* readonly attribute unsigned long adapterVendorID2; */ +/* readonly attribute DOMString adapterVendorID2; */ NS_IMETHODIMP -GfxInfo::GetAdapterVendorID2(PRUint32 *aAdapterVendorID) +GfxInfo::GetAdapterVendorID2(nsAString & aAdapterVendorID) { return NS_ERROR_FAILURE; } -/* readonly attribute unsigned long adapterDeviceID; */ +/* readonly attribute DOMString adapterDeviceID; */ NS_IMETHODIMP -GfxInfo::GetAdapterDeviceID(PRUint32 *aAdapterDeviceID) +GfxInfo::GetAdapterDeviceID(nsAString & aAdapterDeviceID) { - *aAdapterDeviceID = 0; + aAdapterDeviceID.AssignLiteral(""); return NS_OK; } -/* readonly attribute unsigned long adapterDeviceID2; */ +/* readonly attribute DOMString adapterDeviceID2; */ NS_IMETHODIMP -GfxInfo::GetAdapterDeviceID2(PRUint32 *aAdapterDeviceID) +GfxInfo::GetAdapterDeviceID2(nsAString & aAdapterDeviceID) { return NS_ERROR_FAILURE; } diff --git a/widget/src/xpwidgets/GfxInfoX11.h b/widget/src/xpwidgets/GfxInfoX11.h index 43690c00ca13..a7212eddfeca 100644 --- a/widget/src/xpwidgets/GfxInfoX11.h +++ b/widget/src/xpwidgets/GfxInfoX11.h @@ -58,15 +58,15 @@ public: NS_SCRIPTABLE NS_IMETHOD GetCleartypeParameters(nsAString & aCleartypeParams); NS_SCRIPTABLE NS_IMETHOD GetAdapterDescription(nsAString & aAdapterDescription); NS_SCRIPTABLE NS_IMETHOD GetAdapterDriver(nsAString & aAdapterDriver); - NS_SCRIPTABLE NS_IMETHOD GetAdapterVendorID(PRUint32 *aAdapterVendorID); - NS_SCRIPTABLE NS_IMETHOD GetAdapterDeviceID(PRUint32 *aAdapterDeviceID); + NS_SCRIPTABLE NS_IMETHOD GetAdapterVendorID(nsAString & aAdapterVendorID); + NS_SCRIPTABLE NS_IMETHOD GetAdapterDeviceID(nsAString & aAdapterDeviceID); NS_SCRIPTABLE NS_IMETHOD GetAdapterRAM(nsAString & aAdapterRAM); NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverVersion(nsAString & aAdapterDriverVersion); NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverDate(nsAString & aAdapterDriverDate); NS_SCRIPTABLE NS_IMETHOD GetAdapterDescription2(nsAString & aAdapterDescription); NS_SCRIPTABLE NS_IMETHOD GetAdapterDriver2(nsAString & aAdapterDriver); - NS_SCRIPTABLE NS_IMETHOD GetAdapterVendorID2(PRUint32 *aAdapterVendorID); - NS_SCRIPTABLE NS_IMETHOD GetAdapterDeviceID2(PRUint32 *aAdapterDeviceID); + NS_SCRIPTABLE NS_IMETHOD GetAdapterVendorID2(nsAString & aAdapterVendorID); + NS_SCRIPTABLE NS_IMETHOD GetAdapterDeviceID2(nsAString & aAdapterDeviceID); NS_SCRIPTABLE NS_IMETHOD GetAdapterRAM2(nsAString & aAdapterRAM); NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverVersion2(nsAString & aAdapterDriverVersion); NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverDate2(nsAString & aAdapterDriverDate);