From 90ac0e8729b9e58f3125139f9c6fc6e75741acd8 Mon Sep 17 00:00:00 2001 From: Doug Sherk Date: Wed, 14 Dec 2011 21:02:59 -0800 Subject: [PATCH 01/26] Bug 699482: refactored GfxDriverInfo init to happen after global init r=bjacob This patch moves all static initialization of GfxDriverInfo and DeviceFamily classes to the point that they're actually used. It also converts all static GfxDriverInfo arrays into nsTArray so that they can be used interchangeably with the downloadable blocklist. This patch also introduces a new phase of blocklist checking called BEING_PROCESSED, which is the status set when a blocklist check is currently being processed. NO_INFO now only means that we have confirmed that a device is not blocked. --- browser/app/blocklist.xml | 2 +- widget/public/nsIGfxInfo.idl | 11 +- widget/src/android/GfxInfo.cpp | 28 ++- widget/src/android/GfxInfo.h | 4 +- widget/src/cocoa/GfxInfo.h | 4 +- widget/src/cocoa/GfxInfo.mm | 35 +-- widget/src/windows/GfxInfo.cpp | 266 ++++++++++---------- widget/src/windows/GfxInfo.h | 4 +- widget/src/xpwidgets/GfxDriverInfo.cpp | 128 ++++++++++ widget/src/xpwidgets/GfxDriverInfo.h | 119 ++------- widget/src/xpwidgets/GfxInfoBase.cpp | 336 ++++++++++++++----------- widget/src/xpwidgets/GfxInfoBase.h | 16 +- widget/src/xpwidgets/GfxInfoX11.cpp | 18 +- widget/src/xpwidgets/GfxInfoX11.h | 4 +- 14 files changed, 535 insertions(+), 440 deletions(-) diff --git a/browser/app/blocklist.xml b/browser/app/blocklist.xml index 6c346ad92a13..0bbb63877de5 100644 --- a/browser/app/blocklist.xml +++ b/browser/app/blocklist.xml @@ -225,4 +225,4 @@ - \ No newline at end of file + diff --git a/widget/public/nsIGfxInfo.idl b/widget/public/nsIGfxInfo.idl index f0fea0539110..2f3f6ae17a3f 100644 --- a/widget/public/nsIGfxInfo.idl +++ b/widget/public/nsIGfxInfo.idl @@ -114,19 +114,22 @@ interface nsIGfxInfo : nsISupports /* * A set of return values from GetFeatureStatus */ + /* We don't explicitly block or discourage the feature. Which means we'll try getting it from the * hardware, and see what happens. */ const long FEATURE_NO_INFO = 1; + /* We don't know the status of the feature yet. The analysis probably hasn't finished yet. */ + const long FEATURE_STATUS_UNKNOWN = 2; /* This feature is blocked on this driver version. Updating driver will typically unblock it. */ - const long FEATURE_BLOCKED_DRIVER_VERSION = 2; + const long FEATURE_BLOCKED_DRIVER_VERSION = 3; /* This feature is blocked on this device, regardless of driver version. * Typically means we hit too many driver crashes without a good reason to hope for them to * get fixed soon. */ - const long FEATURE_BLOCKED_DEVICE = 3; + const long FEATURE_BLOCKED_DEVICE = 4; /* This feature is available and can be used, but is not suggested (e.g. shouldn't be used by default */ - const long FEATURE_DISCOURAGED = 4; + const long FEATURE_DISCOURAGED = 5; /* This feature is blocked on this OS version. */ - const long FEATURE_BLOCKED_OS_VERSION = 5; + const long FEATURE_BLOCKED_OS_VERSION = 6; /** * Ask about a feature, and return the status of that feature diff --git a/widget/src/android/GfxInfo.cpp b/widget/src/android/GfxInfo.cpp index e00fff71408f..95ceb91677e6 100644 --- a/widget/src/android/GfxInfo.cpp +++ b/widget/src/android/GfxInfo.cpp @@ -274,30 +274,30 @@ GfxInfo::AddOpenGLCrashReportAnnotations() #endif } -static GfxDriverInfo gDriverInfo[] = { - GfxDriverInfo() -}; - -const GfxDriverInfo* +const nsTArray& GfxInfo::GetGfxDriverInfo() { - return &gDriverInfo[0]; + // Nothing here yet. + //if (!mDriverInfo->Length()) { + // + //} + return *mDriverInfo; } nsresult GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, PRInt32 *aStatus, nsAString & aSuggestedDriverVersion, - GfxDriverInfo* aDriverInfo /* = nsnull */, + const nsTArray& aDriverInfo, OperatingSystem* aOS /* = nsnull */) { - PRInt32 status = nsIGfxInfo::FEATURE_NO_INFO; + PRInt32 status = nsIGfxInfo::FEATURE_STATUS_UNKNOWN; aSuggestedDriverVersion.SetIsVoid(true); // For now, we don't implement the downloaded blacklist. - if (aDriverInfo) { - *aStatus = status; + if (aDriverInfo.Length()) { + *aStatus = nsIGfxInfo::FEATURE_NO_INFO; return NS_OK; } @@ -326,6 +326,12 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, *aOS = os; // XXX disabled for now as this calls GetAdapterVendorID and friends, which currently crash on Android, see bug 700124 - // return GfxInfoBase::GetFeatureStatusImpl(aFeature, aStatus, aSuggestedDriverVersion, aDriverInfo, &os); + // FIXME: if this gets fixed, the line setting *aStatus must be removed +#if 0 + return GfxInfoBase::GetFeatureStatusImpl(aFeature, aStatus, aSuggestedDriverVersion, aDriverInfo, &os); +#else + if (status == nsIGfxInfo::FEATURE_STATUS_UNKNOWN) + *aStatus = nsIGfxInfo::FEATURE_NO_INFO; +#endif return NS_OK; } diff --git a/widget/src/android/GfxInfo.h b/widget/src/android/GfxInfo.h index cd964da9639c..d54f6ed192b4 100644 --- a/widget/src/android/GfxInfo.h +++ b/widget/src/android/GfxInfo.h @@ -83,9 +83,9 @@ protected: virtual nsresult GetFeatureStatusImpl(PRInt32 aFeature, PRInt32 *aStatus, nsAString & aSuggestedDriverVersion, - GfxDriverInfo* aDriverInfo = nsnull, + const nsTArray& aDriverInfo, OperatingSystem* aOS = nsnull); - virtual const GfxDriverInfo* GetGfxDriverInfo(); + virtual const nsTArray& GetGfxDriverInfo(); private: diff --git a/widget/src/cocoa/GfxInfo.h b/widget/src/cocoa/GfxInfo.h index eaec9a62929c..d07f2637a79a 100644 --- a/widget/src/cocoa/GfxInfo.h +++ b/widget/src/cocoa/GfxInfo.h @@ -85,9 +85,9 @@ protected: virtual nsresult GetFeatureStatusImpl(PRInt32 aFeature, PRInt32 *aStatus, nsAString & aSuggestedDriverVersion, - GfxDriverInfo* aDriverInfo = nsnull, + const nsTArray& aDriverInfo, OperatingSystem* aOS = nsnull); - virtual const GfxDriverInfo* GetGfxDriverInfo(); + virtual const nsTArray& GetGfxDriverInfo(); private: diff --git a/widget/src/cocoa/GfxInfo.mm b/widget/src/cocoa/GfxInfo.mm index b538834d5594..bdd1604523d4 100644 --- a/widget/src/cocoa/GfxInfo.mm +++ b/widget/src/cocoa/GfxInfo.mm @@ -356,30 +356,21 @@ GfxInfo::AddCrashReportAnnotations() #endif } -static GfxDriverInfo gDriverInfo[] = { - // We don't support checking driver versions on Mac. - #define IMPLEMENT_MAC_DRIVER_BLOCKLIST(os, vendor, device, features, blockOn) \ - GfxDriverInfo(os, vendor, device, features, blockOn, \ - DRIVER_UNKNOWN_COMPARISON, V(0,0,0,0), ""), +// We don't support checking driver versions on Mac. +#define IMPLEMENT_MAC_DRIVER_BLOCKLIST(os, vendor, device, features, blockOn) \ + APPEND_TO_DRIVER_BLOCKLIST(os, vendor, device, features, blockOn, \ + DRIVER_UNKNOWN_COMPARISON, V(0,0,0,0), "") - // Example use of macro. - //IMPLEMENT_MAC_DRIVER_BLOCKLIST(DRIVER_OS_OS_X_10_7, - // GfxDriverInfo::vendorATI, GfxDriverInfo::allDevices, - // GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_OS_VERSION) - // Block all ATI cards from using MSAA, except for two devices that have - // special exceptions in the GetFeatureStatusImpl() function. - IMPLEMENT_MAC_DRIVER_BLOCKLIST(DRIVER_OS_ALL, - GfxDriverInfo::vendorATI, GfxDriverInfo::allDevices, - nsIGfxInfo::FEATURE_WEBGL_MSAA, nsIGfxInfo::FEATURE_BLOCKED_OS_VERSION) - - GfxDriverInfo() -}; - -const GfxDriverInfo* +const nsTArray& GfxInfo::GetGfxDriverInfo() { - return &gDriverInfo[0]; + if (!mDriverInfo->Length()) { + IMPLEMENT_MAC_DRIVER_BLOCKLIST(DRIVER_OS_ALL, + GfxDriverInfo::vendorATI, GfxDriverInfo::allDevices, + nsIGfxInfo::FEATURE_WEBGL_MSAA, nsIGfxInfo::FEATURE_BLOCKED_OS_VERSION); + } + return *mDriverInfo; } static OperatingSystem @@ -401,14 +392,14 @@ nsresult GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, PRInt32* aStatus, nsAString& aSuggestedDriverVersion, - GfxDriverInfo* aDriverInfo /* = nsnull */, + const nsTArray& aDriverInfo, OperatingSystem* aOS /* = nsnull */) { NS_ENSURE_ARG_POINTER(aStatus); aSuggestedDriverVersion.SetIsVoid(true); - PRInt32 status = nsIGfxInfo::FEATURE_NO_INFO; + PRInt32 status = nsIGfxInfo::FEATURE_STATUS_UNKNOWN; OperatingSystem os = OSXVersionToOperatingSystem(nsToolkit::OSXVersion()); diff --git a/widget/src/windows/GfxInfo.cpp b/widget/src/windows/GfxInfo.cpp index b114d970d260..4a92ed7c1e7f 100644 --- a/widget/src/windows/GfxInfo.cpp +++ b/widget/src/windows/GfxInfo.cpp @@ -794,118 +794,6 @@ GfxInfo::AddCrashReportAnnotations() #endif } -static const GfxDriverInfo gDriverInfo[] = { - /* - * Notice that the first match defines the result. So always implement special cases firsts and general case last. - */ - - /* - * NVIDIA entries - */ - GfxDriverInfo( DRIVER_OS_WINDOWS_XP, - GfxDriverInfo::vendorNVIDIA, GfxDriverInfo::allDevices, - GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, - DRIVER_LESS_THAN, V(6,14,12,5721), "257.21" ), - GfxDriverInfo( DRIVER_OS_WINDOWS_VISTA, - GfxDriverInfo::vendorNVIDIA, GfxDriverInfo::allDevices, - GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, - DRIVER_LESS_THAN, V(8,17,12,5721), "257.21" ), - GfxDriverInfo( DRIVER_OS_WINDOWS_7, - GfxDriverInfo::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. - */ - GfxDriverInfo( DRIVER_OS_ALL, - GfxDriverInfo::vendorNVIDIA, (GfxDeviceFamily) deviceFamilyNvidiaBlockD3D9Layers, - nsIGfxInfo::FEATURE_DIRECT3D_9_LAYERS, nsIGfxInfo::FEATURE_BLOCKED_DEVICE, - DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions ), - - /* - * AMD/ATI entries - */ - GfxDriverInfo( DRIVER_OS_ALL, - GfxDriverInfo::vendorATI, GfxDriverInfo::allDevices, - GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, - DRIVER_LESS_THAN, V(8,741,0,0), "10.6" ), - GfxDriverInfo( DRIVER_OS_ALL, - GfxDriverInfo::vendorAMD, GfxDriverInfo::allDevices, - GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, - DRIVER_LESS_THAN, V(8,741,0,0), "10.6" ), - - /* OpenGL on any ATI/AMD hardware is discouraged - * See: - * bug 619773 - WebGL: Crash with blue screen : "NMI: Parity Check / Memory Parity Error" - * bugs 584403, 584404, 620924 - crashes in atioglxx - * + many complaints about incorrect rendering - */ - GfxDriverInfo( DRIVER_OS_ALL, - GfxDriverInfo::vendorATI, GfxDriverInfo::allDevices, - nsIGfxInfo::FEATURE_OPENGL_LAYERS, nsIGfxInfo::FEATURE_DISCOURAGED, - DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions ), - GfxDriverInfo( DRIVER_OS_ALL, - GfxDriverInfo::vendorATI, GfxDriverInfo::allDevices, - nsIGfxInfo::FEATURE_WEBGL_OPENGL, nsIGfxInfo::FEATURE_DISCOURAGED, - DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions ), - GfxDriverInfo( DRIVER_OS_ALL, - GfxDriverInfo::vendorAMD, GfxDriverInfo::allDevices, - nsIGfxInfo::FEATURE_OPENGL_LAYERS, nsIGfxInfo::FEATURE_DISCOURAGED, - DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions ), - GfxDriverInfo( DRIVER_OS_ALL, - GfxDriverInfo::vendorAMD, GfxDriverInfo::allDevices, - nsIGfxInfo::FEATURE_WEBGL_OPENGL, nsIGfxInfo::FEATURE_DISCOURAGED, - DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions ), - - /* - * Intel entries - */ - - /* implement the blocklist from bug 594877 - * 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) \ - GfxDriverInfo( winVer, \ - GfxDriverInfo::vendorIntel, (GfxDeviceFamily) devFamily, \ - GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, \ - DRIVER_LESS_THAN, driverVer ), - - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_XP, deviceFamilyIntelGMA500, V(6,14,11,1018)) - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_XP, deviceFamilyIntelGMA900, V(6,14,10,4764)) - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_XP, deviceFamilyIntelGMA950, V(6,14,10,4926)) - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_XP, deviceFamilyIntelGMA3150, V(6,14,10,5260)) - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_XP, deviceFamilyIntelGMAX3000, V(6,14,10,5218)) - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_XP, deviceFamilyIntelGMAX4500HD, V(6,14,10,5284)) - - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_VISTA, deviceFamilyIntelGMA500, V(7,14,10,1006)) - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_VISTA, deviceFamilyIntelGMA900, GfxDriverInfo::allDriverVersions) - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_VISTA, deviceFamilyIntelGMA950, V(7,14,10,1504)) - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_VISTA, deviceFamilyIntelGMA3150, V(7,14,10,2124)) - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_VISTA, deviceFamilyIntelGMAX3000, V(7,15,10,1666)) - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_VISTA, deviceFamilyIntelGMAX4500HD, V(8,15,10,2202)) - - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_7, deviceFamilyIntelGMA500, V(5,0,0,2026)) - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_7, deviceFamilyIntelGMA900, GfxDriverInfo::allDriverVersions) - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_7, deviceFamilyIntelGMA950, V(8,15,10,1930)) - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_7, deviceFamilyIntelGMA3150, V(8,14,10,2117)) - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_7, deviceFamilyIntelGMAX3000, V(8,15,10,1930)) - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(DRIVER_OS_WINDOWS_7, deviceFamilyIntelGMAX4500HD, V(8,15,10,2202)) - - /* OpenGL on any Intel hardware is discouraged */ - GfxDriverInfo( DRIVER_OS_ALL, - GfxDriverInfo::vendorIntel, GfxDriverInfo::allDevices, - nsIGfxInfo::FEATURE_OPENGL_LAYERS, nsIGfxInfo::FEATURE_DISCOURAGED, - DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions ), - GfxDriverInfo( DRIVER_OS_ALL, - GfxDriverInfo::vendorIntel, GfxDriverInfo::allDevices, - nsIGfxInfo::FEATURE_WEBGL_OPENGL, nsIGfxInfo::FEATURE_DISCOURAGED, - DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions ), - - GfxDriverInfo() -}; - static OperatingSystem WindowsVersionToOperatingSystem(PRInt32 aWindowsVersion) { @@ -926,45 +814,149 @@ WindowsVersionToOperatingSystem(PRInt32 aWindowsVersion) }; } -const GfxDriverInfo* +const nsTArray& GfxInfo::GetGfxDriverInfo() { - return &gDriverInfo[0]; + if (!mDriverInfo->Length()) { + /* + * NVIDIA entries + */ + APPEND_TO_DRIVER_BLOCKLIST( DRIVER_OS_WINDOWS_XP, + GfxDriverInfo::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, + 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, + 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, + 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, + GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, + DRIVER_LESS_THAN, V(8,741,0,0), "10.6" ); + + /* OpenGL on any ATI/AMD hardware is discouraged + * See: + * bug 619773 - WebGL: Crash with blue screen : "NMI: Parity Check / Memory Parity Error" + * bugs 584403, 584404, 620924 - crashes in atioglxx + * + many complaints about incorrect rendering + */ + APPEND_TO_DRIVER_BLOCKLIST2( DRIVER_OS_ALL, + GfxDriverInfo::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, + nsIGfxInfo::FEATURE_WEBGL_OPENGL, nsIGfxInfo::FEATURE_DISCOURAGED, + DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions ); + APPEND_TO_DRIVER_BLOCKLIST2( DRIVER_OS_ALL, + GfxDriverInfo::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, + nsIGfxInfo::FEATURE_WEBGL_OPENGL, nsIGfxInfo::FEATURE_DISCOURAGED, + DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions ); + + /* + * Intel entries + */ + + /* implement the blocklist from bug 594877 + * 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, \ + 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_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_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)); + + /* OpenGL on any Intel hardware is discouraged */ + APPEND_TO_DRIVER_BLOCKLIST2( DRIVER_OS_ALL, + GfxDriverInfo::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, + nsIGfxInfo::FEATURE_WEBGL_OPENGL, nsIGfxInfo::FEATURE_DISCOURAGED, + DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions ); + } + return *mDriverInfo; } nsresult GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, PRInt32 *aStatus, nsAString & aSuggestedDriverVersion, - GfxDriverInfo* aDriverInfo /* = nsnull */, + const nsTArray& aDriverInfo, OperatingSystem* aOS /* = nsnull */) { - *aStatus = nsIGfxInfo::FEATURE_NO_INFO; aSuggestedDriverVersion.SetIsVoid(true); - PRInt32 status = nsIGfxInfo::FEATURE_NO_INFO; + PRInt32 status = nsIGfxInfo::FEATURE_STATUS_UNKNOWN; - PRUint32 adapterVendor = 0; + PRUint32 adapterVendorID = 0; PRUint32 adapterDeviceID = 0; nsAutoString adapterDriverVersionString; - if (NS_FAILED(GetAdapterVendorID(&adapterVendor)) || + if (NS_FAILED(GetAdapterVendorID(&adapterVendorID)) || NS_FAILED(GetAdapterDeviceID(&adapterDeviceID)) || NS_FAILED(GetAdapterDriverVersion(adapterDriverVersionString))) { return NS_ERROR_FAILURE; } - if (adapterVendor != GfxDriverInfo::vendorIntel && - adapterVendor != GfxDriverInfo::vendorNVIDIA && - adapterVendor != GfxDriverInfo::vendorAMD && - adapterVendor != GfxDriverInfo::vendorATI && + if (adapterVendorID != GfxDriverInfo::vendorIntel && + adapterVendorID != GfxDriverInfo::vendorNVIDIA && + adapterVendorID != GfxDriverInfo::vendorAMD && + adapterVendorID != GfxDriverInfo::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. - adapterVendor != 0xabcd && - adapterVendor != 0xdcba && - adapterVendor != 0xabab && - adapterVendor != 0xdcdc) + adapterVendorID != 0xabcd && + adapterVendorID != 0xdcba && + adapterVendorID != 0xabab && + adapterVendorID != 0xdcdc) { *aStatus = FEATURE_BLOCKED_DEVICE; return NS_OK; @@ -974,7 +966,19 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, if (!ParseDriverVersion(adapterDriverVersionString, &driverVersion)) { return NS_ERROR_FAILURE; } - + + // special-case the WinXP test slaves: they have out-of-date drivers, but we still want to + // 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 + driverVersion == V(6,14,11,7756)) + { + *aStatus = FEATURE_NO_INFO; + return NS_OK; + } + if (aFeature == FEATURE_DIRECT3D_9_LAYERS && mWindowsVersion < gfxWindowsPlatform::kWindowsXP) { @@ -998,12 +1002,6 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, if (os == DRIVER_OS_WINDOWS_SERVER_2003) os = DRIVER_OS_WINDOWS_XP; - const GfxDriverInfo *info; - if (aDriverInfo) - info = aDriverInfo; - else - info = &gDriverInfo[0]; - if (mHasDriverVersionMismatch) { if (aFeature == nsIGfxInfo::FEATURE_DIRECT3D_10_LAYERS || aFeature == nsIGfxInfo::FEATURE_DIRECT3D_10_1_LAYERS || diff --git a/widget/src/windows/GfxInfo.h b/widget/src/windows/GfxInfo.h index f193f807f197..178e9c015e84 100644 --- a/widget/src/windows/GfxInfo.h +++ b/widget/src/windows/GfxInfo.h @@ -92,9 +92,9 @@ protected: virtual nsresult GetFeatureStatusImpl(PRInt32 aFeature, PRInt32 *aStatus, nsAString & aSuggestedDriverVersion, - GfxDriverInfo* aDriverInfo = nsnull, + const nsTArray& aDriverInfo, OperatingSystem* aOS = nsnull); - virtual const GfxDriverInfo* GetGfxDriverInfo(); + virtual const nsTArray& GetGfxDriverInfo(); private: diff --git a/widget/src/xpwidgets/GfxDriverInfo.cpp b/widget/src/xpwidgets/GfxDriverInfo.cpp index 6a744f95ce53..12dcc497b2d2 100644 --- a/widget/src/xpwidgets/GfxDriverInfo.cpp +++ b/widget/src/xpwidgets/GfxDriverInfo.cpp @@ -117,3 +117,131 @@ GfxDriverInfo::~GfxDriverInfo() if (mDeleteDevices) delete[] mDevices; } + +const GfxDeviceFamily GfxDriverInfo::GetDeviceFamily(DeviceFamily 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: { + // 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"); + } + + return nsnull; +} diff --git a/widget/src/xpwidgets/GfxDriverInfo.h b/widget/src/xpwidgets/GfxDriverInfo.h index e9340a2bd867..c446e45bbd5a 100644 --- a/widget/src/xpwidgets/GfxDriverInfo.h +++ b/widget/src/xpwidgets/GfxDriverInfo.h @@ -43,6 +43,11 @@ #define V(a,b,c,d) GFX_DRIVER_VERSION(a,b,c,d) +#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) \ + mDriverInfo->AppendElement(GfxDriverInfo(os, vendor, devices, feature, featureStatus, driverComparator, driverVersion)) + namespace mozilla { namespace widget { @@ -74,112 +79,18 @@ enum VersionComparisonOp { DRIVER_UNKNOWN_COMPARISON }; -static const PRUint32 deviceFamilyIntelGMA500[] = { - 0x8108, /* IntelGMA500_1 */ - 0x8109, /* IntelGMA500_2 */ - 0 -}; - -static const PRUint32 deviceFamilyIntelGMA900[] = { - 0x2582, /* IntelGMA900_1 */ - 0x2782, /* IntelGMA900_2 */ - 0x2592, /* IntelGMA900_3 */ - 0x2792, /* IntelGMA900_4 */ - 0 -}; - -static const PRUint32 deviceFamilyIntelGMA950[] = { - 0x2772, /* Intel945G_1 */ - 0x2776, /* Intel945G_2 */ - 0x27A2, /* Intel945_1 */ - 0x27A6, /* Intel945_2 */ - 0x27AE, /* Intel945_3 */ - 0 -}; - -static const PRUint32 deviceFamilyIntelGMA3150[] = { - 0xA001, /* IntelGMA3150_Nettop_1 */ - 0xA002, /* IntelGMA3150_Nettop_2 */ - 0xA011, /* IntelGMA3150_Netbook_1 */ - 0xA012, /* IntelGMA3150_Netbook_2 */ - 0 -}; - -static const PRUint32 deviceFamilyIntelGMAX3000[] = { - 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 -}; - -static const PRUint32 deviceFamilyIntelGMAX4500HD[] = { - 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 -}; - -// Glitches whilst scrolling (see bugs 612007, 644787, 645872) -static const PRUint32 deviceFamilyNvidiaBlockD3D9Layers[] = { - 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 +enum DeviceFamily { + IntelGMA500, + IntelGMA900, + IntelGMA950, + IntelGMA3150, + IntelGMAX3000, + IntelGMAX4500HD, + NvidiaBlockD3D9Layers }; /* A zero-terminated array of devices to match, or all devices */ -typedef PRUint32 *GfxDeviceFamily; +typedef PRUint32* GfxDeviceFamily; struct GfxDriverInfo { @@ -226,6 +137,8 @@ struct GfxDriverInfo static PRUint32 vendorATI; const char *mSuggestedVersion; + + static const GfxDeviceFamily GetDeviceFamily(DeviceFamily id); }; #define GFX_DRIVER_VERSION(a,b,c,d) \ diff --git a/widget/src/xpwidgets/GfxInfoBase.cpp b/widget/src/xpwidgets/GfxInfoBase.cpp index b9609245ce47..a436cb21b231 100644 --- a/widget/src/xpwidgets/GfxInfoBase.cpp +++ b/widget/src/xpwidgets/GfxInfoBase.cpp @@ -48,6 +48,7 @@ #include "nsAutoPtr.h" #include "nsString.h" #include "mozilla/Services.h" +#include "mozilla/Observer.h" #include "nsIObserver.h" #include "nsIObserverService.h" #include "nsIDOMElement.h" @@ -60,8 +61,52 @@ #include "nsExceptionHandler.h" #endif +using namespace mozilla::widget; using namespace mozilla; +nsTArray* GfxInfoBase::mDriverInfo; +bool GfxInfoBase::mDriverInfoObserverInitialized; + +// Observes for shutdown so that the child GfxDriverInfo list is freed. +class ShutdownObserver : public nsIObserver +{ +public: + ShutdownObserver() {} + virtual ~ShutdownObserver() {} + + NS_DECL_ISUPPORTS + + NS_IMETHOD Observe(nsISupports *subject, const char *aTopic, + const PRUnichar *aData) + { + MOZ_ASSERT(strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0); + if (GfxInfoBase::mDriverInfo) { + delete GfxInfoBase::mDriverInfo; + GfxInfoBase::mDriverInfo = nsnull; + } + return NS_OK; + } +}; + +NS_IMPL_ISUPPORTS1(ShutdownObserver, nsIObserver); + +void InitGfxDriverInfoShutdownObserver() +{ + if (GfxInfoBase::mDriverInfoObserverInitialized) + return; + + GfxInfoBase::mDriverInfoObserverInitialized = true; + + nsCOMPtr observerService = services::GetObserverService(); + if (!observerService) { + NS_WARNING("Could not get observer service!"); + return; + } + + ShutdownObserver *obs = new ShutdownObserver(); + observerService->AddObserver(obs, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false); +} + extern "C" { void StoreSpline(int ax, int ay, int bx, int by, int cx, int cy, int dx, int dy); void CrashSpline(double tolerance, int ax, int ay, int bx, int by, int cx, int cy, int dx, int dy); @@ -338,6 +383,8 @@ BlacklistFeatureStatusToGfxFeatureStatus(const nsAString& aStatus) else if (aStatus == NS_LITERAL_STRING("BLOCKED_OS_VERSION")) return nsIGfxInfo::FEATURE_BLOCKED_OS_VERSION; + // Do not allow it to set STATUS_UNKNOWN. + return nsIGfxInfo::FEATURE_NO_INFO; } @@ -558,12 +605,6 @@ GfxInfoBase::Init() return NS_OK; } -static const GfxDriverInfo gDriverInfo[] = { - // No combinations that cause a crash on every OS. - GfxDriverInfo() -}; - - NS_IMETHODIMP GfxInfoBase::GetFeatureStatus(PRInt32 aFeature, PRInt32* aStatus NS_OUTPARAM) { @@ -571,22 +612,145 @@ GfxInfoBase::GetFeatureStatus(PRInt32 aFeature, PRInt32* aStatus NS_OUTPARAM) return NS_OK; nsString version; - return GetFeatureStatusImpl(aFeature, aStatus, version); + nsTArray driverInfo; + return GetFeatureStatusImpl(aFeature, aStatus, version, driverInfo); +} + +PRInt32 +GfxInfoBase::FindBlocklistedDeviceInList(const nsTArray& info, + nsAString& aSuggestedVersion, + PRInt32 aFeature, + OperatingSystem os) +{ + PRInt32 status = nsIGfxInfo::FEATURE_STATUS_UNKNOWN; + + PRUint32 adapterVendorID = 0; + PRUint32 adapterDeviceID = 0; + nsAutoString adapterDriverVersionString; + if (NS_FAILED(GetAdapterVendorID(&adapterVendorID)) || + NS_FAILED(GetAdapterDeviceID(&adapterDeviceID)) || + NS_FAILED(GetAdapterDriverVersion(adapterDriverVersionString))) + { + return NS_OK; + } + + PRUint64 driverVersion; + ParseDriverVersion(adapterDriverVersionString, &driverVersion); + + PRUint32 i = 0; + for (; i < info.Length(); i++) { + if (info[i].mOperatingSystem != DRIVER_OS_ALL && + info[i].mOperatingSystem != os) + { + continue; + } + + if (info[i].mAdapterVendor != GfxDriverInfo::allAdapterVendors && + info[i].mAdapterVendor != adapterVendorID) { + continue; + } + + if (info[i].mDevices != GfxDriverInfo::allDevices) { + bool deviceMatches = false; + for (const PRUint32 *devices = info[i].mDevices; *devices; ++devices) { + if (*devices == adapterDeviceID) { + deviceMatches = true; + break; + } + } + + if (!deviceMatches) { + continue; + } + } + + bool match = false; + +#if !defined(XP_MACOSX) + switch (info[i].mComparisonOp) { + case DRIVER_LESS_THAN: + match = driverVersion < info[i].mDriverVersion; + break; + case DRIVER_LESS_THAN_OR_EQUAL: + match = driverVersion <= info[i].mDriverVersion; + break; + case DRIVER_GREATER_THAN: + match = driverVersion > info[i].mDriverVersion; + break; + case DRIVER_GREATER_THAN_OR_EQUAL: + match = driverVersion >= info[i].mDriverVersion; + break; + case DRIVER_EQUAL: + match = driverVersion == info[i].mDriverVersion; + break; + case DRIVER_NOT_EQUAL: + match = driverVersion != info[i].mDriverVersion; + break; + case DRIVER_BETWEEN_EXCLUSIVE: + match = driverVersion > info[i].mDriverVersion && driverVersion < info[i].mDriverVersionMax; + break; + case DRIVER_BETWEEN_INCLUSIVE: + match = driverVersion >= info[i].mDriverVersion && driverVersion <= info[i].mDriverVersionMax; + break; + case DRIVER_BETWEEN_INCLUSIVE_START: + match = driverVersion >= info[i].mDriverVersion && driverVersion < info[i].mDriverVersionMax; + break; + default: + NS_WARNING("Bogus op in GfxDriverInfo"); + break; + } +#else + // We don't care what driver version it was. We only check OS version and if + // the device matches. + match = true; +#endif + + if (match) { + if (info[i].mFeature == GfxDriverInfo::allFeatures || + info[i].mFeature == aFeature) + { + status = info[i].mFeatureStatus; + break; + } + } + } + + // Depends on Windows driver versioning. We don't pass a GfxDriverInfo object + // back to the Windows handler, so we must handle this here. +#if defined(XP_WIN) + if (status == FEATURE_BLOCKED_DRIVER_VERSION) { + if (info[i].mSuggestedVersion) { + aSuggestedVersion.AppendPrintf("%s", info[i].mSuggestedVersion); + } else if (info[i].mComparisonOp == DRIVER_LESS_THAN && + info[i].mDriverVersion != GfxDriverInfo::allDriverVersions) + { + aSuggestedVersion.AppendPrintf("%lld.%lld.%lld.%lld", + (info[i].mDriverVersion & 0xffff000000000000) >> 48, + (info[i].mDriverVersion & 0x0000ffff00000000) >> 32, + (info[i].mDriverVersion & 0x00000000ffff0000) >> 16, + (info[i].mDriverVersion & 0x000000000000ffff)); + } + } +#endif + + return status; } nsresult GfxInfoBase::GetFeatureStatusImpl(PRInt32 aFeature, PRInt32* aStatus, - nsAString& aVersion, - GfxDriverInfo* aDriverInfo /* = nsnull */, + nsAString& aSuggestedVersion, + const nsTArray& aDriverInfo, OperatingSystem* aOS /* = nsnull */) { - if (*aStatus != nsIGfxInfo::FEATURE_NO_INFO) { + if (*aStatus != nsIGfxInfo::FEATURE_STATUS_UNKNOWN) { // Terminate now with the status determined by the derived type (OS-specific // code). return NS_OK; } + // If an operating system was provided by the derived GetFeatureStatusImpl, + // grab it here. Otherwise, the OS is unknown. OperatingSystem os = DRIVER_OS_UNKNOWN; if (aOS) os = *aOS; @@ -604,137 +768,24 @@ GfxInfoBase::GetFeatureStatusImpl(PRInt32 aFeature, PRUint64 driverVersion; ParseDriverVersion(adapterDriverVersionString, &driverVersion); - // special-case the WinXP test slaves: they have out-of-date drivers, but we still want to - // whitelist them, actually we do know that this combination of device and driver version - // works well. - if (os == DRIVER_OS_WINDOWS_XP && - adapterVendorID == GfxDriverInfo::vendorNVIDIA && - adapterDeviceID == 0x0861 && // GeForce 9400 - driverVersion == V(6,14,11,7756)) - { - return NS_OK; + // Check if the device is blocked from the downloaded blocklist. If not, check + // 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) { + status = FindBlocklistedDeviceInList(GetGfxDriverInfo(), aSuggestedVersion, aFeature, os); } - PRInt32 status = *aStatus; - const GfxDriverInfo* info = aDriverInfo ? aDriverInfo : &gDriverInfo[0]; - // This code will operate in two modes: - // It first loops over the driver tuples stored locally in gDriverInfo, - // then loops over it a second time for the OS's specific list to check for - // all combinations that can lead to disabling a feature. - bool loopingOverOS = false; - while (true) { - if (!info->mOperatingSystem) { - if (loopingOverOS) - break; - else - { - // Mark us as looping over the OS driver tuples. - loopingOverOS = true; - // Get the GfxDriverInfo table from the OS subclass. - info = GetGfxDriverInfo(); - } - } - - if (info->mOperatingSystem != DRIVER_OS_ALL && - info->mOperatingSystem != os) - { - info++; - continue; - } - - if (info->mAdapterVendor != GfxDriverInfo::allAdapterVendors && - info->mAdapterVendor != adapterVendorID) { - info++; - continue; - } - - if (info->mDevices != GfxDriverInfo::allDevices) { - bool deviceMatches = false; - for (const PRUint32 *devices = info->mDevices; *devices; ++devices) { - if (*devices == adapterDeviceID) { - deviceMatches = true; - break; - } - } - - if (!deviceMatches) { - info++; - continue; - } - } - - bool match = false; - -#if !defined(XP_MACOSX) - switch (info->mComparisonOp) { - case DRIVER_LESS_THAN: - match = driverVersion < info->mDriverVersion; - break; - case DRIVER_LESS_THAN_OR_EQUAL: - match = driverVersion <= info->mDriverVersion; - break; - case DRIVER_GREATER_THAN: - match = driverVersion > info->mDriverVersion; - break; - case DRIVER_GREATER_THAN_OR_EQUAL: - match = driverVersion >= info->mDriverVersion; - break; - case DRIVER_EQUAL: - match = driverVersion == info->mDriverVersion; - break; - case DRIVER_NOT_EQUAL: - match = driverVersion != info->mDriverVersion; - break; - case DRIVER_BETWEEN_EXCLUSIVE: - match = driverVersion > info->mDriverVersion && driverVersion < info->mDriverVersionMax; - break; - case DRIVER_BETWEEN_INCLUSIVE: - match = driverVersion >= info->mDriverVersion && driverVersion <= info->mDriverVersionMax; - break; - case DRIVER_BETWEEN_INCLUSIVE_START: - match = driverVersion >= info->mDriverVersion && driverVersion < info->mDriverVersionMax; - break; - default: - NS_WARNING("Bogus op in GfxDriverInfo"); - break; - } -#else - // We don't care what driver version it was. We only check OS version and if - // the device matches. - match = true; -#endif - - if (match) { - if (info->mFeature == GfxDriverInfo::allFeatures || - info->mFeature == aFeature) - { - status = info->mFeatureStatus; - break; - } - } - - info++; + // It's now done being processed. It's safe to set the status to NO_INFO. + if (status == nsIGfxInfo::FEATURE_STATUS_UNKNOWN) { + *aStatus = nsIGfxInfo::FEATURE_NO_INFO; + } else { + *aStatus = status; } - - *aStatus = status; - - // Depends on Windows driver versioning. We don't pass a GfxDriverInfo object - // back to the Windows handler, so we must handle this here. -#if defined(XP_WIN) - if (status == FEATURE_BLOCKED_DRIVER_VERSION) { - if (info->mSuggestedVersion) { - aVersion.AppendPrintf("%s", info->mSuggestedVersion); - } else if (info->mComparisonOp == DRIVER_LESS_THAN && - info->mDriverVersion != GfxDriverInfo::allDriverVersions) - { - aVersion.AppendPrintf("%lld.%lld.%lld.%lld", - (info->mDriverVersion & 0xffff000000000000) >> 48, - (info->mDriverVersion & 0x0000ffff00000000) >> 32, - (info->mDriverVersion & 0x00000000ffff0000) >> 16, - (info->mDriverVersion & 0x000000000000ffff)); - } - } -#endif return NS_OK; } @@ -750,7 +801,8 @@ GfxInfoBase::GetFeatureSuggestedDriverVersion(PRInt32 aFeature, } PRInt32 status; - return GetFeatureStatusImpl(aFeature, &status, aVersion); + nsTArray driverInfo; + return GetFeatureStatusImpl(aFeature, &status, aVersion, driverInfo); } @@ -776,10 +828,6 @@ GfxInfoBase::EvaluateDownloadedBlacklist(nsTArray& aDriverInfo) 0 }; - // GetFeatureStatusImpl wants a zero-GfxDriverInfo terminated array. So, we - // append that to our list. - aDriverInfo.AppendElement(GfxDriverInfo()); - // For every feature we know about, we evaluate whether this blacklist has a // non-NO_INFO status. If it does, we set the pref we evaluate in // GetFeatureStatus above, so we don't need to hold on to this blacklist @@ -790,7 +838,7 @@ GfxInfoBase::EvaluateDownloadedBlacklist(nsTArray& aDriverInfo) nsAutoString suggestedVersion; if (NS_SUCCEEDED(GetFeatureStatusImpl(features[i], &status, suggestedVersion, - aDriverInfo.Elements()))) { + aDriverInfo))) { switch (status) { default: case nsIGfxInfo::FEATURE_NO_INFO: diff --git a/widget/src/xpwidgets/GfxInfoBase.h b/widget/src/xpwidgets/GfxInfoBase.h index a5f784c1f024..bc4bcdcfccd2 100644 --- a/widget/src/xpwidgets/GfxInfoBase.h +++ b/widget/src/xpwidgets/GfxInfoBase.h @@ -87,25 +87,31 @@ public: // NS_GENERIC_FACTORY_CONSTRUCTOR_INIT require it be nsresult return. virtual nsresult Init(); - // Gets the driver info table. Used by GfxInfoBase to check for general cases - // (while subclasses check for more specific ones). - virtual const GfxDriverInfo* GetGfxDriverInfo() = 0; - // only useful on X11 NS_IMETHOD_(void) GetData() { } static void AddCollector(GfxInfoCollectorBase* collector); static void RemoveCollector(GfxInfoCollectorBase* collector); + static nsTArray* mDriverInfo; + static bool mDriverInfoObserverInitialized; protected: virtual nsresult GetFeatureStatusImpl(PRInt32 aFeature, PRInt32* aStatus, nsAString& aSuggestedDriverVersion, - GfxDriverInfo* aDriverInfo = nsnull, + const nsTArray& aDriverInfo, OperatingSystem* aOS = nsnull); + // Gets the driver info table. Used by GfxInfoBase to check for general cases + // (while subclasses check for more specific ones). + virtual const nsTArray& GetGfxDriverInfo() = 0; + private: + virtual PRInt32 FindBlocklistedDeviceInList(const nsTArray& aDriverInfo, + nsAString& aSuggestedVersion, + PRInt32 aFeature, + OperatingSystem os); void EvaluateDownloadedBlacklist(nsTArray& aDriverInfo); diff --git a/widget/src/xpwidgets/GfxInfoX11.cpp b/widget/src/xpwidgets/GfxInfoX11.cpp index 2bc377dfe9f0..1c7b94b2f87e 100644 --- a/widget/src/xpwidgets/GfxInfoX11.cpp +++ b/widget/src/xpwidgets/GfxInfoX11.cpp @@ -246,29 +246,30 @@ static inline PRUint64 version(PRUint32 major, PRUint32 minor, PRUint32 revision return (PRUint64(major) << 32) + (PRUint64(minor) << 16) + PRUint64(revision); } -static GfxDriverInfo gDriverInfo[] = { - GfxDriverInfo() -}; - -const GfxDriverInfo* +const nsTArray& GfxInfo::GetGfxDriverInfo() { - return &gDriverInfo[0]; + // Nothing here yet. + //if (!mDriverInfo->Length()) { + // + //} + return *mDriverInfo; } nsresult GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, PRInt32 *aStatus, nsAString & aSuggestedDriverVersion, - GfxDriverInfo* aDriverInfo /* = nsnull */, + const nsTArray& aDriverInfo, OperatingSystem* aOS /* = nsnull */) { GetData(); - *aStatus = nsIGfxInfo::FEATURE_NO_INFO; + *aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN; aSuggestedDriverVersion.SetIsVoid(true); #ifdef MOZ_PLATFORM_MAEMO + *aStatus = nsIGfxInfo::FEATURE_NO_INFO; // on Maemo, the glxtest probe doesn't build, and we don't really need GfxInfo anyway return NS_OK; #endif @@ -291,6 +292,7 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, !strcmp(mRenderer.get(), "GeForce 9400/PCI/SSE2") && !strcmp(mVersion.get(), "3.2.0 NVIDIA 190.42")) { + *aStatus = nsIGfxInfo::FEATURE_NO_INFO; return NS_OK; } diff --git a/widget/src/xpwidgets/GfxInfoX11.h b/widget/src/xpwidgets/GfxInfoX11.h index 2525db0d98f3..43690c00ca13 100644 --- a/widget/src/xpwidgets/GfxInfoX11.h +++ b/widget/src/xpwidgets/GfxInfoX11.h @@ -84,9 +84,9 @@ protected: virtual nsresult GetFeatureStatusImpl(PRInt32 aFeature, PRInt32 *aStatus, nsAString & aSuggestedDriverVersion, - GfxDriverInfo* aDriverInfo = nsnull, + const nsTArray& aDriverInfo, OperatingSystem* aOS = nsnull); - virtual const GfxDriverInfo* GetGfxDriverInfo(); + virtual const nsTArray& GetGfxDriverInfo(); private: nsCString mVendor; From 44ee4e573ed80f8d3004c9f5bda344f2fd11bb8d Mon Sep 17 00:00:00 2001 From: Doug Sherk Date: Wed, 14 Dec 2011 21:03:01 -0800 Subject: [PATCH 02/26] 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); From 778e94f157dc536abaaed039a845576e6b658667 Mon Sep 17 00:00:00 2001 From: Doug Sherk Date: Wed, 14 Dec 2011 21:03:03 -0800 Subject: [PATCH 03/26] Bug 689598: implement Android gfx blocklisting r=joe Also includes changes to support using the "driver version" field as the Android SDK version. --- widget/src/android/GfxInfo.cpp | 94 ++++++++++++---------------- widget/src/android/GfxInfo.h | 5 ++ widget/src/xpwidgets/GfxDriverInfo.h | 6 ++ widget/src/xpwidgets/GfxInfoBase.cpp | 4 +- 4 files changed, 53 insertions(+), 56 deletions(-) diff --git a/widget/src/android/GfxInfo.cpp b/widget/src/android/GfxInfo.cpp index 9c9ff2e31640..aedd323d4e45 100644 --- a/widget/src/android/GfxInfo.cpp +++ b/widget/src/android/GfxInfo.cpp @@ -89,6 +89,41 @@ nsresult GfxInfo::Init() { mSetCrashReportAnnotations = false; + + mAdapterDescription.AssignASCII(mozilla::gl::GetVendor()); + if (mozilla::AndroidBridge::Bridge()) { + nsAutoString str; + + mAdapterDescription.Append(NS_LITERAL_STRING(", Model: '")); + if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "MODEL", str)) { + mAdapterDeviceID = str; + mAdapterDescription.Append(str); + } + + mAdapterDescription.Append(NS_LITERAL_STRING("', Product: '")); + if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "PRODUCT", str)) + mAdapterDescription.Append(str); + + mAdapterDescription.Append(NS_LITERAL_STRING("', Manufacturer: '")); + if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "MANUFACTURER", str)) + mAdapterDescription.Append(str); + + mAdapterDescription.Append(NS_LITERAL_STRING("', Hardware: '")); + 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)) { + if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "HARDWARE", str)) { + mAdapterVendorID = str; + mAdapterDescription.Append(str); + } + } + + mAdapterDescription.Append(NS_LITERAL_STRING("'")); + mAndroidSDKVersion = version; + } + return GfxInfoBase::Init(); } @@ -96,28 +131,7 @@ GfxInfo::Init() NS_IMETHODIMP GfxInfo::GetAdapterDescription(nsAString & aAdapterDescription) { - aAdapterDescription.AssignASCII(mozilla::gl::GetVendor()); - if (mozilla::AndroidBridge::Bridge()) { - nsAutoString str; - aAdapterDescription.Append(NS_LITERAL_STRING(", Model: '")); - if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "MODEL", str)) - aAdapterDescription.Append(str); - aAdapterDescription.Append(NS_LITERAL_STRING("', Product: '")); - if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "PRODUCT", str)) - aAdapterDescription.Append(str); - aAdapterDescription.Append(NS_LITERAL_STRING("', Manufacturer: '")); - if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "MANUFACTURER", str)) - aAdapterDescription.Append(str); - aAdapterDescription.Append(NS_LITERAL_STRING("', Hardware: '")); - 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)) - if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "HARDWARE", str)) - aAdapterDescription.Append(str); - aAdapterDescription.Append(NS_LITERAL_STRING("'")); - } - + aAdapterDescription = mAdapterDescription; return NS_OK; } @@ -162,7 +176,8 @@ GfxInfo::GetAdapterDriver2(nsAString & aAdapterDriver) NS_IMETHODIMP GfxInfo::GetAdapterDriverVersion(nsAString & aAdapterDriverVersion) { - aAdapterDriverVersion.AssignLiteral(""); + aAdapterDriverVersion.Truncate(0); + aAdapterDriverVersion.AppendInt(mAndroidSDKVersion); return NS_OK; } @@ -192,16 +207,7 @@ GfxInfo::GetAdapterDriverDate2(nsAString & aAdapterDriverDate) NS_IMETHODIMP 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 = str; - return NS_OK; - } - - aAdapterVendorID = NS_LITERAL_STRING(""); + aAdapterVendorID = mAdapterVendorID; return NS_OK; } @@ -216,13 +222,7 @@ GfxInfo::GetAdapterVendorID2(nsAString & aAdapterVendorID) NS_IMETHODIMP GfxInfo::GetAdapterDeviceID(nsAString & aAdapterDeviceID) { - nsAutoString str; - if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "MODEL", str)) { - aAdapterDeviceID = str; - return NS_OK; - } - - aAdapterDeviceID = NS_LITERAL_STRING(""); + aAdapterDeviceID = mAdapterDeviceID; return NS_OK; } @@ -296,12 +296,6 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, aSuggestedDriverVersion.SetIsVoid(true); - // For now, we don't implement the downloaded blacklist. - if (aDriverInfo.Length()) { - *aStatus = nsIGfxInfo::FEATURE_NO_INFO; - return NS_OK; - } - OperatingSystem os = DRIVER_OS_ANDROID; if (aFeature == FEATURE_OPENGL_LAYERS) { @@ -326,13 +320,5 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, if (aOS) *aOS = os; - // XXX disabled for now as this calls GetAdapterVendorID and friends, which currently crash on Android, see bug 700124 - // FIXME: if this gets fixed, the line setting *aStatus must be removed -#if 0 return GfxInfoBase::GetFeatureStatusImpl(aFeature, aStatus, aSuggestedDriverVersion, aDriverInfo, &os); -#else - if (status == nsIGfxInfo::FEATURE_STATUS_UNKNOWN) - *aStatus = nsIGfxInfo::FEATURE_NO_INFO; -#endif - return NS_OK; } diff --git a/widget/src/android/GfxInfo.h b/widget/src/android/GfxInfo.h index 82f892e3bd48..0ca8b684e5a1 100644 --- a/widget/src/android/GfxInfo.h +++ b/widget/src/android/GfxInfo.h @@ -100,6 +100,11 @@ private: nsString mDriverDate; nsString mDeviceKey; + nsString mAdapterDeviceID; + nsString mAdapterVendorID; + nsString mAdapterDescription; + PRInt32 mAndroidSDKVersion; + PRUint32 mRendererIDs[16]; }; diff --git a/widget/src/xpwidgets/GfxDriverInfo.h b/widget/src/xpwidgets/GfxDriverInfo.h index 22a406222aab..e8d1ddebd495 100644 --- a/widget/src/xpwidgets/GfxDriverInfo.h +++ b/widget/src/xpwidgets/GfxDriverInfo.h @@ -156,6 +156,7 @@ struct GfxDriverInfo inline bool ParseDriverVersion(nsAString& aVersion, PRUint64 *aNumericVersion) { +#if defined(XP_WIN) int a, b, c, d; /* honestly, why do I even bother */ if (sscanf(NS_LossyConvertUTF16toASCII(aVersion).get(), @@ -167,6 +168,11 @@ ParseDriverVersion(nsAString& aVersion, PRUint64 *aNumericVersion) if (d < 0 || d > 0xffff) return false; *aNumericVersion = GFX_DRIVER_VERSION(a, b, c, d); +#elif defined(ANDROID) + // Can't use aVersion.ToInteger() because that's not compiled into our code + // unless we have XPCOM_GLUE_AVOID_NSPR disabled. + *aNumericVersion = atoi(NS_LossyConvertUTF16toASCII(aVersion).get()); +#endif return true; } diff --git a/widget/src/xpwidgets/GfxInfoBase.cpp b/widget/src/xpwidgets/GfxInfoBase.cpp index 15acbeccb12d..376e8bc9a367 100644 --- a/widget/src/xpwidgets/GfxInfoBase.cpp +++ b/widget/src/xpwidgets/GfxInfoBase.cpp @@ -664,7 +664,7 @@ GfxInfoBase::FindBlocklistedDeviceInList(const nsTArray& info, bool match = false; -#if !defined(XP_MACOSX) +#if defined(XP_WIN) || defined(ANDROID) switch (info[i].mComparisonOp) { case DRIVER_LESS_THAN: match = driverVersion < info[i].mDriverVersion; @@ -703,7 +703,7 @@ GfxInfoBase::FindBlocklistedDeviceInList(const nsTArray& info, match = true; #endif - if (match) { + if (match || info[i].mDriverVersion == GfxDriverInfo::allDriverVersions) { if (info[i].mFeature == GfxDriverInfo::allFeatures || info[i].mFeature == aFeature) { From 674cb87172e7cc1f072d75bec6b63183400cbf75 Mon Sep 17 00:00:00 2001 From: Doug Sherk Date: Wed, 14 Dec 2011 21:03:06 -0800 Subject: [PATCH 04/26] Bug 705959: move some special cases into global blocklists r=joe Some of the special cases in GfxInfo classes were only necessary because there was no generalized blocklist. These have been moved into the generalized blocklist for each GfxInfo. --- widget/src/android/GfxInfo.cpp | 26 +++++++++++---- widget/src/cocoa/GfxInfo.mm | 46 ++++---------------------- widget/src/xpwidgets/GfxDriverInfo.cpp | 17 ++++++++++ widget/src/xpwidgets/GfxDriverInfo.h | 2 ++ 4 files changed, 45 insertions(+), 46 deletions(-) diff --git a/widget/src/android/GfxInfo.cpp b/widget/src/android/GfxInfo.cpp index aedd323d4e45..2738a9b1c1f5 100644 --- a/widget/src/android/GfxInfo.cpp +++ b/widget/src/android/GfxInfo.cpp @@ -278,10 +278,19 @@ GfxInfo::AddOpenGLCrashReportAnnotations() const nsTArray& GfxInfo::GetGfxDriverInfo() { - // Nothing here yet. - //if (!mDriverInfo->Length()) { - // - //} + if (!mDriverInfo->Length()) { + /* The following entry, when uncommented, will allow us to whitelist a + * specific device. See the long comment in GetFeatureStatusImpl for more + * info. */ + // APPEND_TO_DRIVER_BLOCKLIST( DRIVER_OS_ALL, + // my_vendor_id, my_device_id, + // nsIGfxInfo::FEATURE_OPENGL_LAYERS, nsIGfxInfo::FEATURE_NO_INFO, + // DRIVER_LESS_THAN, GfxDriverInfo::allDevices ); + APPEND_TO_DRIVER_BLOCKLIST2( DRIVER_OS_ALL, + (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorAll), GfxDriverInfo::allDevices, + nsIGfxInfo::FEATURE_OPENGL_LAYERS, nsIGfxInfo::FEATURE_BLOCKED_DEVICE, + DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions ); + } return *mDriverInfo; } @@ -304,7 +313,12 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, mSetCrashReportAnnotations = true; } - /* XXX: Use this code when we're ready to whitelist devices. */ + /* The following code is an old way to whitelist devices when we're ready. + * It is staying here for reference. The best way to do this now is to add + * an entry in the list above. There is a dummy entry which will whitelist a + * device when uncommented and device/vendor IDs are inserted. It is + * preferred that we stop whitelisting and instead go to blocklisting, where + * everything is assumed to be okay as long as it's not in the blocklist. */ // nsAutoString str; // /* Whitelist Galaxy S phones */ // if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "HARDWARE", str)) { @@ -312,8 +326,6 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, // status = FEATURE_BLOCKED_DEVICE; // } // } - - status = FEATURE_BLOCKED_DEVICE; } *aStatus = status; diff --git a/widget/src/cocoa/GfxInfo.mm b/widget/src/cocoa/GfxInfo.mm index 65835bbf835b..b791bba176df 100644 --- a/widget/src/cocoa/GfxInfo.mm +++ b/widget/src/cocoa/GfxInfo.mm @@ -112,21 +112,6 @@ GfxInfo::GetDeviceInfo() } } -// TODO dRdR FIXME -static bool -IsATIRadeonX1000(nsAString& aVendorID, nsAString& aDeviceID) -{ - if (aVendorID.LowerCaseEqualsLiteral("0x1002")) { - // this list is from the ATIRadeonX1000.kext Info.plist - 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.LowerCaseEqualsASCII(devices[i])) - return true; - } - } - return false; -} - nsresult GfxInfo::Init() { @@ -369,6 +354,12 @@ GfxInfo::GetGfxDriverInfo() IMPLEMENT_MAC_DRIVER_BLOCKLIST(DRIVER_OS_ALL, (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorATI), GfxDriverInfo::allDevices, nsIGfxInfo::FEATURE_WEBGL_MSAA, nsIGfxInfo::FEATURE_BLOCKED_OS_VERSION); + IMPLEMENT_MAC_DRIVER_BLOCKLIST(DRIVER_OS_ALL, + (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorATI), (GfxDeviceFamily*) GfxDriverInfo::GetDeviceFamily(RadeonX1000), + nsIGfxInfo::FEATURE_OPENGL_LAYERS, nsIGfxInfo::FEATURE_BLOCKED_DEVICE); + IMPLEMENT_MAC_DRIVER_BLOCKLIST(DRIVER_OS_ALL, + (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorNVIDIA), (GfxDeviceFamily*) GfxDriverInfo::GetDeviceFamily(Geforce7300GT), + nsIGfxInfo::FEATURE_WEBGL_OPENGL, nsIGfxInfo::FEATURE_BLOCKED_DEVICE); } return *mDriverInfo; } @@ -412,13 +403,7 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, status = nsIGfxInfo::FEATURE_BLOCKED_OS_VERSION; } - if (aFeature == nsIGfxInfo::FEATURE_OPENGL_LAYERS) { - bool foundGoodDevice = false; - - if (!IsATIRadeonX1000(mAdapterVendorID, mAdapterDeviceID)) { - foundGoodDevice = true; - } - + // The code around the following has been moved into the global blocklist. #if 0 // CGL reports a list of renderers, some renderers are slow (e.g. software) // and AFAIK we can't decide which one will be used among them, so let's implement this by returning NO_INFO @@ -455,23 +440,6 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, } } #endif - if (!foundGoodDevice) - status = nsIGfxInfo::FEATURE_BLOCKED_DEVICE; - } - - if (aFeature == nsIGfxInfo::FEATURE_WEBGL_OPENGL) { - // same comment as above for FEATURE_OPENGL_LAYERS. - bool foundGoodDevice = true; - - // Blacklist the Geforce 7300 GT because of bug 678053 - if (mAdapterVendorID.LowerCaseEqualsLiteral("0x10de") && - mAdapterDeviceID.LowerCaseEqualsLiteral("0x0393")) { - foundGoodDevice = false; - } - - if (!foundGoodDevice) - status = nsIGfxInfo::FEATURE_BLOCKED_DEVICE; - } if (aFeature == nsIGfxInfo::FEATURE_WEBGL_MSAA) { // Blacklist all ATI cards on OSX, except for diff --git a/widget/src/xpwidgets/GfxDriverInfo.cpp b/widget/src/xpwidgets/GfxDriverInfo.cpp index 063f39985b8d..7c42dfb7dee0 100644 --- a/widget/src/xpwidgets/GfxDriverInfo.cpp +++ b/widget/src/xpwidgets/GfxDriverInfo.cpp @@ -215,6 +215,23 @@ const GfxDeviceFamily* GfxDriverInfo::GetDeviceFamily(DeviceFamily id) APPEND_DEVICE(0x03d2); /* C61 [GeForce 6100 nForce 400 (TM)] */ APPEND_DEVICE(0x03d5); /* C61 [GeForce 6100 nForce 420 (TM)] */ break; + case RadeonX1000: + // This list is from the ATIRadeonX1000.kext Info.plist + APPEND_DEVICE(0x7187); + APPEND_DEVICE(0x7210); + APPEND_DEVICE(0x71de); + APPEND_DEVICE(0x7146); + APPEND_DEVICE(0x7142); + APPEND_DEVICE(0x7109); + APPEND_DEVICE(0x71c5); + APPEND_DEVICE(0x71c0); + APPEND_DEVICE(0x7240); + APPEND_DEVICE(0x7249); + APPEND_DEVICE(0x7291); + break; + case Geforce7300GT: + APPEND_DEVICE(0x0393); + break; // This should never happen, but we get a warning if we don't handle this. case DeviceFamilyMax: NS_WARNING("Invalid DeviceFamily id"); diff --git a/widget/src/xpwidgets/GfxDriverInfo.h b/widget/src/xpwidgets/GfxDriverInfo.h index e8d1ddebd495..69105e61b690 100644 --- a/widget/src/xpwidgets/GfxDriverInfo.h +++ b/widget/src/xpwidgets/GfxDriverInfo.h @@ -88,6 +88,8 @@ enum DeviceFamily { IntelGMAX3000, IntelGMAX4500HD, NvidiaBlockD3D9Layers, + RadeonX1000, + Geforce7300GT, DeviceFamilyMax }; From 0d1edb8efed40c9e01bf9d7d2c690d0fd8053319 Mon Sep 17 00:00:00 2001 From: Doug Sherk Date: Wed, 14 Dec 2011 21:03:08 -0800 Subject: [PATCH 05/26] Bug 706739: don't evaluate static blocklist or special cases when evaluating downloaded blocklist r=joe A bug was introduced in 668004 which caused features to be preffed off while evaluating the downloaded blocklist, even if they weren't in the list. This shouldn't actually have any impact on the end user experience, but is definitely not optimal. --- widget/src/android/GfxInfo.cpp | 52 ++++----- widget/src/cocoa/GfxInfo.mm | 126 +++++++++++----------- widget/src/windows/GfxInfo.cpp | 158 ++++++++++++++-------------- widget/src/xpwidgets/GfxInfoX11.cpp | 65 ++++++------ 4 files changed, 201 insertions(+), 200 deletions(-) diff --git a/widget/src/android/GfxInfo.cpp b/widget/src/android/GfxInfo.cpp index 2738a9b1c1f5..7500b561c3bf 100644 --- a/widget/src/android/GfxInfo.cpp +++ b/widget/src/android/GfxInfo.cpp @@ -301,36 +301,36 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, const nsTArray& aDriverInfo, OperatingSystem* aOS /* = nsnull */) { - PRInt32 status = nsIGfxInfo::FEATURE_STATUS_UNKNOWN; - + NS_ENSURE_ARG_POINTER(aStatus); aSuggestedDriverVersion.SetIsVoid(true); - + *aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN; OperatingSystem os = DRIVER_OS_ANDROID; - - if (aFeature == FEATURE_OPENGL_LAYERS) { - if (!mSetCrashReportAnnotations) { - AddOpenGLCrashReportAnnotations(); - mSetCrashReportAnnotations = true; - } - - /* The following code is an old way to whitelist devices when we're ready. - * It is staying here for reference. The best way to do this now is to add - * an entry in the list above. There is a dummy entry which will whitelist a - * device when uncommented and device/vendor IDs are inserted. It is - * preferred that we stop whitelisting and instead go to blocklisting, where - * everything is assumed to be okay as long as it's not in the blocklist. */ - // nsAutoString str; - // /* Whitelist Galaxy S phones */ - // if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "HARDWARE", str)) { - // if (str != NS_LITERAL_STRING("smdkc110")) { - // status = FEATURE_BLOCKED_DEVICE; - // } - // } - } - - *aStatus = status; if (aOS) *aOS = os; + // Don't evaluate special cases when evaluating the downlaoded blocklist. + if (!aDriverInfo.Length()) { + if (aFeature == FEATURE_OPENGL_LAYERS) { + if (!mSetCrashReportAnnotations) { + AddOpenGLCrashReportAnnotations(); + mSetCrashReportAnnotations = true; + } + + /* The following code is an old way to whitelist devices when we're ready. + * It is staying here for reference. The best way to do this now is to add + * an entry in the list above. There is a dummy entry which will whitelist a + * device when uncommented and device/vendor IDs are inserted. It is + * preferred that we stop whitelisting and instead go to blocklisting, where + * everything is assumed to be okay as long as it's not in the blocklist. */ + // nsAutoString str; + // /* Whitelist Galaxy S phones */ + // if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "HARDWARE", str)) { + // if (str != NS_LITERAL_STRING("smdkc110")) { + // status = FEATURE_BLOCKED_DEVICE; + // } + // } + } + } + return GfxInfoBase::GetFeatureStatusImpl(aFeature, aStatus, aSuggestedDriverVersion, aDriverInfo, &os); } diff --git a/widget/src/cocoa/GfxInfo.mm b/widget/src/cocoa/GfxInfo.mm index b791bba176df..45cb8515612b 100644 --- a/widget/src/cocoa/GfxInfo.mm +++ b/widget/src/cocoa/GfxInfo.mm @@ -387,74 +387,72 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, OperatingSystem* aOS /* = nsnull */) { NS_ENSURE_ARG_POINTER(aStatus); - aSuggestedDriverVersion.SetIsVoid(true); - - PRInt32 status = nsIGfxInfo::FEATURE_STATUS_UNKNOWN; - + *aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN; OperatingSystem os = OSXVersionToOperatingSystem(nsToolkit::OSXVersion()); - - // Many WebGL issues on 10.5, especially: - // * bug 631258: WebGL shader paints using textures belonging to other processes on Mac OS 10.5 - // * bug 618848: Post process shaders and texture mapping crash OS X 10.5 - if (aFeature == nsIGfxInfo::FEATURE_WEBGL_OPENGL && - !nsToolkit::OnSnowLeopardOrLater()) - { - status = nsIGfxInfo::FEATURE_BLOCKED_OS_VERSION; - } - - // The code around the following has been moved into the global blocklist. -#if 0 - // CGL reports a list of renderers, some renderers are slow (e.g. software) - // and AFAIK we can't decide which one will be used among them, so let's implement this by returning NO_INFO - // if any not-known-to-be-bad renderer is found. - // The assumption that we make here is that the system will spontaneously use the best/fastest renderer in the list. - // Note that the presence of software renderer fallbacks means that slow software rendering may be automatically - // used, which seems to be the case in bug 611292 where the user had a Intel GMA 945 card (non programmable hardware). - // Therefore we need to explicitly blacklist non-OpenGL2 hardware, which could result in a software renderer - // being used. - - for (PRUint32 i = 0; i < ArrayLength(mRendererIDs); ++i) { - switch (mRendererIDs[i]) { - case kCGLRendererATIRage128ID: // non-programmable - case kCGLRendererATIRadeonID: // non-programmable - case kCGLRendererATIRageProID: // non-programmable - case kCGLRendererATIRadeon8500ID: // no OpenGL 2 support, http://en.wikipedia.org/wiki/Radeon_R200 - case kCGLRendererATIRadeon9700ID: // no OpenGL 2 support, http://en.wikipedia.org/wiki/Radeon_R200 - case kCGLRendererATIRadeonX1000ID: // can't render to non-power-of-two texture backed framebuffers - case kCGLRendererIntel900ID: // non-programmable - case kCGLRendererGeForce2MXID: // non-programmable - case kCGLRendererGeForce3ID: // no OpenGL 2 support, - // http://en.wikipedia.org/wiki/Comparison_of_Nvidia_graphics_processing_units - case kCGLRendererGeForceFXID: // incomplete OpenGL 2 support with software fallbacks, - // http://en.wikipedia.org/wiki/Comparison_of_Nvidia_graphics_processing_units - case kCGLRendererVTBladeXP2ID: // Trident DX8 chip, assuming it's not GL2 capable - case kCGLRendererMesa3DFXID: // non-programmable - case kCGLRendererGenericFloatID: // software renderer - case kCGLRendererGenericID: // software renderer - case kCGLRendererAppleSWID: // software renderer - break; - default: - if (mRendererIDs[i]) - foundGoodDevice = true; - } - } -#endif - - if (aFeature == nsIGfxInfo::FEATURE_WEBGL_MSAA) { - // Blacklist all ATI cards on OSX, except for - // 0x6760 and 0x9488 - if (mAdapterVendorID == GfxDriverInfo::GetDeviceVendor(VendorATI) && - (mAdapterDeviceID.LowerCaseEqualsLiteral("0x6760") || - mAdapterDeviceID.LowerCaseEqualsLiteral("0x9488"))) { - *aStatus = nsIGfxInfo::FEATURE_NO_INFO; - return NS_OK; - } - } - if (aOS) *aOS = os; - *aStatus = status; + + // Don't evaluate special cases when we're evaluating the downloaded blocklist. + if (!aDriverInfo.Length()) { + // Many WebGL issues on 10.5, especially: + // * bug 631258: WebGL shader paints using textures belonging to other processes on Mac OS 10.5 + // * bug 618848: Post process shaders and texture mapping crash OS X 10.5 + if (aFeature == nsIGfxInfo::FEATURE_WEBGL_OPENGL && + !nsToolkit::OnSnowLeopardOrLater()) { + *aStatus = nsIGfxInfo::FEATURE_BLOCKED_OS_VERSION; + return NS_OK; + } + + // The code around the following has been moved into the global blocklist. +#if 0 + // CGL reports a list of renderers, some renderers are slow (e.g. software) + // and AFAIK we can't decide which one will be used among them, so let's implement this by returning NO_INFO + // if any not-known-to-be-bad renderer is found. + // The assumption that we make here is that the system will spontaneously use the best/fastest renderer in the list. + // Note that the presence of software renderer fallbacks means that slow software rendering may be automatically + // used, which seems to be the case in bug 611292 where the user had a Intel GMA 945 card (non programmable hardware). + // Therefore we need to explicitly blacklist non-OpenGL2 hardware, which could result in a software renderer + // being used. + + for (PRUint32 i = 0; i < ArrayLength(mRendererIDs); ++i) { + switch (mRendererIDs[i]) { + case kCGLRendererATIRage128ID: // non-programmable + case kCGLRendererATIRadeonID: // non-programmable + case kCGLRendererATIRageProID: // non-programmable + case kCGLRendererATIRadeon8500ID: // no OpenGL 2 support, http://en.wikipedia.org/wiki/Radeon_R200 + case kCGLRendererATIRadeon9700ID: // no OpenGL 2 support, http://en.wikipedia.org/wiki/Radeon_R200 + case kCGLRendererATIRadeonX1000ID: // can't render to non-power-of-two texture backed framebuffers + case kCGLRendererIntel900ID: // non-programmable + case kCGLRendererGeForce2MXID: // non-programmable + case kCGLRendererGeForce3ID: // no OpenGL 2 support, + // http://en.wikipedia.org/wiki/Comparison_of_Nvidia_graphics_processing_units + case kCGLRendererGeForceFXID: // incomplete OpenGL 2 support with software fallbacks, + // http://en.wikipedia.org/wiki/Comparison_of_Nvidia_graphics_processing_units + case kCGLRendererVTBladeXP2ID: // Trident DX8 chip, assuming it's not GL2 capable + case kCGLRendererMesa3DFXID: // non-programmable + case kCGLRendererGenericFloatID: // software renderer + case kCGLRendererGenericID: // software renderer + case kCGLRendererAppleSWID: // software renderer + break; + default: + if (mRendererIDs[i]) + foundGoodDevice = true; + } + } +#endif + + if (aFeature == nsIGfxInfo::FEATURE_WEBGL_MSAA) { + // Blacklist all ATI cards on OSX, except for + // 0x6760 and 0x9488 + if (mAdapterVendorID == GfxDriverInfo::GetDeviceVendor(VendorATI) && + (mAdapterDeviceID.LowerCaseEqualsLiteral("0x6760") || + mAdapterDeviceID.LowerCaseEqualsLiteral("0x9488"))) { + *aStatus = nsIGfxInfo::FEATURE_NO_INFO; + return NS_OK; + } + } + } return GfxInfoBase::GetFeatureStatusImpl(aFeature, aStatus, aSuggestedDriverVersion, aDriverInfo, &os); } diff --git a/widget/src/windows/GfxInfo.cpp b/widget/src/windows/GfxInfo.cpp index 775b40f7f2f7..66383f2976f0 100644 --- a/widget/src/windows/GfxInfo.cpp +++ b/widget/src/windows/GfxInfo.cpp @@ -940,90 +940,90 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, const nsTArray& aDriverInfo, OperatingSystem* aOS /* = nsnull */) { + NS_ENSURE_ARG_POINTER(aStatus); aSuggestedDriverVersion.SetIsVoid(true); - - PRInt32 status = nsIGfxInfo::FEATURE_STATUS_UNKNOWN; - - nsAutoString adapterVendorID; - nsAutoString adapterDeviceID; - nsAutoString adapterDriverVersionString; - if (NS_FAILED(GetAdapterVendorID(adapterVendorID)) || - NS_FAILED(GetAdapterDeviceID(adapterDeviceID)) || - NS_FAILED(GetAdapterDriverVersion(adapterDriverVersionString))) - { - return NS_ERROR_FAILURE; - } - - 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.LowerCaseEqualsLiteral("0xabcd") && - !adapterVendorID.LowerCaseEqualsLiteral("0xdcba") && - !adapterVendorID.LowerCaseEqualsLiteral("0xabab") && - !adapterVendorID.LowerCaseEqualsLiteral("0xdcdc")) - { - *aStatus = FEATURE_BLOCKED_DEVICE; - return NS_OK; - } - - PRUint64 driverVersion; - if (!ParseDriverVersion(adapterDriverVersionString, &driverVersion)) { - return NS_ERROR_FAILURE; - } - - // special-case the WinXP test slaves: they have out-of-date drivers, but we still want to - // whitelist them, actually we do know that this combination of device and driver version - // works well. - if (mWindowsVersion == gfxWindowsPlatform::kWindowsXP && - adapterVendorID == GfxDriverInfo::GetDeviceVendor(VendorNVIDIA) && - adapterDeviceID.LowerCaseEqualsLiteral("0x0861") && // GeForce 9400 - driverVersion == V(6,14,11,7756)) - { - *aStatus = FEATURE_NO_INFO; - return NS_OK; - } - - if (aFeature == FEATURE_DIRECT3D_9_LAYERS && - mWindowsVersion < gfxWindowsPlatform::kWindowsXP) - { - *aStatus = FEATURE_BLOCKED_OS_VERSION; - return NS_OK; - } - - // ANGLE currently uses D3D10 <-> D3D9 interop, which crashes on Optimus - // machines. - if (aFeature == FEATURE_WEBGL_ANGLE && - gfxWindowsPlatform::IsOptimus()) - { - *aStatus = FEATURE_BLOCKED_DEVICE; - return NS_OK; - } - OperatingSystem os = WindowsVersionToOperatingSystem(mWindowsVersion); - - // Windows Server 2003 should be just like Windows XP for present purpose, but still has a different version number. - // OTOH Windows Server 2008 R1 and R2 already have the same version numbers as Vista and Seven respectively - if (os == DRIVER_OS_WINDOWS_SERVER_2003) - os = DRIVER_OS_WINDOWS_XP; - - if (mHasDriverVersionMismatch) { - if (aFeature == nsIGfxInfo::FEATURE_DIRECT3D_10_LAYERS || - aFeature == nsIGfxInfo::FEATURE_DIRECT3D_10_1_LAYERS || - aFeature == nsIGfxInfo::FEATURE_DIRECT2D) - { - *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION; - return NS_OK; - } - } - - *aStatus = status; + *aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN; if (aOS) *aOS = os; + // Don't evaluate special cases if we're checking the downloaded blocklist. + if (!aDriverInfo.Length()) { + nsAutoString adapterVendorID; + nsAutoString adapterDeviceID; + nsAutoString adapterDriverVersionString; + if (NS_FAILED(GetAdapterVendorID(adapterVendorID)) || + NS_FAILED(GetAdapterDeviceID(adapterDeviceID)) || + NS_FAILED(GetAdapterDriverVersion(adapterDriverVersionString))) + { + return NS_ERROR_FAILURE; + } + + 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.LowerCaseEqualsLiteral("0xabcd") && + !adapterVendorID.LowerCaseEqualsLiteral("0xdcba") && + !adapterVendorID.LowerCaseEqualsLiteral("0xabab") && + !adapterVendorID.LowerCaseEqualsLiteral("0xdcdc")) + { + *aStatus = FEATURE_BLOCKED_DEVICE; + return NS_OK; + } + + PRUint64 driverVersion; + if (!ParseDriverVersion(adapterDriverVersionString, &driverVersion)) { + return NS_ERROR_FAILURE; + } + + // special-case the WinXP test slaves: they have out-of-date drivers, but we still want to + // whitelist them, actually we do know that this combination of device and driver version + // works well. + if (mWindowsVersion == gfxWindowsPlatform::kWindowsXP && + adapterVendorID == GfxDriverInfo::GetDeviceVendor(VendorNVIDIA) && + adapterDeviceID.LowerCaseEqualsLiteral("0x0861") && // GeForce 9400 + driverVersion == V(6,14,11,7756)) + { + *aStatus = FEATURE_NO_INFO; + return NS_OK; + } + + if (aFeature == FEATURE_DIRECT3D_9_LAYERS && + mWindowsVersion < gfxWindowsPlatform::kWindowsXP) + { + *aStatus = FEATURE_BLOCKED_OS_VERSION; + return NS_OK; + } + + // ANGLE currently uses D3D10 <-> D3D9 interop, which crashes on Optimus + // machines. + if (aFeature == FEATURE_WEBGL_ANGLE && + gfxWindowsPlatform::IsOptimus()) + { + *aStatus = FEATURE_BLOCKED_DEVICE; + return NS_OK; + } + + // Windows Server 2003 should be just like Windows XP for present purpose, but still has a different version number. + // OTOH Windows Server 2008 R1 and R2 already have the same version numbers as Vista and Seven respectively + if (os == DRIVER_OS_WINDOWS_SERVER_2003) + os = DRIVER_OS_WINDOWS_XP; + + if (mHasDriverVersionMismatch) { + if (aFeature == nsIGfxInfo::FEATURE_DIRECT3D_10_LAYERS || + aFeature == nsIGfxInfo::FEATURE_DIRECT3D_10_1_LAYERS || + aFeature == nsIGfxInfo::FEATURE_DIRECT2D) + { + *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION; + return NS_OK; + } + } + } + return GfxInfoBase::GetFeatureStatusImpl(aFeature, aStatus, aSuggestedDriverVersion, aDriverInfo, &os); } diff --git a/widget/src/xpwidgets/GfxInfoX11.cpp b/widget/src/xpwidgets/GfxInfoX11.cpp index f0e2c94e63ea..ab3feb6cb58d 100644 --- a/widget/src/xpwidgets/GfxInfoX11.cpp +++ b/widget/src/xpwidgets/GfxInfoX11.cpp @@ -264,23 +264,28 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, OperatingSystem* aOS /* = nsnull */) { - GetData(); - *aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN; - aSuggestedDriverVersion.SetIsVoid(true); + NS_ENSURE_ARG_POINTER(aStatus); + *aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN; + aSuggestedDriverVersion.SetIsVoid(true); + OperatingSystem os = DRIVER_OS_LINUX; + if (aOS) + *aOS = os; #ifdef MOZ_PLATFORM_MAEMO - *aStatus = nsIGfxInfo::FEATURE_NO_INFO; - // on Maemo, the glxtest probe doesn't build, and we don't really need GfxInfo anyway - return NS_OK; + *aStatus = nsIGfxInfo::FEATURE_NO_INFO; + // on Maemo, the glxtest probe doesn't build, and we don't really need GfxInfo anyway + return NS_OK; #endif - OperatingSystem os = DRIVER_OS_LINUX; + // Don't evaluate any special cases if we're checking the downloaded blocklist. + if (!aDriverInfo.Length()) { + GetData(); // Disable OpenGL layers when we don't have texture_from_pixmap because it regresses performance. if (aFeature == nsIGfxInfo::FEATURE_OPENGL_LAYERS && !mHasTextureFromPixmap) { - *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION; - aSuggestedDriverVersion.AssignLiteral(""); - return NS_OK; + *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION; + aSuggestedDriverVersion.AssignLiteral(""); + return NS_OK; } // whitelist the linux test slaves' current configuration. @@ -292,34 +297,32 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, !strcmp(mRenderer.get(), "GeForce 9400/PCI/SSE2") && !strcmp(mVersion.get(), "3.2.0 NVIDIA 190.42")) { - *aStatus = nsIGfxInfo::FEATURE_NO_INFO; - return NS_OK; + *aStatus = nsIGfxInfo::FEATURE_NO_INFO; + return NS_OK; } if (mIsMesa) { - if (version(mMajorVersion, mMinorVersion, mRevisionVersion) < version(7,10,3)) { - *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION; - aSuggestedDriverVersion.AssignLiteral("Mesa 7.10.3"); - } + if (version(mMajorVersion, mMinorVersion, mRevisionVersion) < version(7,10,3)) { + *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION; + aSuggestedDriverVersion.AssignLiteral("Mesa 7.10.3"); + } } else if (mIsNVIDIA) { - if (version(mMajorVersion, mMinorVersion, mRevisionVersion) < version(257,21)) { - *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION; - aSuggestedDriverVersion.AssignLiteral("NVIDIA 257.21"); - } + if (version(mMajorVersion, mMinorVersion, mRevisionVersion) < version(257,21)) { + *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION; + aSuggestedDriverVersion.AssignLiteral("NVIDIA 257.21"); + } } else if (mIsFGLRX) { - // FGLRX does not report a driver version number, so we have the OpenGL version instead. - // by requiring OpenGL 3, we effectively require recent drivers. - if (version(mMajorVersion, mMinorVersion, mRevisionVersion) < version(3, 0)) { - *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION; - } + // FGLRX does not report a driver version number, so we have the OpenGL version instead. + // by requiring OpenGL 3, we effectively require recent drivers. + if (version(mMajorVersion, mMinorVersion, mRevisionVersion) < version(3, 0)) { + *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION; + } } else { - // like on windows, let's block unknown vendors. Think of virtual machines. - // Also, this case is hit whenever the GLXtest probe failed to get driver info or crashed. - *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE; + // like on windows, let's block unknown vendors. Think of virtual machines. + // Also, this case is hit whenever the GLXtest probe failed to get driver info or crashed. + *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE; } - - if (aOS) - *aOS = os; + } return GfxInfoBase::GetFeatureStatusImpl(aFeature, aStatus, aSuggestedDriverVersion, aDriverInfo, &os); } From 1a923cc362dacb5fe431f6e5e97cf4cc48d46f08 Mon Sep 17 00:00:00 2001 From: Doug Sherk Date: Wed, 14 Dec 2011 21:03:11 -0800 Subject: [PATCH 06/26] Bug 689598: fix crash reporter on Android r=BenWa --- widget/src/android/GfxInfo.cpp | 9 ++------- widget/src/android/GfxInfo.h | 1 - 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/widget/src/android/GfxInfo.cpp b/widget/src/android/GfxInfo.cpp index 7500b561c3bf..4cbed96923f7 100644 --- a/widget/src/android/GfxInfo.cpp +++ b/widget/src/android/GfxInfo.cpp @@ -88,8 +88,6 @@ GfxInfo::GetCleartypeParameters(nsAString & aCleartypeParams) nsresult GfxInfo::Init() { - mSetCrashReportAnnotations = false; - mAdapterDescription.AssignASCII(mozilla::gl::GetVendor()); if (mozilla::AndroidBridge::Bridge()) { nsAutoString str; @@ -124,6 +122,8 @@ GfxInfo::Init() mAndroidSDKVersion = version; } + AddOpenGLCrashReportAnnotations(); + return GfxInfoBase::Init(); } @@ -311,11 +311,6 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, // Don't evaluate special cases when evaluating the downlaoded blocklist. if (!aDriverInfo.Length()) { if (aFeature == FEATURE_OPENGL_LAYERS) { - if (!mSetCrashReportAnnotations) { - AddOpenGLCrashReportAnnotations(); - mSetCrashReportAnnotations = true; - } - /* The following code is an old way to whitelist devices when we're ready. * It is staying here for reference. The best way to do this now is to add * an entry in the list above. There is a dummy entry which will whitelist a diff --git a/widget/src/android/GfxInfo.h b/widget/src/android/GfxInfo.h index 0ca8b684e5a1..abfe5994f622 100644 --- a/widget/src/android/GfxInfo.h +++ b/widget/src/android/GfxInfo.h @@ -91,7 +91,6 @@ protected: private: void AddOpenGLCrashReportAnnotations(); - bool mSetCrashReportAnnotations; nsString mRendererIDsString; nsString mAdapterRAMString; From cf38d95805d3e9dcabe21186ffb14c185081fe58 Mon Sep 17 00:00:00 2001 From: Doug Sherk Date: Wed, 14 Dec 2011 21:03:13 -0800 Subject: [PATCH 07/26] Bug 710432: fix Linux GfxInfo to do feature checks r=joe Also includes changes to allow Linux GfxInfo to provide a vendor and device id. --- widget/src/xpwidgets/GfxInfoX11.cpp | 87 ++++++++++++++++------------- 1 file changed, 47 insertions(+), 40 deletions(-) diff --git a/widget/src/xpwidgets/GfxInfoX11.cpp b/widget/src/xpwidgets/GfxInfoX11.cpp index ab3feb6cb58d..51f537a09e3b 100644 --- a/widget/src/xpwidgets/GfxInfoX11.cpp +++ b/widget/src/xpwidgets/GfxInfoX11.cpp @@ -279,48 +279,53 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, // Don't evaluate any special cases if we're checking the downloaded blocklist. if (!aDriverInfo.Length()) { - GetData(); + // Only check features relevant to Linux. + if (aFeature == nsIGfxInfo::FEATURE_OPENGL_LAYERS || + aFeature == nsIGfxInfo::FEATURE_WEBGL_OPENGL || + aFeature == nsIGfxInfo::FEATURE_WEBGL_MSAA) { + GetData(); - // Disable OpenGL layers when we don't have texture_from_pixmap because it regresses performance. - if (aFeature == nsIGfxInfo::FEATURE_OPENGL_LAYERS && !mHasTextureFromPixmap) { - *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION; - aSuggestedDriverVersion.AssignLiteral(""); - return NS_OK; - } + // Disable OpenGL layers when we don't have texture_from_pixmap because it regresses performance. + if (aFeature == nsIGfxInfo::FEATURE_OPENGL_LAYERS && !mHasTextureFromPixmap) { + *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION; + aSuggestedDriverVersion.AssignLiteral(""); + return NS_OK; + } - // whitelist the linux test slaves' current configuration. - // this is necessary as they're still using the slightly outdated 190.42 driver. - // this isn't a huge risk, as at least this is the exact setting in which we do continuous testing, - // and this only affects GeForce 9400 cards on linux on this precise driver version, which is very few users. - // We do the same thing on Windows XP, see in widget/src/windows/GfxInfo.cpp - if (mIsNVIDIA && - !strcmp(mRenderer.get(), "GeForce 9400/PCI/SSE2") && - !strcmp(mVersion.get(), "3.2.0 NVIDIA 190.42")) - { - *aStatus = nsIGfxInfo::FEATURE_NO_INFO; - return NS_OK; - } + // whitelist the linux test slaves' current configuration. + // this is necessary as they're still using the slightly outdated 190.42 driver. + // this isn't a huge risk, as at least this is the exact setting in which we do continuous testing, + // and this only affects GeForce 9400 cards on linux on this precise driver version, which is very few users. + // We do the same thing on Windows XP, see in widget/src/windows/GfxInfo.cpp + if (mIsNVIDIA && + !strcmp(mRenderer.get(), "GeForce 9400/PCI/SSE2") && + !strcmp(mVersion.get(), "3.2.0 NVIDIA 190.42")) + { + *aStatus = nsIGfxInfo::FEATURE_NO_INFO; + return NS_OK; + } - if (mIsMesa) { - if (version(mMajorVersion, mMinorVersion, mRevisionVersion) < version(7,10,3)) { - *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION; - aSuggestedDriverVersion.AssignLiteral("Mesa 7.10.3"); + if (mIsMesa) { + if (version(mMajorVersion, mMinorVersion, mRevisionVersion) < version(7,10,3)) { + *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION; + aSuggestedDriverVersion.AssignLiteral("Mesa 7.10.3"); + } + } else if (mIsNVIDIA) { + if (version(mMajorVersion, mMinorVersion, mRevisionVersion) < version(257,21)) { + *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION; + aSuggestedDriverVersion.AssignLiteral("NVIDIA 257.21"); + } + } else if (mIsFGLRX) { + // FGLRX does not report a driver version number, so we have the OpenGL version instead. + // by requiring OpenGL 3, we effectively require recent drivers. + if (version(mMajorVersion, mMinorVersion, mRevisionVersion) < version(3, 0)) { + *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION; + } + } else { + // like on windows, let's block unknown vendors. Think of virtual machines. + // Also, this case is hit whenever the GLXtest probe failed to get driver info or crashed. + *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE; } - } else if (mIsNVIDIA) { - if (version(mMajorVersion, mMinorVersion, mRevisionVersion) < version(257,21)) { - *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION; - aSuggestedDriverVersion.AssignLiteral("NVIDIA 257.21"); - } - } else if (mIsFGLRX) { - // FGLRX does not report a driver version number, so we have the OpenGL version instead. - // by requiring OpenGL 3, we effectively require recent drivers. - if (version(mMajorVersion, mMinorVersion, mRevisionVersion) < version(3, 0)) { - *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION; - } - } else { - // like on windows, let's block unknown vendors. Think of virtual machines. - // Also, this case is hit whenever the GLXtest probe failed to get driver info or crashed. - *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE; } } @@ -441,7 +446,8 @@ GfxInfo::GetAdapterDriverDate2(nsAString & aAdapterDriverDate) NS_IMETHODIMP GfxInfo::GetAdapterVendorID(nsAString & aAdapterVendorID) { - aAdapterVendorID.AssignLiteral(""); + GetData(); + CopyUTF8toUTF16(mVendor, aAdapterVendorID); return NS_OK; } @@ -456,7 +462,8 @@ GfxInfo::GetAdapterVendorID2(nsAString & aAdapterVendorID) NS_IMETHODIMP GfxInfo::GetAdapterDeviceID(nsAString & aAdapterDeviceID) { - aAdapterDeviceID.AssignLiteral(""); + GetData(); + CopyUTF8toUTF16(mRenderer, aAdapterDeviceID); return NS_OK; } From 043ebf1931f9c19e0a22a4bd9982dff23cf89e78 Mon Sep 17 00:00:00 2001 From: Doug Sherk Date: Wed, 14 Dec 2011 21:04:35 -0800 Subject: [PATCH 08/26] Bug 710103: Update XPCShell tests for GfxInfo blocklisting r=joe a=mbrubeck --- .../test/xpcshell/data/test_gfxBlacklist.xml | 60 ++++++++++++++++ .../test/xpcshell/test_gfxBlacklist_AllOS1.js | 72 ------------------- .../test/xpcshell/test_gfxBlacklist_AllOS2.js | 72 ------------------- .../test/xpcshell/test_gfxBlacklist_Device.js | 34 +++++++-- .../xpcshell/test_gfxBlacklist_DriverNew.js | 33 +++++++-- .../test_gfxBlacklist_Equal_DriverNew.js | 33 +++++++-- .../test_gfxBlacklist_Equal_DriverOld.js | 33 +++++++-- .../xpcshell/test_gfxBlacklist_Equal_OK.js | 33 +++++++-- .../test_gfxBlacklist_GTE_DriverOld.js | 33 +++++++-- .../test/xpcshell/test_gfxBlacklist_GTE_OK.js | 33 +++++++-- .../test/xpcshell/test_gfxBlacklist_OK.js | 34 +++++++-- .../test/xpcshell/test_gfxBlacklist_OS.js | 35 +++++++-- .../test/xpcshell/test_gfxBlacklist_Vendor.js | 34 +++++++-- .../test/xpcshell/test_gfxBlacklist_prefs.js | 34 +++++++-- .../extensions/test/xpcshell/xpcshell.ini | 2 - widget/public/nsIGfxInfoDebug.idl | 6 +- widget/src/android/GfxInfo.cpp | 37 ++++++++++ widget/src/android/GfxInfo.h | 5 ++ widget/src/cocoa/GfxInfo.h | 6 ++ widget/src/cocoa/GfxInfo.mm | 71 +++++++++++++----- widget/src/windows/GfxInfo.cpp | 12 ++-- widget/src/windows/GfxInfo.h | 8 +-- widget/src/xpwidgets/GfxInfoBase.h | 4 ++ widget/src/xpwidgets/GfxInfoX11.cpp | 38 ++++++++++ widget/src/xpwidgets/GfxInfoX11.h | 5 ++ 25 files changed, 534 insertions(+), 233 deletions(-) delete mode 100644 toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_AllOS1.js delete mode 100644 toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_AllOS2.js diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist.xml b/toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist.xml index cf4f4d77d1b4..6ba553da8136 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist.xml +++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist.xml @@ -54,5 +54,65 @@ 8.52.322.1111 EQUAL + + Darwin 9 + 0xabcd + + 0x2783 + 0x1234 + 0x2782 + + DIRECT2D + BLOCKED_DRIVER_VERSION + + + Linux + 0xabcd + + 0x2783 + 0x1234 + 0x2782 + + DIRECT2D + BLOCKED_DRIVER_VERSION + + + Android + abcd + + wxyz + asdf + erty + + DIRECT2D + BLOCKED_DRIVER_VERSION + 5 + LESS_THAN_OR_EQUAL + + + Android + dcdc + + uiop + vbnm + hjkl + + DIRECT2D + BLOCKED_DRIVER_VERSION + 5 + EQUAL + + + Android + abab + + ghjk + cvbn + + DIRECT2D + BLOCKED_DRIVER_VERSION + 7 + GREATER_THAN_OR_EQUAL + diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_AllOS1.js b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_AllOS1.js deleted file mode 100644 index 7217d61d369f..000000000000 --- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_AllOS1.js +++ /dev/null @@ -1,72 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -// Make sure that a blacklist entry with an OS of "All" matches Windows 7, as -// long as the rest of the blacklist matches it. -// Uses test_gfxBlacklist_AllOS.xml - -do_load_httpd_js(); - -var gTestserver = null; - -function load_blocklist(file) { - Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:4444/data/" + file); - var blocklist = Cc["@mozilla.org/extensions/blocklist;1"]. - getService(Ci.nsITimerCallback); - blocklist.notify(null); -} - -// Performs the initial setup -function run_test() { - try { - var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo); - } catch (e) { - do_test_finished(); - return; - } - - // We can't do anything if we can't spoof the stuff we need. - if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) { - do_test_finished(); - return; - } - - gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug); - - // Set the vendor/device ID, etc, to match the test file. - gfxInfo.spoofVendorID(0xabcd); - gfxInfo.spoofDeviceID(0x1234); - gfxInfo.spoofDriverVersion("8.52.322.2201"); - // Windows 7 - gfxInfo.spoofOSVersion(0x60001); - - createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8"); - startupManager(); - - gTestserver = new nsHttpServer(); - gTestserver.registerDirectory("/data/", do_get_file("data")); - gTestserver.start(4444); - - do_test_pending(); - - function checkBlacklist() - { - var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D); - do_check_eq(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION); - - // Make sure unrelated features aren't affected - status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS); - do_check_eq(status, Ci.nsIGfxInfo.FEATURE_NO_INFO); - - gTestserver.stop(do_test_finished); - } - - Services.obs.addObserver(function(aSubject, aTopic, aData) { - // If we wait until after we go through the event loop, gfxInfo is sure to - // have processed the gfxItems event. - do_execute_soon(checkBlacklist); - }, "blocklist-data-gfxItems", false); - - load_blocklist("test_gfxBlacklist_AllOS.xml"); -} diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_AllOS2.js b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_AllOS2.js deleted file mode 100644 index 62d220fd167d..000000000000 --- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_AllOS2.js +++ /dev/null @@ -1,72 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -// Make sure that a blacklist entry with an OS of "All" matches Windows Vista, -// as long as the rest of the blacklist matches it. -// Uses test_gfxBlacklist_AllOS.xml - -do_load_httpd_js(); - -var gTestserver = null; - -function load_blocklist(file) { - Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:4444/data/" + file); - var blocklist = Cc["@mozilla.org/extensions/blocklist;1"]. - getService(Ci.nsITimerCallback); - blocklist.notify(null); -} - -// Performs the initial setup -function run_test() { - try { - var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo); - } catch (e) { - do_test_finished(); - return; - } - - // We can't do anything if we can't spoof the stuff we need. - if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) { - do_test_finished(); - return; - } - - gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug); - - // Set the vendor/device ID, etc, to match the test file. - gfxInfo.spoofVendorID(0xabcd); - gfxInfo.spoofDeviceID(0x1234); - gfxInfo.spoofDriverVersion("8.52.322.2201"); - // Windows Vista - gfxInfo.spoofOSVersion(0x60000); - - createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8"); - startupManager(); - - gTestserver = new nsHttpServer(); - gTestserver.registerDirectory("/data/", do_get_file("data")); - gTestserver.start(4444); - - do_test_pending(); - - function checkBlacklist() - { - var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D); - do_check_eq(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION); - - // Make sure unrelated features aren't affected - status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS); - do_check_eq(status, Ci.nsIGfxInfo.FEATURE_NO_INFO); - - gTestserver.stop(do_test_finished); - } - - Services.obs.addObserver(function(aSubject, aTopic, aData) { - // If we wait until after we go through the event loop, gfxInfo is sure to - // have processed the gfxItems event. - do_execute_soon(checkBlacklist); - }, "blocklist-data-gfxItems", false); - - load_blocklist("test_gfxBlacklist_AllOS.xml"); -} diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Device.js b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Device.js index bc1cfb788bfc..72de19c1c7b4 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Device.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Device.js @@ -10,6 +10,12 @@ do_load_httpd_js(); var gTestserver = null; +function get_platform() { + var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"] + .getService(Components.interfaces.nsIXULRuntime); + return xulRuntime.OS; +} + function load_blocklist(file) { Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:4444/data/" + file); var blocklist = Cc["@mozilla.org/extensions/blocklist;1"]. @@ -35,11 +41,29 @@ function run_test() { gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug); // Set the vendor/device ID, etc, to match the test file. - gfxInfo.spoofVendorID(0xabcd); - gfxInfo.spoofDeviceID(0x9876); - gfxInfo.spoofDriverVersion("8.52.322.2201"); - // Windows 7 - gfxInfo.spoofOSVersion(0x60001); + switch (get_platform()) { + case "WINNT": + gfxInfo.spoofVendorID("0xabcd"); + gfxInfo.spoofDeviceID("0x9876"); + gfxInfo.spoofDriverVersion("8.52.322.2201"); + // Windows 7 + gfxInfo.spoofOSVersion(0x60001); + break; + case "Linux": + gfxInfo.spoofVendorID("0xabcd"); + gfxInfo.spoofDeviceID("0x9876"); + break; + case "Darwin": + gfxInfo.spoofVendorID("0xabcd"); + gfxInfo.spoofDeviceID("0x9876"); + gfxInfo.spoofOSVersion(0x1050); + break; + case "Android": + gfxInfo.spoofVendorID("abcd"); + gfxInfo.spoofDeviceID("aabb"); + gfxInfo.spoofDriverVersion("5"); + break; + } createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8"); startupManager(); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_DriverNew.js b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_DriverNew.js index dd9d9dfb60cc..ac07c2f71e9f 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_DriverNew.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_DriverNew.js @@ -10,6 +10,12 @@ do_load_httpd_js(); var gTestserver = null; +function get_platform() { + var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"] + .getService(Components.interfaces.nsIXULRuntime); + return xulRuntime.OS; +} + function load_blocklist(file) { Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:4444/data/" + file); var blocklist = Cc["@mozilla.org/extensions/blocklist;1"]. @@ -35,11 +41,28 @@ function run_test() { gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug); // Set the vendor/device ID, etc, to match the test file. - gfxInfo.spoofVendorID(0xabcd); - gfxInfo.spoofDeviceID(0x1234); - gfxInfo.spoofDriverVersion("8.52.322.2202"); - // Windows 7 - gfxInfo.spoofOSVersion(0x60001); + switch (get_platform()) { + case "WINNT": + gfxInfo.spoofVendorID("0xabcd"); + gfxInfo.spoofDeviceID("0x1234"); + gfxInfo.spoofDriverVersion("8.52.322.2202"); + // Windows 7 + gfxInfo.spoofOSVersion(0x60001); + break; + case "Linux": + // We don't support driver versions on Linux. + do_test_finished(); + return; + case "Darwin": + // We don't support driver versions on Darwin. + do_test_finished(); + return; + case "Android": + gfxInfo.spoofVendorID("abcd"); + gfxInfo.spoofDeviceID("wxyz"); + gfxInfo.spoofDriverVersion("6"); + break; + } createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8"); startupManager(); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverNew.js b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverNew.js index c8fe8f9ac1a2..866f275f0b8d 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverNew.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverNew.js @@ -10,6 +10,12 @@ do_load_httpd_js(); var gTestserver = null; +function get_platform() { + var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"] + .getService(Components.interfaces.nsIXULRuntime); + return xulRuntime.OS; +} + function load_blocklist(file) { Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:4444/data/" + file); var blocklist = Cc["@mozilla.org/extensions/blocklist;1"]. @@ -35,11 +41,28 @@ function run_test() { gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug); // Set the vendor/device ID, etc, to match the test file. - gfxInfo.spoofVendorID(0xdcdc); - gfxInfo.spoofDeviceID(0x1234); - gfxInfo.spoofDriverVersion("8.52.322.1112"); - // Windows 7 - gfxInfo.spoofOSVersion(0x60001); + switch (get_platform()) { + case "WINNT": + gfxInfo.spoofVendorID("0xdcdc"); + gfxInfo.spoofDeviceID("0x1234"); + gfxInfo.spoofDriverVersion("8.52.322.1112"); + // Windows 7 + gfxInfo.spoofOSVersion(0x60001); + break; + case "Linux": + // We don't support driver versions on Linux. + do_test_finished(); + return; + case "Darwin": + // We don't support driver versions on Darwin. + do_test_finished(); + return; + case "Android": + gfxInfo.spoofVendorID("dcdc"); + gfxInfo.spoofDeviceID("uiop"); + gfxInfo.spoofDriverVersion("6"); + break; + } createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8"); startupManager(); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverOld.js b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverOld.js index 5126ff339eb5..9ef4984d7063 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverOld.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverOld.js @@ -10,6 +10,12 @@ do_load_httpd_js(); var gTestserver = null; +function get_platform() { + var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"] + .getService(Components.interfaces.nsIXULRuntime); + return xulRuntime.OS; +} + function load_blocklist(file) { Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:4444/data/" + file); var blocklist = Cc["@mozilla.org/extensions/blocklist;1"]. @@ -35,11 +41,28 @@ function run_test() { gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug); // Set the vendor/device ID, etc, to match the test file. - gfxInfo.spoofVendorID(0xdcdc); - gfxInfo.spoofDeviceID(0x1234); - gfxInfo.spoofDriverVersion("8.52.322.1110"); - // Windows 7 - gfxInfo.spoofOSVersion(0x60001); + switch (get_platform()) { + case "WINNT": + gfxInfo.spoofVendorID("0xdcdc"); + gfxInfo.spoofDeviceID("0x1234"); + gfxInfo.spoofDriverVersion("8.52.322.1110"); + // Windows 7 + gfxInfo.spoofOSVersion(0x60001); + break; + case "Linux": + // We don't support driver versions on Linux. + do_test_finished(); + return; + case "Darwin": + // We don't support driver versions on Darwin. + do_test_finished(); + return; + case "Android": + gfxInfo.spoofVendorID("dcdc"); + gfxInfo.spoofDeviceID("uiop"); + gfxInfo.spoofDriverVersion("4"); + break; + } createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8"); startupManager(); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_OK.js b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_OK.js index 8fe84313d589..325e37cad08d 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_OK.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_OK.js @@ -10,6 +10,12 @@ do_load_httpd_js(); var gTestserver = null; +function get_platform() { + var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"] + .getService(Components.interfaces.nsIXULRuntime); + return xulRuntime.OS; +} + function load_blocklist(file) { Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:4444/data/" + file); var blocklist = Cc["@mozilla.org/extensions/blocklist;1"]. @@ -35,11 +41,28 @@ function run_test() { gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug); // Set the vendor/device ID, etc, to match the test file. - gfxInfo.spoofVendorID(0xdcdc); - gfxInfo.spoofDeviceID(0x1234); - gfxInfo.spoofDriverVersion("8.52.322.1111"); - // Windows 7 - gfxInfo.spoofOSVersion(0x60001); + switch (get_platform()) { + case "WINNT": + gfxInfo.spoofVendorID("0xdcdc"); + gfxInfo.spoofDeviceID("0x1234"); + gfxInfo.spoofDriverVersion("8.52.322.1111"); + // Windows 7 + gfxInfo.spoofOSVersion(0x60001); + break; + case "Linux": + // We don't support driver versions on Linux. + do_test_finished(); + return; + case "Darwin": + // We don't support driver versions on Darwin. + do_test_finished(); + return; + case "Android": + gfxInfo.spoofVendorID("dcdc"); + gfxInfo.spoofDeviceID("uiop"); + gfxInfo.spoofDriverVersion("5"); + break; + } createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8"); startupManager(); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_DriverOld.js b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_DriverOld.js index 90f77bc7c0c9..f3dc47303a18 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_DriverOld.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_DriverOld.js @@ -10,6 +10,12 @@ do_load_httpd_js(); var gTestserver = null; +function get_platform() { + var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"] + .getService(Components.interfaces.nsIXULRuntime); + return xulRuntime.OS; +} + function load_blocklist(file) { Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:4444/data/" + file); var blocklist = Cc["@mozilla.org/extensions/blocklist;1"]. @@ -35,11 +41,28 @@ function run_test() { gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug); // Set the vendor/device ID, etc, to match the test file. - gfxInfo.spoofVendorID(0xabab); - gfxInfo.spoofDeviceID(0x1234); - gfxInfo.spoofDriverVersion("8.52.322.2201"); - // Windows 7 - gfxInfo.spoofOSVersion(0x60001); + switch (get_platform()) { + case "WINNT": + gfxInfo.spoofVendorID("0xabab"); + gfxInfo.spoofDeviceID("0x1234"); + gfxInfo.spoofDriverVersion("8.52.322.2201"); + // Windows 7 + gfxInfo.spoofOSVersion(0x60001); + break; + case "Linux": + // We don't support driver versions on Linux. + do_test_finished(); + return; + case "Darwin": + // We don't support driver versions on Darwin. + do_test_finished(); + return; + case "Android": + gfxInfo.spoofVendorID("abab"); + gfxInfo.spoofDeviceID("ghjk"); + gfxInfo.spoofDriverVersion("6"); + break; + } createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8"); startupManager(); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_OK.js b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_OK.js index af9d8b9a30f4..79953e35ca3a 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_OK.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_OK.js @@ -10,6 +10,12 @@ do_load_httpd_js(); var gTestserver = null; +function get_platform() { + var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"] + .getService(Components.interfaces.nsIXULRuntime); + return xulRuntime.OS; +} + function load_blocklist(file) { Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:4444/data/" + file); var blocklist = Cc["@mozilla.org/extensions/blocklist;1"]. @@ -35,11 +41,28 @@ function run_test() { gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug); // Set the vendor/device ID, etc, to match the test file. - gfxInfo.spoofVendorID(0xabab); - gfxInfo.spoofDeviceID(0x1234); - gfxInfo.spoofDriverVersion("8.52.322.2202"); - // Windows 7 - gfxInfo.spoofOSVersion(0x60001); + switch (get_platform()) { + case "WINNT": + gfxInfo.spoofVendorID("0xabab"); + gfxInfo.spoofDeviceID("0x1234"); + gfxInfo.spoofDriverVersion("8.52.322.2202"); + // Windows 7 + gfxInfo.spoofOSVersion(0x60001); + break; + case "Linux": + // We don't support driver versions on Linux. + do_test_finished(); + return; + case "Darwin": + // We don't support driver versions on Darwin. + do_test_finished(); + return; + case "Android": + gfxInfo.spoofVendorID("abab"); + gfxInfo.spoofDeviceID("ghjk"); + gfxInfo.spoofDriverVersion("7"); + break; + } createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8"); startupManager(); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OK.js b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OK.js index f4e12cf762f1..18fa7286c478 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OK.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OK.js @@ -10,6 +10,12 @@ do_load_httpd_js(); var gTestserver = null; +function get_platform() { + var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"] + .getService(Components.interfaces.nsIXULRuntime); + return xulRuntime.OS; +} + function load_blocklist(file) { Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:4444/data/" + file); var blocklist = Cc["@mozilla.org/extensions/blocklist;1"]. @@ -35,11 +41,29 @@ function run_test() { gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug); // Set the vendor/device ID, etc, to match the test file. - gfxInfo.spoofVendorID(0xabcd); - gfxInfo.spoofDeviceID(0x1234); - gfxInfo.spoofDriverVersion("8.52.322.2201"); - // Windows 7 - gfxInfo.spoofOSVersion(0x60001); + switch (get_platform()) { + case "WINNT": + gfxInfo.spoofVendorID("0xabcd"); + gfxInfo.spoofDeviceID("0x1234"); + gfxInfo.spoofDriverVersion("8.52.322.2201"); + // Windows 7 + gfxInfo.spoofOSVersion(0x60001); + break; + case "Linux": + gfxInfo.spoofVendorID("0xabcd"); + gfxInfo.spoofDeviceID("0x1234"); + break; + case "Darwin": + gfxInfo.spoofVendorID("0xabcd"); + gfxInfo.spoofDeviceID("0x1234"); + gfxInfo.spoofOSVersion(0x1050); + break; + case "Android": + gfxInfo.spoofVendorID("abcd"); + gfxInfo.spoofDeviceID("asdf"); + gfxInfo.spoofDriverVersion("5"); + break; + } createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8"); startupManager(); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OS.js b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OS.js index d5294fc2f7b2..0f3101aa2b67 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OS.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OS.js @@ -10,6 +10,12 @@ do_load_httpd_js(); var gTestserver = null; +function get_platform() { + var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"] + .getService(Components.interfaces.nsIXULRuntime); + return xulRuntime.OS; +} + function load_blocklist(file) { Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:4444/data/" + file); var blocklist = Cc["@mozilla.org/extensions/blocklist;1"]. @@ -35,11 +41,30 @@ function run_test() { gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug); // Set the vendor/device ID, etc, to match the test file. - gfxInfo.spoofVendorID(0xabcd); - gfxInfo.spoofDeviceID(0x1234); - gfxInfo.spoofDriverVersion("8.52.322.2201"); - // Windows Vista - gfxInfo.spoofOSVersion(0x60000); + switch (get_platform()) { + case "WINNT": + gfxInfo.spoofVendorID("0xabcd"); + gfxInfo.spoofDeviceID("0x1234"); + gfxInfo.spoofDriverVersion("8.52.322.2201"); + // Windows Vista + gfxInfo.spoofOSVersion(0x60000); + break; + case "Linux": + // We don't have any OS versions on Linux, just "Linux". + do_test_finished(); + return; + case "Darwin": + gfxInfo.spoofVendorID("0xabcd"); + gfxInfo.spoofDeviceID("0x1234"); + // Snow Leopard + gfxInfo.spoofOSVersion(0x1060); + break; + case "Android": + // On Android, the driver version is used as the OS version (because + // there's so many of them). + do_test_finished(); + return; + } createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8"); startupManager(); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Vendor.js b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Vendor.js index b54224c55592..ebf5d0f3dc0a 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Vendor.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Vendor.js @@ -10,6 +10,12 @@ do_load_httpd_js(); var gTestserver = null; +function get_platform() { + var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"] + .getService(Components.interfaces.nsIXULRuntime); + return xulRuntime.OS; +} + function load_blocklist(file) { Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:4444/data/" + file); var blocklist = Cc["@mozilla.org/extensions/blocklist;1"]. @@ -35,11 +41,29 @@ function run_test() { gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug); // Set the vendor/device ID, etc, to match the test file. - gfxInfo.spoofVendorID(0xdcba); - gfxInfo.spoofDeviceID(0x1234); - gfxInfo.spoofDriverVersion("8.52.322.2201"); - // Windows 7 - gfxInfo.spoofOSVersion(0x60001); + switch (get_platform()) { + case "WINNT": + gfxInfo.spoofVendorID("0xdcba"); + gfxInfo.spoofDeviceID("0x1234"); + gfxInfo.spoofDriverVersion("8.52.322.2201"); + // Windows 7 + gfxInfo.spoofOSVersion(0x60001); + break; + case "Linux": + gfxInfo.spoofVendorID("0xdcba"); + gfxInfo.spoofDeviceID("0x1234"); + break; + case "Darwin": + gfxInfo.spoofVendorID("0xdcba"); + gfxInfo.spoofDeviceID("0x1234"); + gfxInfo.spoofOSVersion(0x1050); + break; + case "Android": + gfxInfo.spoofVendorID("dcba"); + gfxInfo.spoofDeviceID("asdf"); + gfxInfo.spoofDriverVersion("5"); + break; + } createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8"); startupManager(); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_prefs.js b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_prefs.js index 1ef872330ccc..5c6231ba7ee8 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_prefs.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_prefs.js @@ -10,6 +10,12 @@ do_load_httpd_js(); var gTestserver = null; +function get_platform() { + var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"] + .getService(Components.interfaces.nsIXULRuntime); + return xulRuntime.OS; +} + function load_blocklist(file) { Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:4444/data/" + file); var blocklist = Cc["@mozilla.org/extensions/blocklist;1"]. @@ -35,11 +41,29 @@ function run_test() { gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug); // Set the vendor/device ID, etc, to match the test file. - gfxInfo.spoofVendorID(0xabcd); - gfxInfo.spoofDeviceID(0x1234); - gfxInfo.spoofDriverVersion("8.52.322.2201"); - // Windows 7 - gfxInfo.spoofOSVersion(0x60001); + switch (get_platform()) { + case "WINNT": + gfxInfo.spoofVendorID("0xabcd"); + gfxInfo.spoofDeviceID("0x1234"); + gfxInfo.spoofDriverVersion("8.52.322.2201"); + // Windows 7 + gfxInfo.spoofOSVersion(0x60001); + break; + case "Linux": + gfxInfo.spoofVendorID("0xabcd"); + gfxInfo.spoofDeviceID("0x1234"); + break; + case "Darwin": + gfxInfo.spoofVendorID("0xabcd"); + gfxInfo.spoofDeviceID("0x1234"); + gfxInfo.spoofOSVersion(0x1050); + break; + case "Android": + gfxInfo.spoofVendorID("abcd"); + gfxInfo.spoofDeviceID("asdf"); + gfxInfo.spoofDriverVersion("5"); + break; + } createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8"); startupManager(); diff --git a/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini b/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini index 5b135a946a59..dc482dde6b74 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini +++ b/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini @@ -150,8 +150,6 @@ skip-if = os == "android" [test_fuel.js] [test_general.js] [test_getresource.js] -[test_gfxBlacklist_AllOS1.js] -[test_gfxBlacklist_AllOS2.js] [test_gfxBlacklist_Device.js] [test_gfxBlacklist_DriverNew.js] [test_gfxBlacklist_Equal_DriverNew.js] diff --git a/widget/public/nsIGfxInfoDebug.idl b/widget/public/nsIGfxInfoDebug.idl index 878be14d528f..9468f5b22db6 100644 --- a/widget/public/nsIGfxInfoDebug.idl +++ b/widget/public/nsIGfxInfoDebug.idl @@ -39,11 +39,11 @@ /* NOTE: this interface is only implemented in debug builds */ -[scriptable, uuid(0c19c88a-9ef1-4bb4-b0a2-86ab768e8bd6)] +[scriptable, uuid(ca7b0bc7-c67c-4b79-8270-ed7ba002af08)] interface nsIGfxInfoDebug : nsISupports { - void spoofVendorID(in unsigned long aVendorID); - void spoofDeviceID(in unsigned long aDeviceID); + void spoofVendorID(in DOMString aVendorID); + void spoofDeviceID(in DOMString aDeviceID); void spoofDriverVersion(in DOMString aDriverVersion); diff --git a/widget/src/android/GfxInfo.cpp b/widget/src/android/GfxInfo.cpp index 4cbed96923f7..31b051c63af3 100644 --- a/widget/src/android/GfxInfo.cpp +++ b/widget/src/android/GfxInfo.cpp @@ -51,6 +51,10 @@ using namespace mozilla::widget; +#ifdef DEBUG +NS_IMPL_ISUPPORTS_INHERITED1(GfxInfo, GfxInfoBase, nsIGfxInfoDebug) +#endif + /* GetD2DEnabled and GetDwriteEnabled shouldn't be called until after gfxPlatform initialization * has occurred because they depend on it for information. (See bug 591561) */ nsresult @@ -329,3 +333,36 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, return GfxInfoBase::GetFeatureStatusImpl(aFeature, aStatus, aSuggestedDriverVersion, aDriverInfo, &os); } + +#ifdef DEBUG + +// Implement nsIGfxInfoDebug + +/* void spoofVendorID (in DOMString aVendorID); */ +NS_IMETHODIMP GfxInfo::SpoofVendorID(const nsAString & aVendorID) +{ + mAdapterVendorID = aVendorID; + return NS_OK; +} + +/* void spoofDeviceID (in unsigned long aDeviceID); */ +NS_IMETHODIMP GfxInfo::SpoofDeviceID(const nsAString & aDeviceID) +{ + mAdapterDeviceID = aDeviceID; + return NS_OK; +} + +/* void spoofDriverVersion (in DOMString aDriverVersion); */ +NS_IMETHODIMP GfxInfo::SpoofDriverVersion(const nsAString & aDriverVersion) +{ + mDriverVersion = aDriverVersion; + return NS_OK; +} + +/* void spoofOSVersion (in unsigned long aVersion); */ +NS_IMETHODIMP GfxInfo::SpoofOSVersion(PRUint32 aVersion) +{ + return NS_OK; +} + +#endif diff --git a/widget/src/android/GfxInfo.h b/widget/src/android/GfxInfo.h index abfe5994f622..f7302a7a2854 100644 --- a/widget/src/android/GfxInfo.h +++ b/widget/src/android/GfxInfo.h @@ -79,6 +79,11 @@ public: virtual nsresult Init(); +#ifdef DEBUG + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_NSIGFXINFODEBUG +#endif + protected: virtual nsresult GetFeatureStatusImpl(PRInt32 aFeature, diff --git a/widget/src/cocoa/GfxInfo.h b/widget/src/cocoa/GfxInfo.h index f112a2a8f3a6..c6a280a896e7 100644 --- a/widget/src/cocoa/GfxInfo.h +++ b/widget/src/cocoa/GfxInfo.h @@ -74,12 +74,18 @@ public: NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverVersion2(nsAString & aAdapterDriverVersion); NS_SCRIPTABLE NS_IMETHOD GetAdapterDriverDate2(nsAString & aAdapterDriverDate); NS_SCRIPTABLE NS_IMETHOD GetIsGPU2Active(bool *aIsGPU2Active); + using GfxInfoBase::GetFeatureStatus; using GfxInfoBase::GetFeatureSuggestedDriverVersion; using GfxInfoBase::GetWebGLParameter; virtual nsresult Init(); +#ifdef DEBUG + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_NSIGFXINFODEBUG +#endif + protected: virtual nsresult GetFeatureStatusImpl(PRInt32 aFeature, diff --git a/widget/src/cocoa/GfxInfo.mm b/widget/src/cocoa/GfxInfo.mm index 45cb8515612b..73d579e23e24 100644 --- a/widget/src/cocoa/GfxInfo.mm +++ b/widget/src/cocoa/GfxInfo.mm @@ -67,10 +67,28 @@ using namespace mozilla; using namespace mozilla::widget; +#ifdef DEBUG +NS_IMPL_ISUPPORTS_INHERITED1(GfxInfo, GfxInfoBase, nsIGfxInfoDebug) +#endif + GfxInfo::GfxInfo() { } +static OperatingSystem +OSXVersionToOperatingSystem(PRUint32 aOSXVersion) +{ + switch (aOSXVersion & MAC_OS_X_VERSION_MAJOR_MASK) { + case MAC_OS_X_VERSION_10_5_HEX: + return DRIVER_OS_OS_X_10_5; + case MAC_OS_X_VERSION_10_6_HEX: + return DRIVER_OS_OS_X_10_6; + case MAC_OS_X_VERSION_10_7_HEX: + return DRIVER_OS_OS_X_10_7; + } + + return DRIVER_OS_UNKNOWN; +} // The following three functions are derived from Chromium code static CFTypeRef SearchPortForProperty(io_registry_entry_t dspPort, CFStringRef propertyName) @@ -158,6 +176,8 @@ GfxInfo::Init() AddCrashReportAnnotations(); + mOSXVersion = nsToolkit::OSXVersion(); + return rv; } @@ -364,21 +384,6 @@ GfxInfo::GetGfxDriverInfo() return *mDriverInfo; } -static OperatingSystem -OSXVersionToOperatingSystem(PRUint32 aOSXVersion) -{ - switch (aOSXVersion & MAC_OS_X_VERSION_MAJOR_MASK) { - case MAC_OS_X_VERSION_10_5_HEX: - return DRIVER_OS_OS_X_10_5; - case MAC_OS_X_VERSION_10_6_HEX: - return DRIVER_OS_OS_X_10_6; - case MAC_OS_X_VERSION_10_7_HEX: - return DRIVER_OS_OS_X_10_7; - } - - return DRIVER_OS_UNKNOWN; -} - nsresult GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, PRInt32* aStatus, @@ -389,7 +394,7 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, NS_ENSURE_ARG_POINTER(aStatus); aSuggestedDriverVersion.SetIsVoid(true); *aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN; - OperatingSystem os = OSXVersionToOperatingSystem(nsToolkit::OSXVersion()); + OperatingSystem os = OSXVersionToOperatingSystem(mOSXVersion); if (aOS) *aOS = os; @@ -456,3 +461,37 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, return GfxInfoBase::GetFeatureStatusImpl(aFeature, aStatus, aSuggestedDriverVersion, aDriverInfo, &os); } + +#ifdef DEBUG + +// Implement nsIGfxInfoDebug + +/* void spoofVendorID (in DOMString aVendorID); */ +NS_IMETHODIMP GfxInfo::SpoofVendorID(const nsAString & aVendorID) +{ + mAdapterVendorID = aVendorID; + return NS_OK; +} + +/* void spoofDeviceID (in unsigned long aDeviceID); */ +NS_IMETHODIMP GfxInfo::SpoofDeviceID(const nsAString & aDeviceID) +{ + mAdapterDeviceID = aDeviceID; + return NS_OK; +} + +/* void spoofDriverVersion (in DOMString aDriverVersion); */ +NS_IMETHODIMP GfxInfo::SpoofDriverVersion(const nsAString & aDriverVersion) +{ + mDriverVersion = aDriverVersion; + return NS_OK; +} + +/* void spoofOSVersion (in unsigned long aVersion); */ +NS_IMETHODIMP GfxInfo::SpoofOSVersion(PRUint32 aVersion) +{ + mOSXVersion = aVersion; + return NS_OK; +} + +#endif diff --git a/widget/src/windows/GfxInfo.cpp b/widget/src/windows/GfxInfo.cpp index 66383f2976f0..8adc70761968 100644 --- a/widget/src/windows/GfxInfo.cpp +++ b/widget/src/windows/GfxInfo.cpp @@ -1031,19 +1031,17 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature, // Implement nsIGfxInfoDebug -/* void spoofVendorID (in unsigned long aVendorID); */ -NS_IMETHODIMP GfxInfo::SpoofVendorID(PRUint32 aVendorID) +/* void spoofVendorID (in DOMString aVendorID); */ +NS_IMETHODIMP GfxInfo::SpoofVendorID(const nsAString & aVendorID) { - mAdapterVendorID.Truncate(0); - mAdapterVendorID.AppendPrintf("0x%04x", aVendorID); + mAdapterVendorID = aVendorID; return NS_OK; } /* void spoofDeviceID (in unsigned long aDeviceID); */ -NS_IMETHODIMP GfxInfo::SpoofDeviceID(PRUint32 aDeviceID) +NS_IMETHODIMP GfxInfo::SpoofDeviceID(const nsAString & aDeviceID) { - mAdapterDeviceID.Truncate(0); - mAdapterDeviceID.AppendPrintf("0x%04x", aDeviceID); + mAdapterDeviceID = aDeviceID; return NS_OK; } diff --git a/widget/src/windows/GfxInfo.h b/widget/src/windows/GfxInfo.h index a75604ef88f8..8ccd8747dfa0 100644 --- a/widget/src/windows/GfxInfo.h +++ b/widget/src/windows/GfxInfo.h @@ -41,15 +41,11 @@ #define __mozilla_widget_GfxInfo_h__ #include "GfxInfoBase.h" -#include "nsIGfxInfoDebug.h" namespace mozilla { namespace widget { class GfxInfo : public GfxInfoBase -#ifdef DEBUG - , public nsIGfxInfoDebug -#endif { public: GfxInfo(); @@ -80,13 +76,13 @@ public: using GfxInfoBase::GetFeatureSuggestedDriverVersion; using GfxInfoBase::GetWebGLParameter; + virtual nsresult Init(); + #ifdef DEBUG NS_DECL_ISUPPORTS_INHERITED NS_DECL_NSIGFXINFODEBUG #endif - virtual nsresult Init(); - protected: virtual nsresult GetFeatureStatusImpl(PRInt32 aFeature, diff --git a/widget/src/xpwidgets/GfxInfoBase.h b/widget/src/xpwidgets/GfxInfoBase.h index bc4bcdcfccd2..1fb38aa7c332 100644 --- a/widget/src/xpwidgets/GfxInfoBase.h +++ b/widget/src/xpwidgets/GfxInfoBase.h @@ -48,6 +48,7 @@ #include "nsTArray.h" #include "nsString.h" #include "GfxInfoCollector.h" +#include "nsIGfxInfoDebug.h" namespace mozilla { namespace widget { @@ -55,6 +56,9 @@ namespace widget { class GfxInfoBase : public nsIGfxInfo, public nsIObserver, public nsSupportsWeakReference +#ifdef DEBUG + , public nsIGfxInfoDebug +#endif { public: GfxInfoBase(); diff --git a/widget/src/xpwidgets/GfxInfoX11.cpp b/widget/src/xpwidgets/GfxInfoX11.cpp index 51f537a09e3b..b02987414185 100644 --- a/widget/src/xpwidgets/GfxInfoX11.cpp +++ b/widget/src/xpwidgets/GfxInfoX11.cpp @@ -54,6 +54,10 @@ namespace mozilla { namespace widget { +#ifdef DEBUG +NS_IMPL_ISUPPORTS_INHERITED1(GfxInfo, GfxInfoBase, nsIGfxInfoDebug) +#endif + // these global variables will be set when firing the glxtest process int glxtest_pipe = 0; pid_t glxtest_pid = 0; @@ -481,6 +485,40 @@ GfxInfo::GetIsGPU2Active(bool* aIsGPU2Active) return NS_ERROR_FAILURE; } +#ifdef DEBUG + +// Implement nsIGfxInfoDebug +// We don't support spoofing anything on Linux + +/* void spoofVendorID (in DOMString aVendorID); */ +NS_IMETHODIMP GfxInfo::SpoofVendorID(const nsAString & aVendorID) +{ + CopyUTF16toUTF8(aVendorID, mVendor); + return NS_OK; +} + +/* void spoofDeviceID (in unsigned long aDeviceID); */ +NS_IMETHODIMP GfxInfo::SpoofDeviceID(const nsAString & aDeviceID) +{ + CopyUTF16toUTF8(aDeviceID, mRenderer); + return NS_OK; +} + +/* void spoofDriverVersion (in DOMString aDriverVersion); */ +NS_IMETHODIMP GfxInfo::SpoofDriverVersion(const nsAString & aDriverVersion) +{ + CopyUTF16toUTF8(aDriverVersion, mVersion); + return NS_OK; +} + +/* void spoofOSVersion (in unsigned long aVersion); */ +NS_IMETHODIMP GfxInfo::SpoofOSVersion(PRUint32 aVersion) +{ + // We don't support OS versioning on Linux. There's just "Linux". + return NS_OK; +} + +#endif } // end namespace widget } // end namespace mozilla diff --git a/widget/src/xpwidgets/GfxInfoX11.h b/widget/src/xpwidgets/GfxInfoX11.h index a7212eddfeca..c89336a2bb24 100644 --- a/widget/src/xpwidgets/GfxInfoX11.h +++ b/widget/src/xpwidgets/GfxInfoX11.h @@ -79,6 +79,11 @@ public: NS_IMETHOD_(void) GetData(); +#ifdef DEBUG + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_NSIGFXINFODEBUG +#endif + protected: virtual nsresult GetFeatureStatusImpl(PRInt32 aFeature, From b3569be7d98440f311ef821fff364e85d87f3c3e Mon Sep 17 00:00:00 2001 From: Jason Voll Date: Wed, 14 Dec 2011 21:37:11 -0800 Subject: [PATCH 09/26] Bug 710418 - Browser content provider can't handle null projections in query. r=blassey, a=rnewman --- mobile/android/base/db/BrowserProvider.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mobile/android/base/db/BrowserProvider.java b/mobile/android/base/db/BrowserProvider.java index 45baf23162aa..b3a3cb2d47c5 100644 --- a/mobile/android/base/db/BrowserProvider.java +++ b/mobile/android/base/db/BrowserProvider.java @@ -20,6 +20,7 @@ * * Contributor(s): * Lucas Rocha + * Jason Voll * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -247,6 +248,7 @@ public class BrowserProvider extends ContentProvider { } private static boolean hasImagesInProjection(String[] projection) { + if (projection == null) return true; for (int i = 0; i < projection.length; ++i) { if (projection[i].equals(Images.FAVICON) || projection[i].equals(Images.THUMBNAIL)) From 34ae9a22e560ebdff5f68e682f6d9e3730e706c0 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Thu, 15 Dec 2011 06:40:20 +0100 Subject: [PATCH 10/26] Bug 709721 - Move video and audio libraries in a gkmedias library on Windows. r=khuey --- browser/installer/package-manifest.in | 1 + config/system-headers | 11 +++ js/src/config/system-headers | 11 +++ layout/Makefile.in | 1 + layout/build/Makefile.in | 22 ------ layout/media/Makefile.in | 93 ++++++++++++++++++++++++ layout/media/symbols.def | 79 ++++++++++++++++++++ media/libnestegg/src/Makefile.in | 3 + media/libogg/src/Makefile.in | 3 + media/libsydneyaudio/src/Makefile.in | 3 + media/libtheora/lib/Makefile.in | 3 + media/libvorbis/lib/Makefile.in | 3 + media/libvpx/Makefile.in | 3 + mobile/xul/installer/package-manifest.in | 1 + toolkit/library/Makefile.in | 2 + xpcom/stub/Makefile.in | 6 ++ 16 files changed, 223 insertions(+), 22 deletions(-) create mode 100644 layout/media/Makefile.in create mode 100644 layout/media/symbols.def diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index 7a5ba918e48b..50798daa3d00 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -58,6 +58,7 @@ @BINPATH@/@MOZ_CHILD_PROCESS_NAME@ #endif #ifdef XP_WIN32 +@BINPATH@/@DLL_PREFIX@gkmedias@DLL_SUFFIX@ #if _MSC_VER == 1400 @BINPATH@/Microsoft.VC80.CRT.manifest @BINPATH@/msvcm80.dll diff --git a/config/system-headers b/config/system-headers index 9fbe553973c9..8cc86c426629 100644 --- a/config/system-headers +++ b/config/system-headers @@ -1037,3 +1037,14 @@ shareuiinterface.h vpx/vpx_decoder.h vpx/vp8dx.h #endif +#ifdef XP_WIN +vpx/vpx_decoder.h +vpx/vp8dx.h +sydneyaudio/sydney_audio.h +vorbis/codec.h +theora/theoradec.h +tremor/ivorbiscodec.h +ogg/ogg.h +ogg/os_types.h +nestegg/nestegg.h +#endif diff --git a/js/src/config/system-headers b/js/src/config/system-headers index 9fbe553973c9..8cc86c426629 100644 --- a/js/src/config/system-headers +++ b/js/src/config/system-headers @@ -1037,3 +1037,14 @@ shareuiinterface.h vpx/vpx_decoder.h vpx/vp8dx.h #endif +#ifdef XP_WIN +vpx/vpx_decoder.h +vpx/vp8dx.h +sydneyaudio/sydney_audio.h +vorbis/codec.h +theora/theoradec.h +tremor/ivorbiscodec.h +ogg/ogg.h +ogg/os_types.h +nestegg/nestegg.h +#endif diff --git a/layout/Makefile.in b/layout/Makefile.in index f8fc5554f7cb..c7f65493ecf8 100644 --- a/layout/Makefile.in +++ b/layout/Makefile.in @@ -67,6 +67,7 @@ PARALLEL_DIRS += inspector/tests inspector/tests/chrome endif DIRS += build +DIRS += media ifdef ENABLE_TESTS PARALLEL_DIRS += \ diff --git a/layout/build/Makefile.in b/layout/build/Makefile.in index 364cbfa20844..f38de7c623cb 100644 --- a/layout/build/Makefile.in +++ b/layout/build/Makefile.in @@ -150,20 +150,6 @@ ifdef MOZ_B2G_RIL #{ SHARED_LIBRARY_LIBS += $(DEPTH)/dom/system/b2g/$(LIB_PREFIX)domsystemb2g_s.$(LIB_SUFFIX) endif #} -ifdef MOZ_VORBIS -SHARED_LIBRARY_LIBS += \ - $(DEPTH)/media/libvorbis/lib/$(LIB_PREFIX)vorbis.$(LIB_SUFFIX) \ - $(DEPTH)/media/libogg/src/$(LIB_PREFIX)ogg.$(LIB_SUFFIX) \ - $(NULL) -endif - -ifdef MOZ_TREMOR -SHARED_LIBRARY_LIBS += \ - $(DEPTH)/media/libtremor/lib/$(LIB_PREFIX)tremor.$(LIB_SUFFIX) \ - $(DEPTH)/media/libogg/src/$(LIB_PREFIX)ogg.$(LIB_SUFFIX) \ - $(NULL) -endif - ifdef MOZ_MEDIA SHARED_LIBRARY_LIBS += \ $(DEPTH)/content/media/$(LIB_PREFIX)gkconmedia_s.$(LIB_SUFFIX) \ @@ -172,7 +158,6 @@ endif ifdef MOZ_OGG SHARED_LIBRARY_LIBS += \ - $(DEPTH)/media/libtheora/lib/$(LIB_PREFIX)theora.$(LIB_SUFFIX) \ $(DEPTH)/content/media/ogg/$(LIB_PREFIX)gkconogg_s.$(LIB_SUFFIX) \ $(NULL) endif @@ -186,11 +171,7 @@ endif ifdef MOZ_WEBM SHARED_LIBRARY_LIBS += \ $(DEPTH)/content/media/webm/$(LIB_PREFIX)gkconwebm_s.$(LIB_SUFFIX) \ - $(DEPTH)/media/libnestegg/src/$(LIB_PREFIX)nestegg.$(LIB_SUFFIX) \ $(NULL) -ifndef MOZ_NATIVE_LIBVPX -SHARED_LIBRARY_LIBS += $(DEPTH)/media/libvpx/$(LIB_PREFIX)vpx.$(LIB_SUFFIX) -endif endif ifdef MOZ_WAVE @@ -200,9 +181,6 @@ SHARED_LIBRARY_LIBS += \ endif ifdef MOZ_SYDNEYAUDIO -SHARED_LIBRARY_LIBS += \ - $(DEPTH)/media/libsydneyaudio/src/$(LIB_PREFIX)sydneyaudio.$(LIB_SUFFIX) \ - $(NULL) LOCAL_INCLUDES += -I$(DEPTH)/content/html/content/src endif diff --git a/layout/media/Makefile.in b/layout/media/Makefile.in new file mode 100644 index 000000000000..03e3385635bc --- /dev/null +++ b/layout/media/Makefile.in @@ -0,0 +1,93 @@ +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is +# Mozilla Foundation. +# Portions created by the Initial Developer are Copyright (C) 2011 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +DEPTH = ../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +MODULE = layout +LIBRARY_NAME = gkmedias +EXPORT_LIBRARY = $(DIST)/lib +ifeq (WINNT,$(OS_TARGET)) +FORCE_SHARED_LIB = 1 +endif + +SHARED_LIBRARY_LIBS = + +ifdef MOZ_VORBIS +SHARED_LIBRARY_LIBS += \ + $(DEPTH)/media/libvorbis/lib/$(LIB_PREFIX)vorbis.$(LIB_SUFFIX) \ + $(DEPTH)/media/libogg/src/$(LIB_PREFIX)ogg.$(LIB_SUFFIX) \ + $(NULL) +endif + +ifdef MOZ_TREMOR +SHARED_LIBRARY_LIBS += \ + $(DEPTH)/media/libtremor/lib/$(LIB_PREFIX)tremor.$(LIB_SUFFIX) \ + $(DEPTH)/media/libogg/src/$(LIB_PREFIX)ogg.$(LIB_SUFFIX) \ + $(NULL) +endif + +ifdef MOZ_OGG +SHARED_LIBRARY_LIBS += \ + $(DEPTH)/media/libtheora/lib/$(LIB_PREFIX)theora.$(LIB_SUFFIX) \ + $(NULL) +endif + +ifdef MOZ_WEBM +SHARED_LIBRARY_LIBS += \ + $(DEPTH)/media/libnestegg/src/$(LIB_PREFIX)nestegg.$(LIB_SUFFIX) \ + $(NULL) +ifndef MOZ_NATIVE_LIBVPX +SHARED_LIBRARY_LIBS += $(DEPTH)/media/libvpx/$(LIB_PREFIX)vpx.$(LIB_SUFFIX) +endif +endif + +ifdef MOZ_SYDNEYAUDIO +SHARED_LIBRARY_LIBS += \ + $(DEPTH)/media/libsydneyaudio/src/$(LIB_PREFIX)sydneyaudio.$(LIB_SUFFIX) \ + $(NULL) +endif + +ifeq (WINNT,$(OS_TARGET)) +DEFFILE = $(srcdir)/symbols.def +endif + +include $(topsrcdir)/config/rules.mk diff --git a/layout/media/symbols.def b/layout/media/symbols.def new file mode 100644 index 000000000000..8c148dec1923 --- /dev/null +++ b/layout/media/symbols.def @@ -0,0 +1,79 @@ +LIBRARY gkmedias.dll +EXPORTS +nestegg_destroy +nestegg_duration +nestegg_free_packet +nestegg_init +nestegg_packet_count +nestegg_packet_data +nestegg_packet_track +nestegg_packet_tstamp +nestegg_read_packet +nestegg_track_audio_params +nestegg_track_codec_data +nestegg_track_codec_data_count +nestegg_track_codec_id +nestegg_track_count +nestegg_track_seek +nestegg_track_type +nestegg_track_video_params +nestegg_tstamp_scale +ogg_page_bos +ogg_page_granulepos +ogg_page_serialno +ogg_stream_check +ogg_stream_clear +ogg_stream_init +ogg_stream_packetout +ogg_stream_pagein +ogg_stream_reset +ogg_sync_buffer +ogg_sync_clear +ogg_sync_init +ogg_sync_pageseek +ogg_sync_reset +ogg_sync_wrote +sa_stream_create_pcm +sa_stream_destroy +sa_stream_drain +sa_stream_get_min_write +sa_stream_get_position +sa_stream_get_write_size +sa_stream_open +sa_stream_pause +sa_stream_resume +sa_stream_write +th_comment_clear +th_comment_init +th_decode_alloc +th_decode_free +th_decode_headerin +th_decode_packetin +th_decode_ycbcr_out +th_granule_frame +th_info_clear +th_info_init +th_packet_isheader +th_packet_iskeyframe +th_setup_free +vorbis_block_clear +vorbis_block_init +vorbis_comment_clear +vorbis_comment_init +vorbis_dsp_clear +vorbis_info_clear +vorbis_info_init +vorbis_packet_blocksize +vorbis_synthesis +vorbis_synthesis_blockin +vorbis_synthesis_headerin +vorbis_synthesis_init +vorbis_synthesis_pcmout +vorbis_synthesis_read +vorbis_synthesis_restart +vpx_codec_dec_init_ver +vpx_codec_decode +vpx_codec_destroy +vpx_codec_get_frame +vpx_codec_peek_stream_info +vpx_codec_vp8_dx_algo diff --git a/media/libnestegg/src/Makefile.in b/media/libnestegg/src/Makefile.in index f2f714dd2f0f..6fc5af0ec48b 100644 --- a/media/libnestegg/src/Makefile.in +++ b/media/libnestegg/src/Makefile.in @@ -45,6 +45,9 @@ include $(DEPTH)/config/autoconf.mk MODULE = nestegg LIBRARY_NAME = nestegg FORCE_STATIC_LIB= 1 +ifeq (WINNT,$(OS_TARGET)) +VISIBILITY_FLAGS = +endif CSRCS = \ nestegg.c \ diff --git a/media/libogg/src/Makefile.in b/media/libogg/src/Makefile.in index e234b47da6fc..c9b072360bb5 100644 --- a/media/libogg/src/Makefile.in +++ b/media/libogg/src/Makefile.in @@ -44,6 +44,9 @@ include $(DEPTH)/config/autoconf.mk MODULE = ogg LIBRARY_NAME = ogg FORCE_STATIC_LIB= 1 +ifeq (WINNT,$(OS_TARGET)) +VISIBILITY_FLAGS = +endif CSRCS = \ ogg_bitwise.c \ diff --git a/media/libsydneyaudio/src/Makefile.in b/media/libsydneyaudio/src/Makefile.in index 332eb468e087..1ec54f973381 100644 --- a/media/libsydneyaudio/src/Makefile.in +++ b/media/libsydneyaudio/src/Makefile.in @@ -44,6 +44,9 @@ include $(DEPTH)/config/autoconf.mk MODULE = sydneyaudio LIBRARY_NAME = sydneyaudio FORCE_STATIC_LIB= 1 +ifeq (WINNT,$(OS_TARGET)) +VISIBILITY_FLAGS = +endif ifneq (,$(filter DragonFly FreeBSD GNU GNU_% NetBSD OpenBSD,$(OS_ARCH))) CSRCS = \ diff --git a/media/libtheora/lib/Makefile.in b/media/libtheora/lib/Makefile.in index 914b7d6d6bf2..58a10e1eb29a 100644 --- a/media/libtheora/lib/Makefile.in +++ b/media/libtheora/lib/Makefile.in @@ -43,6 +43,9 @@ include $(DEPTH)/config/autoconf.mk MODULE = theora LIBRARY_NAME = theora FORCE_STATIC_LIB = 1 +ifeq (WINNT,$(OS_TARGET)) +VISIBILITY_FLAGS = +endif # The encoder is currently not included. DEFINES += -DTHEORA_DISABLE_ENCODE diff --git a/media/libvorbis/lib/Makefile.in b/media/libvorbis/lib/Makefile.in index d238425b77aa..f42fc6605b9c 100644 --- a/media/libvorbis/lib/Makefile.in +++ b/media/libvorbis/lib/Makefile.in @@ -44,6 +44,9 @@ include $(DEPTH)/config/autoconf.mk MODULE = vorbis LIBRARY_NAME = vorbis FORCE_STATIC_LIB= 1 +ifeq (WINNT,$(OS_TARGET)) +VISIBILITY_FLAGS = +endif CSRCS = \ vorbis_mdct.c \ diff --git a/media/libvpx/Makefile.in b/media/libvpx/Makefile.in index 7b6aa08b799b..13bd7f24d2e0 100644 --- a/media/libvpx/Makefile.in +++ b/media/libvpx/Makefile.in @@ -47,6 +47,9 @@ DEFINES += -DHAVE_CONFIG_H=vpx_config.h MODULE = vpx LIBRARY_NAME = vpx FORCE_STATIC_LIB= 1 +ifeq (WINNT,$(OS_TARGET)) +VISIBILITY_FLAGS = +endif LOCAL_INCLUDES += \ -I. \ diff --git a/mobile/xul/installer/package-manifest.in b/mobile/xul/installer/package-manifest.in index e5e0931d8886..eb363520a0c2 100644 --- a/mobile/xul/installer/package-manifest.in +++ b/mobile/xul/installer/package-manifest.in @@ -59,6 +59,7 @@ @BINPATH@/@MOZ_CHILD_PROCESS_NAME@ #endif #ifdef XP_WIN32 +@BINPATH@/@DLL_PREFIX@gkmedias@DLL_SUFFIX@ #if _MSC_VER == 1400 @BINPATH@/Microsoft.VC80.CRT.manifest @BINPATH@/msvcm80.dll diff --git a/toolkit/library/Makefile.in b/toolkit/library/Makefile.in index 3e06d64ccd93..6de65bcb4726 100644 --- a/toolkit/library/Makefile.in +++ b/toolkit/library/Makefile.in @@ -403,6 +403,8 @@ ifdef MOZ_NATIVE_LIBVPX EXTRA_DSO_LDOPTS += $(MOZ_LIBVPX_LIBS) endif +EXTRA_DSO_LDOPTS += $(call EXPAND_LIBNAME_PATH,gkmedias,$(DIST)/lib) + ifdef MOZ_SYDNEYAUDIO ifeq ($(OS_ARCH),Linux) EXTRA_DSO_LDOPTS += $(MOZ_ALSA_LIBS) diff --git a/xpcom/stub/Makefile.in b/xpcom/stub/Makefile.in index 8a5675aa37da..696adf129dfb 100644 --- a/xpcom/stub/Makefile.in +++ b/xpcom/stub/Makefile.in @@ -103,6 +103,12 @@ ifdef MOZ_JPROF DEPENDENT_LIBS_LIST += $(DLL_PREFIX)jprof$(DLL_SUFFIX) endif +ifeq (WINNT,$(OS_TARGET)) +ifneq (,$(MOZ_SYDNEYAUDIO)$(MOZ_WEBM)$(MOZ_OGG)$(MOZ_TREMOR)$(MOZ_VORBIS)) +DEPENDENT_LIBS_LIST += $(DLL_PREFIX)gkmedias$(DLL_SUFFIX) +endif +endif + ifeq (bundle,$(MOZ_FS_LAYOUT)) EXTRA_DSO_LDOPTS += $(DIST)/bin/XUL DEPENDENT_LIBS_LIST += XUL From 16031a25e3d726068e538510483594f984e78024 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Thu, 15 Dec 2011 06:40:22 +0100 Subject: [PATCH 11/26] Bug 709721 - Part 2: Access vpx_codec_vp8_dx_algo through the function accessor to make things work cross-modules. r=cpearce --- content/media/webm/nsWebMReader.cpp | 4 ++-- layout/media/symbols.def | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/content/media/webm/nsWebMReader.cpp b/content/media/webm/nsWebMReader.cpp index f10d7b999dd1..06611ea4ff15 100644 --- a/content/media/webm/nsWebMReader.cpp +++ b/content/media/webm/nsWebMReader.cpp @@ -161,7 +161,7 @@ nsWebMReader::~nsWebMReader() nsresult nsWebMReader::Init(nsBuiltinDecoderReader* aCloneDonor) { - if (vpx_codec_dec_init(&mVP8, &vpx_codec_vp8_dx_algo, NULL, 0)) { + if (vpx_codec_dec_init(&mVP8, vpx_codec_vp8_dx(), NULL, 0)) { return NS_ERROR_FAILURE; } @@ -669,7 +669,7 @@ bool nsWebMReader::DecodeVideoFrame(bool &aKeyframeSkip, vpx_codec_stream_info_t si; memset(&si, 0, sizeof(si)); si.sz = sizeof(si); - vpx_codec_peek_stream_info(&vpx_codec_vp8_dx_algo, data, length, &si); + vpx_codec_peek_stream_info(vpx_codec_vp8_dx(), data, length, &si); if (aKeyframeSkip && (!si.is_kf || tstamp_usecs < aTimeThreshold)) { // Skipping to next keyframe... parsed++; // Assume 1 frame per chunk. diff --git a/layout/media/symbols.def b/layout/media/symbols.def index 8c148dec1923..3ee0a1596171 100644 --- a/layout/media/symbols.def +++ b/layout/media/symbols.def @@ -76,4 +76,4 @@ vpx_codec_decode vpx_codec_destroy vpx_codec_get_frame vpx_codec_peek_stream_info -vpx_codec_vp8_dx_algo +vpx_codec_vp8_dx From 08ab6292b869102bda3aeb5ccedfb8e461beee95 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Thu, 15 Dec 2011 06:40:23 +0100 Subject: [PATCH 12/26] Bug 709914 - Slice out the ANGLE compiler from libxul on Windows. r=khuey,a=philor --- gfx/angle/Makefile.in | 4 +++- layout/media/Makefile.in | 6 ++++++ layout/media/symbols.def | 8 ++++++++ toolkit/library/Makefile.in | 2 -- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/gfx/angle/Makefile.in b/gfx/angle/Makefile.in index 185ce9c19633..402a47696ebc 100644 --- a/gfx/angle/Makefile.in +++ b/gfx/angle/Makefile.in @@ -45,7 +45,9 @@ include $(DEPTH)/config/autoconf.mk MODULE = angle LIBRARY_NAME = angle LIBXUL_LIBRARY = 1 -EXPORT_LIBRARY = 1 +ifeq (WINNT,$(OS_TARGET)) +VISIBILITY_FLAGS = +endif EXPORTS_NAMESPACES = angle diff --git a/layout/media/Makefile.in b/layout/media/Makefile.in index 03e3385635bc..5cd4d0732d65 100644 --- a/layout/media/Makefile.in +++ b/layout/media/Makefile.in @@ -86,6 +86,12 @@ SHARED_LIBRARY_LIBS += \ $(NULL) endif +SHARED_LIBRARY_LIBS += \ + $(DEPTH)/gfx/angle/$(LIB_PREFIX)angle.$(LIB_SUFFIX) \ + $(NULL) + +EXTRA_DSO_LDOPTS = $(MOZALLOC_LIB) $(NSPR_LIBS) + ifeq (WINNT,$(OS_TARGET)) DEFFILE = $(srcdir)/symbols.def endif diff --git a/layout/media/symbols.def b/layout/media/symbols.def index 3ee0a1596171..5c636d478806 100644 --- a/layout/media/symbols.def +++ b/layout/media/symbols.def @@ -77,3 +77,11 @@ vpx_codec_destroy vpx_codec_get_frame vpx_codec_peek_stream_info vpx_codec_vp8_dx +ShInitialize +ShFinalize +ShGetObjectCode +ShDestruct +ShGetInfoLog +ShCompile +ShGetInfo +ShConstructCompiler diff --git a/toolkit/library/Makefile.in b/toolkit/library/Makefile.in index 6de65bcb4726..500ade9429a0 100644 --- a/toolkit/library/Makefile.in +++ b/toolkit/library/Makefile.in @@ -318,8 +318,6 @@ STATIC_LIBS += thebes gl ycbcr COMPONENT_LIBS += profiler -STATIC_LIBS += angle - ifeq (windows,$(MOZ_WIDGET_TOOLKIT)) COMPONENT_LIBS += gkwidget endif From 10e6018920610d27bcab1ac340acd733fe743668 Mon Sep 17 00:00:00 2001 From: Makoto Kato Date: Thu, 15 Dec 2011 19:22:06 +0900 Subject: [PATCH 14/26] Bug 709575 - Remove unnecessary ipc/chromium files. r=cjones --- ipc/chromium/Makefile.in | 3 - ipc/chromium/src/base/sha2.cc | 24 - ipc/chromium/src/base/sha2.h | 27 - ipc/chromium/src/base/sha2_unittest.cc | 78 - .../src/base/third_party/nss/README.chromium | 8 - ipc/chromium/src/base/third_party/nss/blapi.h | 105 -- .../src/base/third_party/nss/blapit.h | 91 -- .../src/base/third_party/nss/sha256.h | 51 - .../src/base/third_party/nss/sha512.cc | 1397 ----------------- 9 files changed, 1784 deletions(-) delete mode 100644 ipc/chromium/src/base/sha2.cc delete mode 100644 ipc/chromium/src/base/sha2.h delete mode 100644 ipc/chromium/src/base/sha2_unittest.cc delete mode 100644 ipc/chromium/src/base/third_party/nss/README.chromium delete mode 100644 ipc/chromium/src/base/third_party/nss/blapi.h delete mode 100644 ipc/chromium/src/base/third_party/nss/blapit.h delete mode 100644 ipc/chromium/src/base/third_party/nss/sha256.h delete mode 100644 ipc/chromium/src/base/third_party/nss/sha512.cc diff --git a/ipc/chromium/Makefile.in b/ipc/chromium/Makefile.in index cdd2b61d81a2..d85ec112a17c 100644 --- a/ipc/chromium/Makefile.in +++ b/ipc/chromium/Makefile.in @@ -63,7 +63,6 @@ endif # } vpath %.cc \ $(srcdir)/src/base \ $(srcdir)/src/base/third_party/nspr \ - $(srcdir)/src/base/third_party/nss \ $(srcdir)/src/chrome/common \ $(NULL) @@ -98,7 +97,6 @@ CPPSRCS += \ ref_counted.cc \ revocable_store.cc \ scoped_temp_dir.cc \ - sha2.cc \ simple_thread.cc \ stats_table.cc \ string_escape.cc \ @@ -130,7 +128,6 @@ CPPSRCS += \ message_router.cc \ notification_service.cc \ task_queue.cc \ - sha512.cc \ $(NULL) ifdef OS_WIN # { diff --git a/ipc/chromium/src/base/sha2.cc b/ipc/chromium/src/base/sha2.cc deleted file mode 100644 index 127a1b08aa6f..000000000000 --- a/ipc/chromium/src/base/sha2.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/sha2.h" - -#include "base/third_party/nss/blapi.h" -#include "base/third_party/nss/sha256.h" - -using namespace nss; - -namespace base { - -void SHA256HashString(const std::string& str, void* output, size_t len) { - SHA256Context ctx; - - SHA256_Begin(&ctx); - SHA256_Update(&ctx, reinterpret_cast(str.data()), - static_cast(str.length())); - SHA256_End(&ctx, static_cast(output), NULL, - static_cast(len)); -} - -} // namespace base diff --git a/ipc/chromium/src/base/sha2.h b/ipc/chromium/src/base/sha2.h deleted file mode 100644 index d7772e3ff809..000000000000 --- a/ipc/chromium/src/base/sha2.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef BASE_SHA2_H__ -#define BASE_SHA2_H__ - -#include - -namespace base { - -// These functions perform SHA-256 operations. -// -// Functions for SHA-384 and SHA-512 can be added when the need arises. - -enum { - SHA256_LENGTH = 32 // length in bytes of a SHA-256 hash -}; - -// Computes the SHA-256 hash of the input string 'str' and stores the first -// 'len' bytes of the hash in the output buffer 'output'. If 'len' > 32, -// only 32 bytes (the full hash) are stored in the 'output' buffer. -void SHA256HashString(const std::string& str, void* output, size_t len); - -} // namespace base - -#endif // BASE_SHA2_H__ diff --git a/ipc/chromium/src/base/sha2_unittest.cc b/ipc/chromium/src/base/sha2_unittest.cc deleted file mode 100644 index a6844dd463c9..000000000000 --- a/ipc/chromium/src/base/sha2_unittest.cc +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/sha2.h" - -#include "base/basictypes.h" -#include "testing/gtest/include/gtest/gtest.h" - -TEST(Sha256Test, Test1) { - // Example B.1 from FIPS 180-2: one-block message. - std::string input1 = "abc"; - int expected1[] = { 0xba, 0x78, 0x16, 0xbf, - 0x8f, 0x01, 0xcf, 0xea, - 0x41, 0x41, 0x40, 0xde, - 0x5d, 0xae, 0x22, 0x23, - 0xb0, 0x03, 0x61, 0xa3, - 0x96, 0x17, 0x7a, 0x9c, - 0xb4, 0x10, 0xff, 0x61, - 0xf2, 0x00, 0x15, 0xad }; - - uint8 output1[base::SHA256_LENGTH]; - base::SHA256HashString(input1, output1, sizeof(output1)); - for (size_t i = 0; i < base::SHA256_LENGTH; i++) - EXPECT_EQ(expected1[i], static_cast(output1[i])); - - uint8 output_truncated1[4]; // 4 bytes == 32 bits - base::SHA256HashString(input1, output_truncated1, sizeof(output_truncated1)); - for (size_t i = 0; i < sizeof(output_truncated1); i++) - EXPECT_EQ(expected1[i], static_cast(output_truncated1[i])); -} - -TEST(Sha256Test, Test2) { - // Example B.2 from FIPS 180-2: multi-block message. - std::string input2 = - "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; - int expected2[] = { 0x24, 0x8d, 0x6a, 0x61, - 0xd2, 0x06, 0x38, 0xb8, - 0xe5, 0xc0, 0x26, 0x93, - 0x0c, 0x3e, 0x60, 0x39, - 0xa3, 0x3c, 0xe4, 0x59, - 0x64, 0xff, 0x21, 0x67, - 0xf6, 0xec, 0xed, 0xd4, - 0x19, 0xdb, 0x06, 0xc1 }; - - uint8 output2[base::SHA256_LENGTH]; - base::SHA256HashString(input2, output2, sizeof(output2)); - for (size_t i = 0; i < base::SHA256_LENGTH; i++) - EXPECT_EQ(expected2[i], static_cast(output2[i])); - - uint8 output_truncated2[6]; - base::SHA256HashString(input2, output_truncated2, sizeof(output_truncated2)); - for (size_t i = 0; i < sizeof(output_truncated2); i++) - EXPECT_EQ(expected2[i], static_cast(output_truncated2[i])); -} - -TEST(Sha256Test, Test3) { - // Example B.3 from FIPS 180-2: long message. - std::string input3(1000000, 'a'); // 'a' repeated a million times - int expected3[] = { 0xcd, 0xc7, 0x6e, 0x5c, - 0x99, 0x14, 0xfb, 0x92, - 0x81, 0xa1, 0xc7, 0xe2, - 0x84, 0xd7, 0x3e, 0x67, - 0xf1, 0x80, 0x9a, 0x48, - 0xa4, 0x97, 0x20, 0x0e, - 0x04, 0x6d, 0x39, 0xcc, - 0xc7, 0x11, 0x2c, 0xd0 }; - - uint8 output3[base::SHA256_LENGTH]; - base::SHA256HashString(input3, output3, sizeof(output3)); - for (size_t i = 0; i < base::SHA256_LENGTH; i++) - EXPECT_EQ(expected3[i], static_cast(output3[i])); - - uint8 output_truncated3[12]; - base::SHA256HashString(input3, output_truncated3, sizeof(output_truncated3)); - for (size_t i = 0; i < sizeof(output_truncated3); i++) - EXPECT_EQ(expected3[i], static_cast(output_truncated3[i])); -} diff --git a/ipc/chromium/src/base/third_party/nss/README.chromium b/ipc/chromium/src/base/third_party/nss/README.chromium deleted file mode 100644 index 7106351fadb7..000000000000 --- a/ipc/chromium/src/base/third_party/nss/README.chromium +++ /dev/null @@ -1,8 +0,0 @@ -The original code is the Network Security Services (NSS), licensed under -the MPL/GPL/LGPL tri-license (http://www.mozilla.org/MPL/). - -We extracted the SHA-256 source files, eliminated unneeded dependencies, -deleted or commented out unused code, and tweaked them for Chrome's source -tree. sha512.c is renamed sha512.cc so that it can include Chrome's C++ -header "base/basictypes.h". We define NOUNROLL256 to reduce the object code -size. diff --git a/ipc/chromium/src/base/third_party/nss/blapi.h b/ipc/chromium/src/base/third_party/nss/blapi.h deleted file mode 100644 index bc069d2d3580..000000000000 --- a/ipc/chromium/src/base/third_party/nss/blapi.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * crypto.h - public data structures and prototypes for the crypto library - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is the Netscape security libraries. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1994-2000 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Dr Vipul Gupta , Sun Microsystems Laboratories - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -/* $Id: blapi.h,v 1.27 2007/11/09 18:49:32 wtc%google.com Exp $ */ - -#ifndef _BLAPI_H_ -#define _BLAPI_H_ - -#include "base/third_party/nss/blapit.h" - -namespace nss { - -/******************************************/ - -extern SHA256Context *SHA256_NewContext(void); -extern void SHA256_DestroyContext(SHA256Context *cx, bool freeit); -extern void SHA256_Begin(SHA256Context *cx); -extern void SHA256_Update(SHA256Context *cx, const unsigned char *input, - unsigned int inputLen); -extern void SHA256_End(SHA256Context *cx, unsigned char *digest, - unsigned int *digestLen, unsigned int maxDigestLen); -extern SECStatus SHA256_HashBuf(unsigned char *dest, const unsigned char *src, - uint32 src_length); -extern SECStatus SHA256_Hash(unsigned char *dest, const char *src); -extern void SHA256_TraceState(SHA256Context *cx); -extern unsigned int SHA256_FlattenSize(SHA256Context *cx); -extern SECStatus SHA256_Flatten(SHA256Context *cx,unsigned char *space); -extern SHA256Context * SHA256_Resurrect(unsigned char *space, void *arg); -extern void SHA256_Clone(SHA256Context *dest, SHA256Context *src); - -/******************************************/ - -extern SHA512Context *SHA512_NewContext(void); -extern void SHA512_DestroyContext(SHA512Context *cx, bool freeit); -extern void SHA512_Begin(SHA512Context *cx); -extern void SHA512_Update(SHA512Context *cx, const unsigned char *input, - unsigned int inputLen); -extern void SHA512_End(SHA512Context *cx, unsigned char *digest, - unsigned int *digestLen, unsigned int maxDigestLen); -extern SECStatus SHA512_HashBuf(unsigned char *dest, const unsigned char *src, - uint32 src_length); -extern SECStatus SHA512_Hash(unsigned char *dest, const char *src); -extern void SHA512_TraceState(SHA512Context *cx); -extern unsigned int SHA512_FlattenSize(SHA512Context *cx); -extern SECStatus SHA512_Flatten(SHA512Context *cx,unsigned char *space); -extern SHA512Context * SHA512_Resurrect(unsigned char *space, void *arg); -extern void SHA512_Clone(SHA512Context *dest, SHA512Context *src); - -/******************************************/ - -extern SHA384Context *SHA384_NewContext(void); -extern void SHA384_DestroyContext(SHA384Context *cx, bool freeit); -extern void SHA384_Begin(SHA384Context *cx); -extern void SHA384_Update(SHA384Context *cx, const unsigned char *input, - unsigned int inputLen); -extern void SHA384_End(SHA384Context *cx, unsigned char *digest, - unsigned int *digestLen, unsigned int maxDigestLen); -extern SECStatus SHA384_HashBuf(unsigned char *dest, const unsigned char *src, - uint32 src_length); -extern SECStatus SHA384_Hash(unsigned char *dest, const char *src); -extern void SHA384_TraceState(SHA384Context *cx); -extern unsigned int SHA384_FlattenSize(SHA384Context *cx); -extern SECStatus SHA384_Flatten(SHA384Context *cx,unsigned char *space); -extern SHA384Context * SHA384_Resurrect(unsigned char *space, void *arg); -extern void SHA384_Clone(SHA384Context *dest, SHA384Context *src); - -} // namespace nss - -#endif /* _BLAPI_H_ */ diff --git a/ipc/chromium/src/base/third_party/nss/blapit.h b/ipc/chromium/src/base/third_party/nss/blapit.h deleted file mode 100644 index e16a0846d378..000000000000 --- a/ipc/chromium/src/base/third_party/nss/blapit.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * blapit.h - public data structures for the crypto library - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is the Netscape security libraries. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1994-2000 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Dr Vipul Gupta and - * Douglas Stebila , Sun Microsystems Laboratories - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -/* $Id: blapit.h,v 1.20 2007/02/28 19:47:37 rrelyea%redhat.com Exp $ */ - -#ifndef _BLAPIT_H_ -#define _BLAPIT_H_ - -#include "base/third_party/nspr/prtypes.h" - -/* -** A status code. Status's are used by procedures that return status -** values. Again the motivation is so that a compiler can generate -** warnings when return values are wrong. Correct testing of status codes: -** -** SECStatus rv; -** rv = some_function (some_argument); -** if (rv != SECSuccess) -** do_an_error_thing(); -** -*/ -typedef enum _SECStatus { - SECWouldBlock = -2, - SECFailure = -1, - SECSuccess = 0 -} SECStatus; - -#define SHA256_LENGTH 32 /* bytes */ -#define SHA384_LENGTH 48 /* bytes */ -#define SHA512_LENGTH 64 /* bytes */ -#define HASH_LENGTH_MAX SHA512_LENGTH - -/* - * Input block size for each hash algorithm. - */ - -#define SHA256_BLOCK_LENGTH 64 /* bytes */ -#define SHA384_BLOCK_LENGTH 128 /* bytes */ -#define SHA512_BLOCK_LENGTH 128 /* bytes */ -#define HASH_BLOCK_LENGTH_MAX SHA512_BLOCK_LENGTH - -/*************************************************************************** -** Opaque objects -*/ - -struct SHA256ContextStr ; -struct SHA512ContextStr ; - -typedef struct SHA256ContextStr SHA256Context; -typedef struct SHA512ContextStr SHA512Context; -/* SHA384Context is really a SHA512ContextStr. This is not a mistake. */ -typedef struct SHA512ContextStr SHA384Context; - -#endif /* _BLAPIT_H_ */ diff --git a/ipc/chromium/src/base/third_party/nss/sha256.h b/ipc/chromium/src/base/third_party/nss/sha256.h deleted file mode 100644 index e641b4916196..000000000000 --- a/ipc/chromium/src/base/third_party/nss/sha256.h +++ /dev/null @@ -1,51 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is the Netscape security libraries. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2002 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef _SHA_256_H_ -#define _SHA_256_H_ - -#include "base/third_party/nspr/prtypes.h" - -struct SHA256ContextStr { - union { - PRUint32 w[64]; /* message schedule, input buffer, plus 48 words */ - PRUint8 b[256]; - } u; - PRUint32 h[8]; /* 8 state variables */ - PRUint32 sizeHi,sizeLo; /* 64-bit count of hashed bytes. */ -}; - -#endif /* _SHA_256_H_ */ diff --git a/ipc/chromium/src/base/third_party/nss/sha512.cc b/ipc/chromium/src/base/third_party/nss/sha512.cc deleted file mode 100644 index 48e1ce24d42c..000000000000 --- a/ipc/chromium/src/base/third_party/nss/sha512.cc +++ /dev/null @@ -1,1397 +0,0 @@ -/* - * sha512.c - implementation of SHA256, SHA384 and SHA512 - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is the Netscape security libraries. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2002 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -/* $Id: sha512.c,v 1.9 2006/10/13 16:54:04 wtchang%redhat.com Exp $ */ - -// Prevent manual unrolling in the sha256 code, which reduces the binary code -// size from ~10k to ~1k. The performance should be reasonable for our use. -#define NOUNROLL256 1 - -#include "base/third_party/nspr/prtypes.h" /* for PRUintXX */ -#if defined(_X86_) || defined(SHA_NO_LONG_LONG) -#define NOUNROLL512 1 -#undef HAVE_LONG_LONG -#endif -#include "base/third_party/nss/blapi.h" -#include "base/third_party/nss/sha256.h" /* for struct SHA256ContextStr */ - -#include -#include -#define PORT_New(type) static_cast(malloc(sizeof(type))) -#define PORT_ZFree(ptr, len) do { memset(ptr, 0, len); free(ptr); } while (0) -#define PORT_Strlen(s) static_cast(strlen(s)) -#define PORT_Memcpy memcpy - -namespace nss { - -/* ============= Common constants and defines ======================= */ - -#define W ctx->u.w -#define B ctx->u.b -#define H ctx->h - -#define SHR(x,n) (x >> n) -#define SHL(x,n) (x << n) -#define Ch(x,y,z) ((x & y) ^ (~x & z)) -#define Maj(x,y,z) ((x & y) ^ (x & z) ^ (y & z)) - -/* Padding used with all flavors of SHA */ -static const PRUint8 pad[240] = { -0x80,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - /* compiler will fill the rest in with zeros */ -}; - -/* ============= SHA256 implemenmtation ================================== */ - -/* SHA-256 constants, K256. */ -static const PRUint32 K256[64] = { - 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, - 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, - 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, - 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, - 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, - 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, - 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, - 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, - 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, - 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, - 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, - 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, - 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, - 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, - 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, - 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 -}; - -/* SHA-256 initial hash values */ -static const PRUint32 H256[8] = { - 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, - 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 -}; - -#if defined(_MSC_VER) && defined(_X86_) -#ifndef FORCEINLINE -#if (_MSC_VER >= 1200) -#define FORCEINLINE __forceinline -#else -#define FORCEINLINE __inline -#endif -#endif -#define FASTCALL __fastcall - -static FORCEINLINE PRUint32 FASTCALL -swap4b(PRUint32 dwd) -{ - __asm { - mov eax,dwd - bswap eax - } -} - -#define SHA_HTONL(x) swap4b(x) -#define BYTESWAP4(x) x = SHA_HTONL(x) - -#elif defined(LINUX) && defined(_X86_) -#undef __OPTIMIZE__ -#define __OPTIMIZE__ 1 -#undef __pentium__ -#define __pentium__ 1 -#include -#define SHA_HTONL(x) bswap_32(x) -#define BYTESWAP4(x) x = SHA_HTONL(x) - -#else /* neither windows nor Linux PC */ -#define SWAP4MASK 0x00FF00FF -#define SHA_HTONL(x) (t1 = (x), t1 = (t1 << 16) | (t1 >> 16), \ - ((t1 & SWAP4MASK) << 8) | ((t1 >> 8) & SWAP4MASK)) -#define BYTESWAP4(x) x = SHA_HTONL(x) -#endif - -#if defined(_MSC_VER) && defined(_X86_) -#pragma intrinsic (_lrotr, _lrotl) -#define ROTR32(x,n) _lrotr(x,n) -#define ROTL32(x,n) _lrotl(x,n) -#else -#define ROTR32(x,n) ((x >> n) | (x << ((8 * sizeof x) - n))) -#define ROTL32(x,n) ((x << n) | (x >> ((8 * sizeof x) - n))) -#endif - -/* Capitol Sigma and lower case sigma functions */ -#define S0(x) (ROTR32(x, 2) ^ ROTR32(x,13) ^ ROTR32(x,22)) -#define S1(x) (ROTR32(x, 6) ^ ROTR32(x,11) ^ ROTR32(x,25)) -#define s0(x) (t1 = x, ROTR32(t1, 7) ^ ROTR32(t1,18) ^ SHR(t1, 3)) -#define s1(x) (t2 = x, ROTR32(t2,17) ^ ROTR32(t2,19) ^ SHR(t2,10)) - -SHA256Context * -SHA256_NewContext(void) -{ - SHA256Context *ctx = PORT_New(SHA256Context); - return ctx; -} - -void -SHA256_DestroyContext(SHA256Context *ctx, bool freeit) -{ - if (freeit) { - PORT_ZFree(ctx, sizeof *ctx); - } -} - -void -SHA256_Begin(SHA256Context *ctx) -{ - memset(ctx, 0, sizeof *ctx); - memcpy(H, H256, sizeof H256); -} - -static void -SHA256_Compress(SHA256Context *ctx) -{ - { - register PRUint32 t1, t2; - -#if defined(IS_LITTLE_ENDIAN) - BYTESWAP4(W[0]); - BYTESWAP4(W[1]); - BYTESWAP4(W[2]); - BYTESWAP4(W[3]); - BYTESWAP4(W[4]); - BYTESWAP4(W[5]); - BYTESWAP4(W[6]); - BYTESWAP4(W[7]); - BYTESWAP4(W[8]); - BYTESWAP4(W[9]); - BYTESWAP4(W[10]); - BYTESWAP4(W[11]); - BYTESWAP4(W[12]); - BYTESWAP4(W[13]); - BYTESWAP4(W[14]); - BYTESWAP4(W[15]); -#endif - -#define INITW(t) W[t] = (s1(W[t-2]) + W[t-7] + s0(W[t-15]) + W[t-16]) - - /* prepare the "message schedule" */ -#ifdef NOUNROLL256 - { - int t; - for (t = 16; t < 64; ++t) { - INITW(t); - } - } -#else - INITW(16); - INITW(17); - INITW(18); - INITW(19); - - INITW(20); - INITW(21); - INITW(22); - INITW(23); - INITW(24); - INITW(25); - INITW(26); - INITW(27); - INITW(28); - INITW(29); - - INITW(30); - INITW(31); - INITW(32); - INITW(33); - INITW(34); - INITW(35); - INITW(36); - INITW(37); - INITW(38); - INITW(39); - - INITW(40); - INITW(41); - INITW(42); - INITW(43); - INITW(44); - INITW(45); - INITW(46); - INITW(47); - INITW(48); - INITW(49); - - INITW(50); - INITW(51); - INITW(52); - INITW(53); - INITW(54); - INITW(55); - INITW(56); - INITW(57); - INITW(58); - INITW(59); - - INITW(60); - INITW(61); - INITW(62); - INITW(63); - -#endif -#undef INITW - } - { - PRUint32 a, b, c, d, e, f, g, h; - - a = H[0]; - b = H[1]; - c = H[2]; - d = H[3]; - e = H[4]; - f = H[5]; - g = H[6]; - h = H[7]; - -#define ROUND(n,a,b,c,d,e,f,g,h) \ - h += S1(e) + Ch(e,f,g) + K256[n] + W[n]; \ - d += h; \ - h += S0(a) + Maj(a,b,c); - -#ifdef NOUNROLL256 - { - int t; - for (t = 0; t < 64; t+= 8) { - ROUND(t+0,a,b,c,d,e,f,g,h) - ROUND(t+1,h,a,b,c,d,e,f,g) - ROUND(t+2,g,h,a,b,c,d,e,f) - ROUND(t+3,f,g,h,a,b,c,d,e) - ROUND(t+4,e,f,g,h,a,b,c,d) - ROUND(t+5,d,e,f,g,h,a,b,c) - ROUND(t+6,c,d,e,f,g,h,a,b) - ROUND(t+7,b,c,d,e,f,g,h,a) - } - } -#else - ROUND( 0,a,b,c,d,e,f,g,h) - ROUND( 1,h,a,b,c,d,e,f,g) - ROUND( 2,g,h,a,b,c,d,e,f) - ROUND( 3,f,g,h,a,b,c,d,e) - ROUND( 4,e,f,g,h,a,b,c,d) - ROUND( 5,d,e,f,g,h,a,b,c) - ROUND( 6,c,d,e,f,g,h,a,b) - ROUND( 7,b,c,d,e,f,g,h,a) - - ROUND( 8,a,b,c,d,e,f,g,h) - ROUND( 9,h,a,b,c,d,e,f,g) - ROUND(10,g,h,a,b,c,d,e,f) - ROUND(11,f,g,h,a,b,c,d,e) - ROUND(12,e,f,g,h,a,b,c,d) - ROUND(13,d,e,f,g,h,a,b,c) - ROUND(14,c,d,e,f,g,h,a,b) - ROUND(15,b,c,d,e,f,g,h,a) - - ROUND(16,a,b,c,d,e,f,g,h) - ROUND(17,h,a,b,c,d,e,f,g) - ROUND(18,g,h,a,b,c,d,e,f) - ROUND(19,f,g,h,a,b,c,d,e) - ROUND(20,e,f,g,h,a,b,c,d) - ROUND(21,d,e,f,g,h,a,b,c) - ROUND(22,c,d,e,f,g,h,a,b) - ROUND(23,b,c,d,e,f,g,h,a) - - ROUND(24,a,b,c,d,e,f,g,h) - ROUND(25,h,a,b,c,d,e,f,g) - ROUND(26,g,h,a,b,c,d,e,f) - ROUND(27,f,g,h,a,b,c,d,e) - ROUND(28,e,f,g,h,a,b,c,d) - ROUND(29,d,e,f,g,h,a,b,c) - ROUND(30,c,d,e,f,g,h,a,b) - ROUND(31,b,c,d,e,f,g,h,a) - - ROUND(32,a,b,c,d,e,f,g,h) - ROUND(33,h,a,b,c,d,e,f,g) - ROUND(34,g,h,a,b,c,d,e,f) - ROUND(35,f,g,h,a,b,c,d,e) - ROUND(36,e,f,g,h,a,b,c,d) - ROUND(37,d,e,f,g,h,a,b,c) - ROUND(38,c,d,e,f,g,h,a,b) - ROUND(39,b,c,d,e,f,g,h,a) - - ROUND(40,a,b,c,d,e,f,g,h) - ROUND(41,h,a,b,c,d,e,f,g) - ROUND(42,g,h,a,b,c,d,e,f) - ROUND(43,f,g,h,a,b,c,d,e) - ROUND(44,e,f,g,h,a,b,c,d) - ROUND(45,d,e,f,g,h,a,b,c) - ROUND(46,c,d,e,f,g,h,a,b) - ROUND(47,b,c,d,e,f,g,h,a) - - ROUND(48,a,b,c,d,e,f,g,h) - ROUND(49,h,a,b,c,d,e,f,g) - ROUND(50,g,h,a,b,c,d,e,f) - ROUND(51,f,g,h,a,b,c,d,e) - ROUND(52,e,f,g,h,a,b,c,d) - ROUND(53,d,e,f,g,h,a,b,c) - ROUND(54,c,d,e,f,g,h,a,b) - ROUND(55,b,c,d,e,f,g,h,a) - - ROUND(56,a,b,c,d,e,f,g,h) - ROUND(57,h,a,b,c,d,e,f,g) - ROUND(58,g,h,a,b,c,d,e,f) - ROUND(59,f,g,h,a,b,c,d,e) - ROUND(60,e,f,g,h,a,b,c,d) - ROUND(61,d,e,f,g,h,a,b,c) - ROUND(62,c,d,e,f,g,h,a,b) - ROUND(63,b,c,d,e,f,g,h,a) -#endif - - H[0] += a; - H[1] += b; - H[2] += c; - H[3] += d; - H[4] += e; - H[5] += f; - H[6] += g; - H[7] += h; - } -#undef ROUND -} - -#undef s0 -#undef s1 -#undef S0 -#undef S1 - -void -SHA256_Update(SHA256Context *ctx, const unsigned char *input, - unsigned int inputLen) -{ - unsigned int inBuf = ctx->sizeLo & 0x3f; - if (!inputLen) - return; - - /* Add inputLen into the count of bytes processed, before processing */ - if ((ctx->sizeLo += inputLen) < inputLen) - ctx->sizeHi++; - - /* if data already in buffer, attemp to fill rest of buffer */ - if (inBuf) { - unsigned int todo = SHA256_BLOCK_LENGTH - inBuf; - if (inputLen < todo) - todo = inputLen; - memcpy(B + inBuf, input, todo); - input += todo; - inputLen -= todo; - if (inBuf + todo == SHA256_BLOCK_LENGTH) - SHA256_Compress(ctx); - } - - /* if enough data to fill one or more whole buffers, process them. */ - while (inputLen >= SHA256_BLOCK_LENGTH) { - memcpy(B, input, SHA256_BLOCK_LENGTH); - input += SHA256_BLOCK_LENGTH; - inputLen -= SHA256_BLOCK_LENGTH; - SHA256_Compress(ctx); - } - /* if data left over, fill it into buffer */ - if (inputLen) - memcpy(B, input, inputLen); -} - -void -SHA256_End(SHA256Context *ctx, unsigned char *digest, - unsigned int *digestLen, unsigned int maxDigestLen) -{ - unsigned int inBuf = ctx->sizeLo & 0x3f; - unsigned int padLen = (inBuf < 56) ? (56 - inBuf) : (56 + 64 - inBuf); - PRUint32 hi, lo; -#ifdef SWAP4MASK - PRUint32 t1; -#endif - - hi = (ctx->sizeHi << 3) | (ctx->sizeLo >> 29); - lo = (ctx->sizeLo << 3); - - SHA256_Update(ctx, pad, padLen); - -#if defined(IS_LITTLE_ENDIAN) - W[14] = SHA_HTONL(hi); - W[15] = SHA_HTONL(lo); -#else - W[14] = hi; - W[15] = lo; -#endif - SHA256_Compress(ctx); - - /* now output the answer */ -#if defined(IS_LITTLE_ENDIAN) - BYTESWAP4(H[0]); - BYTESWAP4(H[1]); - BYTESWAP4(H[2]); - BYTESWAP4(H[3]); - BYTESWAP4(H[4]); - BYTESWAP4(H[5]); - BYTESWAP4(H[6]); - BYTESWAP4(H[7]); -#endif - padLen = PR_MIN(SHA256_LENGTH, maxDigestLen); - memcpy(digest, H, padLen); - if (digestLen) - *digestLen = padLen; -} - -/* Comment out unused code, mostly the SHA384 and SHA512 implementations. */ -#if 0 -SECStatus -SHA256_HashBuf(unsigned char *dest, const unsigned char *src, - uint32 src_length) -{ - SHA256Context ctx; - unsigned int outLen; - - SHA256_Begin(&ctx); - SHA256_Update(&ctx, src, src_length); - SHA256_End(&ctx, dest, &outLen, SHA256_LENGTH); - - return SECSuccess; -} - - -SECStatus -SHA256_Hash(unsigned char *dest, const char *src) -{ - return SHA256_HashBuf(dest, (const unsigned char *)src, PORT_Strlen(src)); -} - - -void SHA256_TraceState(SHA256Context *ctx) { } - -unsigned int -SHA256_FlattenSize(SHA256Context *ctx) -{ - return sizeof *ctx; -} - -SECStatus -SHA256_Flatten(SHA256Context *ctx,unsigned char *space) -{ - PORT_Memcpy(space, ctx, sizeof *ctx); - return SECSuccess; -} - -SHA256Context * -SHA256_Resurrect(unsigned char *space, void *arg) -{ - SHA256Context *ctx = SHA256_NewContext(); - if (ctx) - PORT_Memcpy(ctx, space, sizeof *ctx); - return ctx; -} - -void SHA256_Clone(SHA256Context *dest, SHA256Context *src) -{ - memcpy(dest, src, sizeof *dest); -} - - -/* ======= SHA512 and SHA384 common constants and defines ================= */ - -/* common #defines for SHA512 and SHA384 */ -#if defined(HAVE_LONG_LONG) -#define ROTR64(x,n) ((x >> n) | (x << (64 - n))) -#define ROTL64(x,n) ((x << n) | (x >> (64 - n))) - -#define S0(x) (ROTR64(x,28) ^ ROTR64(x,34) ^ ROTR64(x,39)) -#define S1(x) (ROTR64(x,14) ^ ROTR64(x,18) ^ ROTR64(x,41)) -#define s0(x) (t1 = x, ROTR64(t1, 1) ^ ROTR64(t1, 8) ^ SHR(t1,7)) -#define s1(x) (t2 = x, ROTR64(t2,19) ^ ROTR64(t2,61) ^ SHR(t2,6)) - -#if PR_BYTES_PER_LONG == 8 -#define ULLC(hi,lo) 0x ## hi ## lo ## UL -#elif defined(_MSC_VER) -#define ULLC(hi,lo) 0x ## hi ## lo ## ui64 -#else -#define ULLC(hi,lo) 0x ## hi ## lo ## ULL -#endif - -#define SHA_MASK16 ULLC(0000FFFF,0000FFFF) -#define SHA_MASK8 ULLC(00FF00FF,00FF00FF) -#define SHA_HTONLL(x) (t1 = x, \ - t1 = ((t1 & SHA_MASK8 ) << 8) | ((t1 >> 8) & SHA_MASK8 ), \ - t1 = ((t1 & SHA_MASK16) << 16) | ((t1 >> 16) & SHA_MASK16), \ - (t1 >> 32) | (t1 << 32)) -#define BYTESWAP8(x) x = SHA_HTONLL(x) - -#else /* no long long */ - -#if defined(IS_LITTLE_ENDIAN) -#define ULLC(hi,lo) { 0x ## lo ## U, 0x ## hi ## U } -#else -#define ULLC(hi,lo) { 0x ## hi ## U, 0x ## lo ## U } -#endif - -#define SHA_HTONLL(x) ( BYTESWAP4(x.lo), BYTESWAP4(x.hi), \ - x.hi ^= x.lo ^= x.hi ^= x.lo, x) -#define BYTESWAP8(x) do { PRUint32 tmp; BYTESWAP4(x.lo); BYTESWAP4(x.hi); \ - tmp = x.lo; x.lo = x.hi; x.hi = tmp; } while (0) -#endif - -/* SHA-384 and SHA-512 constants, K512. */ -static const PRUint64 K512[80] = { -#if PR_BYTES_PER_LONG == 8 - 0x428a2f98d728ae22UL , 0x7137449123ef65cdUL , - 0xb5c0fbcfec4d3b2fUL , 0xe9b5dba58189dbbcUL , - 0x3956c25bf348b538UL , 0x59f111f1b605d019UL , - 0x923f82a4af194f9bUL , 0xab1c5ed5da6d8118UL , - 0xd807aa98a3030242UL , 0x12835b0145706fbeUL , - 0x243185be4ee4b28cUL , 0x550c7dc3d5ffb4e2UL , - 0x72be5d74f27b896fUL , 0x80deb1fe3b1696b1UL , - 0x9bdc06a725c71235UL , 0xc19bf174cf692694UL , - 0xe49b69c19ef14ad2UL , 0xefbe4786384f25e3UL , - 0x0fc19dc68b8cd5b5UL , 0x240ca1cc77ac9c65UL , - 0x2de92c6f592b0275UL , 0x4a7484aa6ea6e483UL , - 0x5cb0a9dcbd41fbd4UL , 0x76f988da831153b5UL , - 0x983e5152ee66dfabUL , 0xa831c66d2db43210UL , - 0xb00327c898fb213fUL , 0xbf597fc7beef0ee4UL , - 0xc6e00bf33da88fc2UL , 0xd5a79147930aa725UL , - 0x06ca6351e003826fUL , 0x142929670a0e6e70UL , - 0x27b70a8546d22ffcUL , 0x2e1b21385c26c926UL , - 0x4d2c6dfc5ac42aedUL , 0x53380d139d95b3dfUL , - 0x650a73548baf63deUL , 0x766a0abb3c77b2a8UL , - 0x81c2c92e47edaee6UL , 0x92722c851482353bUL , - 0xa2bfe8a14cf10364UL , 0xa81a664bbc423001UL , - 0xc24b8b70d0f89791UL , 0xc76c51a30654be30UL , - 0xd192e819d6ef5218UL , 0xd69906245565a910UL , - 0xf40e35855771202aUL , 0x106aa07032bbd1b8UL , - 0x19a4c116b8d2d0c8UL , 0x1e376c085141ab53UL , - 0x2748774cdf8eeb99UL , 0x34b0bcb5e19b48a8UL , - 0x391c0cb3c5c95a63UL , 0x4ed8aa4ae3418acbUL , - 0x5b9cca4f7763e373UL , 0x682e6ff3d6b2b8a3UL , - 0x748f82ee5defb2fcUL , 0x78a5636f43172f60UL , - 0x84c87814a1f0ab72UL , 0x8cc702081a6439ecUL , - 0x90befffa23631e28UL , 0xa4506cebde82bde9UL , - 0xbef9a3f7b2c67915UL , 0xc67178f2e372532bUL , - 0xca273eceea26619cUL , 0xd186b8c721c0c207UL , - 0xeada7dd6cde0eb1eUL , 0xf57d4f7fee6ed178UL , - 0x06f067aa72176fbaUL , 0x0a637dc5a2c898a6UL , - 0x113f9804bef90daeUL , 0x1b710b35131c471bUL , - 0x28db77f523047d84UL , 0x32caab7b40c72493UL , - 0x3c9ebe0a15c9bebcUL , 0x431d67c49c100d4cUL , - 0x4cc5d4becb3e42b6UL , 0x597f299cfc657e2aUL , - 0x5fcb6fab3ad6faecUL , 0x6c44198c4a475817UL -#else - ULLC(428a2f98,d728ae22), ULLC(71374491,23ef65cd), - ULLC(b5c0fbcf,ec4d3b2f), ULLC(e9b5dba5,8189dbbc), - ULLC(3956c25b,f348b538), ULLC(59f111f1,b605d019), - ULLC(923f82a4,af194f9b), ULLC(ab1c5ed5,da6d8118), - ULLC(d807aa98,a3030242), ULLC(12835b01,45706fbe), - ULLC(243185be,4ee4b28c), ULLC(550c7dc3,d5ffb4e2), - ULLC(72be5d74,f27b896f), ULLC(80deb1fe,3b1696b1), - ULLC(9bdc06a7,25c71235), ULLC(c19bf174,cf692694), - ULLC(e49b69c1,9ef14ad2), ULLC(efbe4786,384f25e3), - ULLC(0fc19dc6,8b8cd5b5), ULLC(240ca1cc,77ac9c65), - ULLC(2de92c6f,592b0275), ULLC(4a7484aa,6ea6e483), - ULLC(5cb0a9dc,bd41fbd4), ULLC(76f988da,831153b5), - ULLC(983e5152,ee66dfab), ULLC(a831c66d,2db43210), - ULLC(b00327c8,98fb213f), ULLC(bf597fc7,beef0ee4), - ULLC(c6e00bf3,3da88fc2), ULLC(d5a79147,930aa725), - ULLC(06ca6351,e003826f), ULLC(14292967,0a0e6e70), - ULLC(27b70a85,46d22ffc), ULLC(2e1b2138,5c26c926), - ULLC(4d2c6dfc,5ac42aed), ULLC(53380d13,9d95b3df), - ULLC(650a7354,8baf63de), ULLC(766a0abb,3c77b2a8), - ULLC(81c2c92e,47edaee6), ULLC(92722c85,1482353b), - ULLC(a2bfe8a1,4cf10364), ULLC(a81a664b,bc423001), - ULLC(c24b8b70,d0f89791), ULLC(c76c51a3,0654be30), - ULLC(d192e819,d6ef5218), ULLC(d6990624,5565a910), - ULLC(f40e3585,5771202a), ULLC(106aa070,32bbd1b8), - ULLC(19a4c116,b8d2d0c8), ULLC(1e376c08,5141ab53), - ULLC(2748774c,df8eeb99), ULLC(34b0bcb5,e19b48a8), - ULLC(391c0cb3,c5c95a63), ULLC(4ed8aa4a,e3418acb), - ULLC(5b9cca4f,7763e373), ULLC(682e6ff3,d6b2b8a3), - ULLC(748f82ee,5defb2fc), ULLC(78a5636f,43172f60), - ULLC(84c87814,a1f0ab72), ULLC(8cc70208,1a6439ec), - ULLC(90befffa,23631e28), ULLC(a4506ceb,de82bde9), - ULLC(bef9a3f7,b2c67915), ULLC(c67178f2,e372532b), - ULLC(ca273ece,ea26619c), ULLC(d186b8c7,21c0c207), - ULLC(eada7dd6,cde0eb1e), ULLC(f57d4f7f,ee6ed178), - ULLC(06f067aa,72176fba), ULLC(0a637dc5,a2c898a6), - ULLC(113f9804,bef90dae), ULLC(1b710b35,131c471b), - ULLC(28db77f5,23047d84), ULLC(32caab7b,40c72493), - ULLC(3c9ebe0a,15c9bebc), ULLC(431d67c4,9c100d4c), - ULLC(4cc5d4be,cb3e42b6), ULLC(597f299c,fc657e2a), - ULLC(5fcb6fab,3ad6faec), ULLC(6c44198c,4a475817) -#endif -}; - -struct SHA512ContextStr { - union { - PRUint64 w[80]; /* message schedule, input buffer, plus 64 words */ - PRUint32 l[160]; - PRUint8 b[640]; - } u; - PRUint64 h[8]; /* 8 state variables */ - PRUint64 sizeLo; /* 64-bit count of hashed bytes. */ -}; - -/* =========== SHA512 implementation ===================================== */ - -/* SHA-512 initial hash values */ -static const PRUint64 H512[8] = { -#if PR_BYTES_PER_LONG == 8 - 0x6a09e667f3bcc908UL , 0xbb67ae8584caa73bUL , - 0x3c6ef372fe94f82bUL , 0xa54ff53a5f1d36f1UL , - 0x510e527fade682d1UL , 0x9b05688c2b3e6c1fUL , - 0x1f83d9abfb41bd6bUL , 0x5be0cd19137e2179UL -#else - ULLC(6a09e667,f3bcc908), ULLC(bb67ae85,84caa73b), - ULLC(3c6ef372,fe94f82b), ULLC(a54ff53a,5f1d36f1), - ULLC(510e527f,ade682d1), ULLC(9b05688c,2b3e6c1f), - ULLC(1f83d9ab,fb41bd6b), ULLC(5be0cd19,137e2179) -#endif -}; - - -SHA512Context * -SHA512_NewContext(void) -{ - SHA512Context *ctx = PORT_New(SHA512Context); - return ctx; -} - -void -SHA512_DestroyContext(SHA512Context *ctx, bool freeit) -{ - if (freeit) { - PORT_ZFree(ctx, sizeof *ctx); - } -} - -void -SHA512_Begin(SHA512Context *ctx) -{ - memset(ctx, 0, sizeof *ctx); - memcpy(H, H512, sizeof H512); -} - -#if defined(SHA512_TRACE) -#if defined(HAVE_LONG_LONG) -#define DUMP(n,a,d,e,h) printf(" t = %2d, %s = %016lx, %s = %016lx\n", \ - n, #e, d, #a, h); -#else -#define DUMP(n,a,d,e,h) printf(" t = %2d, %s = %08x%08x, %s = %08x%08x\n", \ - n, #e, d.hi, d.lo, #a, h.hi, h.lo); -#endif -#else -#define DUMP(n,a,d,e,h) -#endif - -#if defined(HAVE_LONG_LONG) - -#define ADDTO(x,y) y += x - -#define INITW(t) W[t] = (s1(W[t-2]) + W[t-7] + s0(W[t-15]) + W[t-16]) - -#define ROUND(n,a,b,c,d,e,f,g,h) \ - h += S1(e) + Ch(e,f,g) + K512[n] + W[n]; \ - d += h; \ - h += S0(a) + Maj(a,b,c); \ - DUMP(n,a,d,e,h) - -#else /* use only 32-bit variables, and don't unroll loops */ - -#undef NOUNROLL512 -#define NOUNROLL512 1 - -#define ADDTO(x,y) y.lo += x.lo; y.hi += x.hi + (x.lo > y.lo) - -#define ROTR64a(x,n,lo,hi) (x.lo >> n | x.hi << (32-n)) -#define ROTR64A(x,n,lo,hi) (x.lo << (64-n) | x.hi >> (n-32)) -#define SHR64a(x,n,lo,hi) (x.lo >> n | x.hi << (32-n)) - -/* Capitol Sigma and lower case sigma functions */ -#define s0lo(x) (ROTR64a(x,1,lo,hi) ^ ROTR64a(x,8,lo,hi) ^ SHR64a(x,7,lo,hi)) -#define s0hi(x) (ROTR64a(x,1,hi,lo) ^ ROTR64a(x,8,hi,lo) ^ (x.hi >> 7)) - -#define s1lo(x) (ROTR64a(x,19,lo,hi) ^ ROTR64A(x,61,lo,hi) ^ SHR64a(x,6,lo,hi)) -#define s1hi(x) (ROTR64a(x,19,hi,lo) ^ ROTR64A(x,61,hi,lo) ^ (x.hi >> 6)) - -#define S0lo(x)(ROTR64a(x,28,lo,hi) ^ ROTR64A(x,34,lo,hi) ^ ROTR64A(x,39,lo,hi)) -#define S0hi(x)(ROTR64a(x,28,hi,lo) ^ ROTR64A(x,34,hi,lo) ^ ROTR64A(x,39,hi,lo)) - -#define S1lo(x)(ROTR64a(x,14,lo,hi) ^ ROTR64a(x,18,lo,hi) ^ ROTR64A(x,41,lo,hi)) -#define S1hi(x)(ROTR64a(x,14,hi,lo) ^ ROTR64a(x,18,hi,lo) ^ ROTR64A(x,41,hi,lo)) - -/* 32-bit versions of Ch and Maj */ -#define Chxx(x,y,z,lo) ((x.lo & y.lo) ^ (~x.lo & z.lo)) -#define Majx(x,y,z,lo) ((x.lo & y.lo) ^ (x.lo & z.lo) ^ (y.lo & z.lo)) - -#define INITW(t) \ - do { \ - PRUint32 lo, tm; \ - PRUint32 cy = 0; \ - lo = s1lo(W[t-2]); \ - lo += (tm = W[t-7].lo); if (lo < tm) cy++; \ - lo += (tm = s0lo(W[t-15])); if (lo < tm) cy++; \ - lo += (tm = W[t-16].lo); if (lo < tm) cy++; \ - W[t].lo = lo; \ - W[t].hi = cy + s1hi(W[t-2]) + W[t-7].hi + s0hi(W[t-15]) + W[t-16].hi; \ - } while (0) - -#define ROUND(n,a,b,c,d,e,f,g,h) \ - { \ - PRUint32 lo, tm, cy; \ - lo = S1lo(e); \ - lo += (tm = Chxx(e,f,g,lo)); cy = (lo < tm); \ - lo += (tm = K512[n].lo); if (lo < tm) cy++; \ - lo += (tm = W[n].lo); if (lo < tm) cy++; \ - h.lo += lo; if (h.lo < lo) cy++; \ - h.hi += cy + S1hi(e) + Chxx(e,f,g,hi) + K512[n].hi + W[n].hi; \ - d.lo += h.lo; \ - d.hi += h.hi + (d.lo < h.lo); \ - lo = S0lo(a); \ - lo += (tm = Majx(a,b,c,lo)); cy = (lo < tm); \ - h.lo += lo; if (h.lo < lo) cy++; \ - h.hi += cy + S0hi(a) + Majx(a,b,c,hi); \ - DUMP(n,a,d,e,h) \ - } -#endif - -static void -SHA512_Compress(SHA512Context *ctx) -{ -#if defined(IS_LITTLE_ENDIAN) - { -#if defined(HAVE_LONG_LONG) - PRUint64 t1; -#else - PRUint32 t1; -#endif - BYTESWAP8(W[0]); - BYTESWAP8(W[1]); - BYTESWAP8(W[2]); - BYTESWAP8(W[3]); - BYTESWAP8(W[4]); - BYTESWAP8(W[5]); - BYTESWAP8(W[6]); - BYTESWAP8(W[7]); - BYTESWAP8(W[8]); - BYTESWAP8(W[9]); - BYTESWAP8(W[10]); - BYTESWAP8(W[11]); - BYTESWAP8(W[12]); - BYTESWAP8(W[13]); - BYTESWAP8(W[14]); - BYTESWAP8(W[15]); - } -#endif - - { - PRUint64 t1, t2; -#ifdef NOUNROLL512 - { - /* prepare the "message schedule" */ - int t; - for (t = 16; t < 80; ++t) { - INITW(t); - } - } -#else - INITW(16); - INITW(17); - INITW(18); - INITW(19); - - INITW(20); - INITW(21); - INITW(22); - INITW(23); - INITW(24); - INITW(25); - INITW(26); - INITW(27); - INITW(28); - INITW(29); - - INITW(30); - INITW(31); - INITW(32); - INITW(33); - INITW(34); - INITW(35); - INITW(36); - INITW(37); - INITW(38); - INITW(39); - - INITW(40); - INITW(41); - INITW(42); - INITW(43); - INITW(44); - INITW(45); - INITW(46); - INITW(47); - INITW(48); - INITW(49); - - INITW(50); - INITW(51); - INITW(52); - INITW(53); - INITW(54); - INITW(55); - INITW(56); - INITW(57); - INITW(58); - INITW(59); - - INITW(60); - INITW(61); - INITW(62); - INITW(63); - INITW(64); - INITW(65); - INITW(66); - INITW(67); - INITW(68); - INITW(69); - - INITW(70); - INITW(71); - INITW(72); - INITW(73); - INITW(74); - INITW(75); - INITW(76); - INITW(77); - INITW(78); - INITW(79); -#endif - } -#ifdef SHA512_TRACE - { - int i; - for (i = 0; i < 80; ++i) { -#ifdef HAVE_LONG_LONG - printf("W[%2d] = %016lx\n", i, W[i]); -#else - printf("W[%2d] = %08x%08x\n", i, W[i].hi, W[i].lo); -#endif - } - } -#endif - { - PRUint64 a, b, c, d, e, f, g, h; - - a = H[0]; - b = H[1]; - c = H[2]; - d = H[3]; - e = H[4]; - f = H[5]; - g = H[6]; - h = H[7]; - -#ifdef NOUNROLL512 - { - int t; - for (t = 0; t < 80; t+= 8) { - ROUND(t+0,a,b,c,d,e,f,g,h) - ROUND(t+1,h,a,b,c,d,e,f,g) - ROUND(t+2,g,h,a,b,c,d,e,f) - ROUND(t+3,f,g,h,a,b,c,d,e) - ROUND(t+4,e,f,g,h,a,b,c,d) - ROUND(t+5,d,e,f,g,h,a,b,c) - ROUND(t+6,c,d,e,f,g,h,a,b) - ROUND(t+7,b,c,d,e,f,g,h,a) - } - } -#else - ROUND( 0,a,b,c,d,e,f,g,h) - ROUND( 1,h,a,b,c,d,e,f,g) - ROUND( 2,g,h,a,b,c,d,e,f) - ROUND( 3,f,g,h,a,b,c,d,e) - ROUND( 4,e,f,g,h,a,b,c,d) - ROUND( 5,d,e,f,g,h,a,b,c) - ROUND( 6,c,d,e,f,g,h,a,b) - ROUND( 7,b,c,d,e,f,g,h,a) - - ROUND( 8,a,b,c,d,e,f,g,h) - ROUND( 9,h,a,b,c,d,e,f,g) - ROUND(10,g,h,a,b,c,d,e,f) - ROUND(11,f,g,h,a,b,c,d,e) - ROUND(12,e,f,g,h,a,b,c,d) - ROUND(13,d,e,f,g,h,a,b,c) - ROUND(14,c,d,e,f,g,h,a,b) - ROUND(15,b,c,d,e,f,g,h,a) - - ROUND(16,a,b,c,d,e,f,g,h) - ROUND(17,h,a,b,c,d,e,f,g) - ROUND(18,g,h,a,b,c,d,e,f) - ROUND(19,f,g,h,a,b,c,d,e) - ROUND(20,e,f,g,h,a,b,c,d) - ROUND(21,d,e,f,g,h,a,b,c) - ROUND(22,c,d,e,f,g,h,a,b) - ROUND(23,b,c,d,e,f,g,h,a) - - ROUND(24,a,b,c,d,e,f,g,h) - ROUND(25,h,a,b,c,d,e,f,g) - ROUND(26,g,h,a,b,c,d,e,f) - ROUND(27,f,g,h,a,b,c,d,e) - ROUND(28,e,f,g,h,a,b,c,d) - ROUND(29,d,e,f,g,h,a,b,c) - ROUND(30,c,d,e,f,g,h,a,b) - ROUND(31,b,c,d,e,f,g,h,a) - - ROUND(32,a,b,c,d,e,f,g,h) - ROUND(33,h,a,b,c,d,e,f,g) - ROUND(34,g,h,a,b,c,d,e,f) - ROUND(35,f,g,h,a,b,c,d,e) - ROUND(36,e,f,g,h,a,b,c,d) - ROUND(37,d,e,f,g,h,a,b,c) - ROUND(38,c,d,e,f,g,h,a,b) - ROUND(39,b,c,d,e,f,g,h,a) - - ROUND(40,a,b,c,d,e,f,g,h) - ROUND(41,h,a,b,c,d,e,f,g) - ROUND(42,g,h,a,b,c,d,e,f) - ROUND(43,f,g,h,a,b,c,d,e) - ROUND(44,e,f,g,h,a,b,c,d) - ROUND(45,d,e,f,g,h,a,b,c) - ROUND(46,c,d,e,f,g,h,a,b) - ROUND(47,b,c,d,e,f,g,h,a) - - ROUND(48,a,b,c,d,e,f,g,h) - ROUND(49,h,a,b,c,d,e,f,g) - ROUND(50,g,h,a,b,c,d,e,f) - ROUND(51,f,g,h,a,b,c,d,e) - ROUND(52,e,f,g,h,a,b,c,d) - ROUND(53,d,e,f,g,h,a,b,c) - ROUND(54,c,d,e,f,g,h,a,b) - ROUND(55,b,c,d,e,f,g,h,a) - - ROUND(56,a,b,c,d,e,f,g,h) - ROUND(57,h,a,b,c,d,e,f,g) - ROUND(58,g,h,a,b,c,d,e,f) - ROUND(59,f,g,h,a,b,c,d,e) - ROUND(60,e,f,g,h,a,b,c,d) - ROUND(61,d,e,f,g,h,a,b,c) - ROUND(62,c,d,e,f,g,h,a,b) - ROUND(63,b,c,d,e,f,g,h,a) - - ROUND(64,a,b,c,d,e,f,g,h) - ROUND(65,h,a,b,c,d,e,f,g) - ROUND(66,g,h,a,b,c,d,e,f) - ROUND(67,f,g,h,a,b,c,d,e) - ROUND(68,e,f,g,h,a,b,c,d) - ROUND(69,d,e,f,g,h,a,b,c) - ROUND(70,c,d,e,f,g,h,a,b) - ROUND(71,b,c,d,e,f,g,h,a) - - ROUND(72,a,b,c,d,e,f,g,h) - ROUND(73,h,a,b,c,d,e,f,g) - ROUND(74,g,h,a,b,c,d,e,f) - ROUND(75,f,g,h,a,b,c,d,e) - ROUND(76,e,f,g,h,a,b,c,d) - ROUND(77,d,e,f,g,h,a,b,c) - ROUND(78,c,d,e,f,g,h,a,b) - ROUND(79,b,c,d,e,f,g,h,a) -#endif - - ADDTO(a,H[0]); - ADDTO(b,H[1]); - ADDTO(c,H[2]); - ADDTO(d,H[3]); - ADDTO(e,H[4]); - ADDTO(f,H[5]); - ADDTO(g,H[6]); - ADDTO(h,H[7]); - } -} - -void -SHA512_Update(SHA512Context *ctx, const unsigned char *input, - unsigned int inputLen) -{ - unsigned int inBuf; - if (!inputLen) - return; - -#if defined(HAVE_LONG_LONG) - inBuf = (unsigned int)ctx->sizeLo & 0x7f; - /* Add inputLen into the count of bytes processed, before processing */ - ctx->sizeLo += inputLen; -#else - inBuf = (unsigned int)ctx->sizeLo.lo & 0x7f; - ctx->sizeLo.lo += inputLen; - if (ctx->sizeLo.lo < inputLen) ctx->sizeLo.hi++; -#endif - - /* if data already in buffer, attemp to fill rest of buffer */ - if (inBuf) { - unsigned int todo = SHA512_BLOCK_LENGTH - inBuf; - if (inputLen < todo) - todo = inputLen; - memcpy(B + inBuf, input, todo); - input += todo; - inputLen -= todo; - if (inBuf + todo == SHA512_BLOCK_LENGTH) - SHA512_Compress(ctx); - } - - /* if enough data to fill one or more whole buffers, process them. */ - while (inputLen >= SHA512_BLOCK_LENGTH) { - memcpy(B, input, SHA512_BLOCK_LENGTH); - input += SHA512_BLOCK_LENGTH; - inputLen -= SHA512_BLOCK_LENGTH; - SHA512_Compress(ctx); - } - /* if data left over, fill it into buffer */ - if (inputLen) - memcpy(B, input, inputLen); -} - -void -SHA512_End(SHA512Context *ctx, unsigned char *digest, - unsigned int *digestLen, unsigned int maxDigestLen) -{ -#if defined(HAVE_LONG_LONG) - unsigned int inBuf = (unsigned int)ctx->sizeLo & 0x7f; - unsigned int padLen = (inBuf < 112) ? (112 - inBuf) : (112 + 128 - inBuf); - PRUint64 lo, t1; - lo = (ctx->sizeLo << 3); -#else - unsigned int inBuf = (unsigned int)ctx->sizeLo.lo & 0x7f; - unsigned int padLen = (inBuf < 112) ? (112 - inBuf) : (112 + 128 - inBuf); - PRUint64 lo = ctx->sizeLo; - PRUint32 t1; - lo.lo <<= 3; -#endif - - SHA512_Update(ctx, pad, padLen); - -#if defined(HAVE_LONG_LONG) - W[14] = 0; -#else - W[14].lo = 0; - W[14].hi = 0; -#endif - - W[15] = lo; -#if defined(IS_LITTLE_ENDIAN) - BYTESWAP8(W[15]); -#endif - SHA512_Compress(ctx); - - /* now output the answer */ -#if defined(IS_LITTLE_ENDIAN) - BYTESWAP8(H[0]); - BYTESWAP8(H[1]); - BYTESWAP8(H[2]); - BYTESWAP8(H[3]); - BYTESWAP8(H[4]); - BYTESWAP8(H[5]); - BYTESWAP8(H[6]); - BYTESWAP8(H[7]); -#endif - padLen = PR_MIN(SHA512_LENGTH, maxDigestLen); - memcpy(digest, H, padLen); - if (digestLen) - *digestLen = padLen; -} - -SECStatus -SHA512_HashBuf(unsigned char *dest, const unsigned char *src, - uint32 src_length) -{ - SHA512Context ctx; - unsigned int outLen; - - SHA512_Begin(&ctx); - SHA512_Update(&ctx, src, src_length); - SHA512_End(&ctx, dest, &outLen, SHA512_LENGTH); - - return SECSuccess; -} - - -SECStatus -SHA512_Hash(unsigned char *dest, const char *src) -{ - return SHA512_HashBuf(dest, (const unsigned char *)src, PORT_Strlen(src)); -} - - -void SHA512_TraceState(SHA512Context *ctx) { } - -unsigned int -SHA512_FlattenSize(SHA512Context *ctx) -{ - return sizeof *ctx; -} - -SECStatus -SHA512_Flatten(SHA512Context *ctx,unsigned char *space) -{ - PORT_Memcpy(space, ctx, sizeof *ctx); - return SECSuccess; -} - -SHA512Context * -SHA512_Resurrect(unsigned char *space, void *arg) -{ - SHA512Context *ctx = SHA512_NewContext(); - if (ctx) - PORT_Memcpy(ctx, space, sizeof *ctx); - return ctx; -} - -void SHA512_Clone(SHA512Context *dest, SHA512Context *src) -{ - memcpy(dest, src, sizeof *dest); -} - -/* ======================================================================= */ -/* SHA384 uses a SHA512Context as the real context. -** The only differences between SHA384 an SHA512 are: -** a) the intialization values for the context, and -** b) the number of bytes of data produced as output. -*/ - -/* SHA-384 initial hash values */ -static const PRUint64 H384[8] = { -#if PR_BYTES_PER_LONG == 8 - 0xcbbb9d5dc1059ed8UL , 0x629a292a367cd507UL , - 0x9159015a3070dd17UL , 0x152fecd8f70e5939UL , - 0x67332667ffc00b31UL , 0x8eb44a8768581511UL , - 0xdb0c2e0d64f98fa7UL , 0x47b5481dbefa4fa4UL -#else - ULLC(cbbb9d5d,c1059ed8), ULLC(629a292a,367cd507), - ULLC(9159015a,3070dd17), ULLC(152fecd8,f70e5939), - ULLC(67332667,ffc00b31), ULLC(8eb44a87,68581511), - ULLC(db0c2e0d,64f98fa7), ULLC(47b5481d,befa4fa4) -#endif -}; - -SHA384Context * -SHA384_NewContext(void) -{ - return SHA512_NewContext(); -} - -void -SHA384_DestroyContext(SHA384Context *ctx, bool freeit) -{ - SHA512_DestroyContext(ctx, freeit); -} - -void -SHA384_Begin(SHA384Context *ctx) -{ - memset(ctx, 0, sizeof *ctx); - memcpy(H, H384, sizeof H384); -} - -void -SHA384_Update(SHA384Context *ctx, const unsigned char *input, - unsigned int inputLen) -{ - SHA512_Update(ctx, input, inputLen); -} - -void -SHA384_End(SHA384Context *ctx, unsigned char *digest, - unsigned int *digestLen, unsigned int maxDigestLen) -{ -#define SHA_MIN(a,b) (a < b ? a : b) - unsigned int maxLen = SHA_MIN(maxDigestLen, SHA384_LENGTH); - SHA512_End(ctx, digest, digestLen, maxLen); -} - -SECStatus -SHA384_HashBuf(unsigned char *dest, const unsigned char *src, - uint32 src_length) -{ - SHA512Context ctx; - unsigned int outLen; - - SHA384_Begin(&ctx); - SHA512_Update(&ctx, src, src_length); - SHA512_End(&ctx, dest, &outLen, SHA384_LENGTH); - - return SECSuccess; -} - -SECStatus -SHA384_Hash(unsigned char *dest, const char *src) -{ - return SHA384_HashBuf(dest, (const unsigned char *)src, PORT_Strlen(src)); -} - -void SHA384_TraceState(SHA384Context *ctx) { } - -unsigned int -SHA384_FlattenSize(SHA384Context *ctx) -{ - return sizeof(SHA384Context); -} - -SECStatus -SHA384_Flatten(SHA384Context *ctx,unsigned char *space) -{ - return SHA512_Flatten(ctx, space); -} - -SHA384Context * -SHA384_Resurrect(unsigned char *space, void *arg) -{ - return SHA512_Resurrect(space, arg); -} - -void SHA384_Clone(SHA384Context *dest, SHA384Context *src) -{ - memcpy(dest, src, sizeof *dest); -} -#endif /* Comment out unused code. */ - -} // namespace nss - -/* ======================================================================= */ -#ifdef SELFTEST -#include - -using namespace nss; - -static const char abc[] = { "abc" }; -static const char abcdbc[] = { - "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" -}; -static const char abcdef[] = { - "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn" - "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu" -}; - -void -dumpHash32(const unsigned char *buf, unsigned int bufLen) -{ - unsigned int i; - for (i = 0; i < bufLen; i += 4) { - printf(" %02x%02x%02x%02x", buf[i], buf[i+1], buf[i+2], buf[i+3]); - } - printf("\n"); -} - -void test256(void) -{ - unsigned char outBuf[SHA256_LENGTH]; - - printf("SHA256, input = %s\n", abc); - SHA256_Hash(outBuf, abc); - dumpHash32(outBuf, sizeof outBuf); - - printf("SHA256, input = %s\n", abcdbc); - SHA256_Hash(outBuf, abcdbc); - dumpHash32(outBuf, sizeof outBuf); -} - -void -dumpHash64(const unsigned char *buf, unsigned int bufLen) -{ - unsigned int i; - for (i = 0; i < bufLen; i += 8) { - if (i % 32 == 0) - printf("\n"); - printf(" %02x%02x%02x%02x%02x%02x%02x%02x", - buf[i ], buf[i+1], buf[i+2], buf[i+3], - buf[i+4], buf[i+5], buf[i+6], buf[i+7]); - } - printf("\n"); -} - -void test512(void) -{ - unsigned char outBuf[SHA512_LENGTH]; - - printf("SHA512, input = %s\n", abc); - SHA512_Hash(outBuf, abc); - dumpHash64(outBuf, sizeof outBuf); - - printf("SHA512, input = %s\n", abcdef); - SHA512_Hash(outBuf, abcdef); - dumpHash64(outBuf, sizeof outBuf); -} - -void time512(void) -{ - unsigned char outBuf[SHA512_LENGTH]; - - SHA512_Hash(outBuf, abc); - SHA512_Hash(outBuf, abcdef); -} - -void test384(void) -{ - unsigned char outBuf[SHA384_LENGTH]; - - printf("SHA384, input = %s\n", abc); - SHA384_Hash(outBuf, abc); - dumpHash64(outBuf, sizeof outBuf); - - printf("SHA384, input = %s\n", abcdef); - SHA384_Hash(outBuf, abcdef); - dumpHash64(outBuf, sizeof outBuf); -} - -int main (int argc, char *argv[], char *envp[]) -{ - int i = 1; - if (argc > 1) { - i = atoi(argv[1]); - } - if (i < 2) { - test256(); - test512(); - test384(); - } else { - while (i-- > 0) { - time512(); - } - printf("done\n"); - } - return 0; -} - -#endif From 684f03fbb86db1f3df8bbe9501762bf3fda65e58 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Thu, 15 Dec 2011 23:26:42 +1300 Subject: [PATCH 15/26] Bug 687972. Ignore closed streams when computing whether all streams for the resource are suspended. r=cpearce --- content/media/nsMediaCache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/media/nsMediaCache.cpp b/content/media/nsMediaCache.cpp index 7af430bd6a9c..4ecaa8a8bd92 100644 --- a/content/media/nsMediaCache.cpp +++ b/content/media/nsMediaCache.cpp @@ -1913,7 +1913,7 @@ nsMediaCacheStream::AreAllStreamsForResourceSuspended(nsMediaStream** aActiveStr ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor()); nsMediaCache::ResourceStreamIterator iter(mResourceID); while (nsMediaCacheStream* stream = iter.Next()) { - if (!stream->mCacheSuspended && !stream->mChannelEnded) { + if (!stream->mCacheSuspended && !stream->mChannelEnded && !stream->mClosed) { if (aActiveStream) { *aActiveStream = stream->mClient; } From 0400aab29432f817b21a3fc3e36a5a3619dc8b76 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Thu, 15 Dec 2011 23:26:42 +1300 Subject: [PATCH 16/26] Bug 687972. Remove logging that we added to hunt down the bug. --- content/media/nsBuiltinDecoder.cpp | 1 - content/media/nsMediaStream.cpp | 8 -------- 2 files changed, 9 deletions(-) diff --git a/content/media/nsBuiltinDecoder.cpp b/content/media/nsBuiltinDecoder.cpp index 813a457ef196..c6e4ac368d08 100644 --- a/content/media/nsBuiltinDecoder.cpp +++ b/content/media/nsBuiltinDecoder.cpp @@ -647,7 +647,6 @@ void nsBuiltinDecoder::NotifySuspendedStatusChanged() nsMediaStream* activeStream; bool suspended = mStream->IsSuspendedByCache(&activeStream); - printf("*** nsBuiltinDecoder::NotifySuspendedStatusChanged(%p), suspended=%d, active-stream=%p\n", this, suspended, activeStream); if (suspended && mElement) { // if this is an autoplay element, we need to kick off its autoplaying // now so we consume data and hopefully free up cache space diff --git a/content/media/nsMediaStream.cpp b/content/media/nsMediaStream.cpp index 9993727db6c9..6961e7a23ecb 100644 --- a/content/media/nsMediaStream.cpp +++ b/content/media/nsMediaStream.cpp @@ -751,8 +751,6 @@ private: void nsMediaChannelStream::CacheClientNotifyDataEnded(nsresult aStatus) { - printf("*** nsMediaChannelStream::CacheClientNotifyDataEnded() mDecoder=%p\n", mDecoder); - NS_ASSERTION(NS_IsMainThread(), "Don't call on non-main thread"); // NOTE: this can be called with the media cache lock held, so don't // block or do anything which might try to acquire a lock! @@ -766,8 +764,6 @@ nsMediaChannelStream::CacheClientSeek(PRInt64 aOffset, bool aResume) { NS_ASSERTION(NS_IsMainThread(), "Don't call on non-main thread"); - printf("*** nsMediaChannelStream::CacheClientSeek() mDecoder=%p aOffset=%lld aResume = %d\n", mDecoder, (long long)aOffset, aResume); - CloseChannel(); if (aResume) { @@ -787,8 +783,6 @@ nsMediaChannelStream::CacheClientSeek(PRInt64 aOffset, bool aResume) nsresult nsMediaChannelStream::CacheClientSuspend() { - printf("*** nsMediaChannelStream::CacheClientSuspend() mDecoder=%p\n", mDecoder); - Suspend(false); mDecoder->NotifySuspendedStatusChanged(); @@ -798,8 +792,6 @@ nsMediaChannelStream::CacheClientSuspend() nsresult nsMediaChannelStream::CacheClientResume() { - printf("*** nsMediaChannelStream::CacheClientResume() mDecoder=%p\n", mDecoder); - Resume(); mDecoder->NotifySuspendedStatusChanged(); From 02ec6567dfe65d92677386eb8044d0e5ff41eb2d Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Thu, 15 Dec 2011 23:26:42 +1300 Subject: [PATCH 17/26] Bug 708109. Remove THEBES_INLINE_DECL_THREADSAFE_REFCOUNTING in favour of NS_ version. r=joe --- gfx/gl/GLContext.h | 2 +- gfx/layers/ImageLayers.h | 5 +++-- gfx/layers/opengl/ImageLayerOGL.h | 2 +- gfx/thebes/gfxTypes.h | 23 ----------------------- 4 files changed, 5 insertions(+), 27 deletions(-) diff --git a/gfx/gl/GLContext.h b/gfx/gl/GLContext.h index e465ee3d8975..3f160818185e 100644 --- a/gfx/gl/GLContext.h +++ b/gfx/gl/GLContext.h @@ -527,7 +527,7 @@ struct THEBES_API ContextFormat class GLContext : public LibrarySymbolLoader { - THEBES_INLINE_DECL_THREADSAFE_REFCOUNTING(GLContext) + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GLContext) public: GLContext(const ContextFormat& aFormat, bool aIsOffscreen = false, diff --git a/gfx/layers/ImageLayers.h b/gfx/layers/ImageLayers.h index c5e88a8490c7..3aef7527b521 100644 --- a/gfx/layers/ImageLayers.h +++ b/gfx/layers/ImageLayers.h @@ -40,6 +40,7 @@ #include "Layers.h" +#include "nsISupportsImpl.h" #include "gfxPattern.h" #include "nsThreadUtils.h" #include "mozilla/ReentrantMonitor.h" @@ -74,7 +75,7 @@ enum StereoMode { * sampled. For example, cairo images should be sampled in EXTEND_PAD mode. */ class THEBES_API Image { - THEBES_INLINE_DECL_THREADSAFE_REFCOUNTING(Image) + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(Image) public: virtual ~Image() {} @@ -132,7 +133,7 @@ protected: * video playback without involving the main thread, for example. */ class THEBES_API ImageContainer { - THEBES_INLINE_DECL_THREADSAFE_REFCOUNTING(ImageContainer) + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ImageContainer) public: ImageContainer() : diff --git a/gfx/layers/opengl/ImageLayerOGL.h b/gfx/layers/opengl/ImageLayerOGL.h index 1b3f9d0069c7..55ea130cc6ac 100644 --- a/gfx/layers/opengl/ImageLayerOGL.h +++ b/gfx/layers/opengl/ImageLayerOGL.h @@ -97,7 +97,7 @@ private: * reference loop between an ImageContainerOGL and its active image. */ class RecycleBin { - THEBES_INLINE_DECL_THREADSAFE_REFCOUNTING(RecycleBin) + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RecycleBin) typedef mozilla::gl::GLContext GLContext; diff --git a/gfx/thebes/gfxTypes.h b/gfx/thebes/gfxTypes.h index 2563ab71fa2d..e12611cb6315 100644 --- a/gfx/thebes/gfxTypes.h +++ b/gfx/thebes/gfxTypes.h @@ -89,27 +89,4 @@ enum gfxBreakPriority { eNormalBreak }; -#define THEBES_INLINE_DECL_THREADSAFE_REFCOUNTING(_class) \ -public: \ - nsrefcnt AddRef(void) { \ - NS_PRECONDITION(PRInt32(mRefCnt) >= 0, "illegal refcnt"); \ - nsrefcnt count = NS_AtomicIncrementRefcnt(mRefCnt); \ - NS_LOG_ADDREF(this, count, #_class, sizeof(*this)); \ - return count; \ - } \ - nsrefcnt Release(void) { \ - NS_PRECONDITION(0 != mRefCnt, "dup release"); \ - nsrefcnt count = NS_AtomicDecrementRefcnt(mRefCnt); \ - NS_LOG_RELEASE(this, count, #_class); \ - if (count == 0) { \ - mRefCnt = 1; /* stabilize */ \ - delete this; \ - return 0; \ - } \ - return count; \ - } \ -protected: \ - nsAutoRefCnt mRefCnt; \ -public: - #endif /* GFX_TYPES_H */ From ed5855c04cdd5463293c49ec8619a03068bfcc16 Mon Sep 17 00:00:00 2001 From: Joel Maher Date: Thu, 15 Dec 2011 07:41:40 -0500 Subject: [PATCH 18/26] Bug 705967 - reftest assumes we are loaded in a window and have direct access to a document. r=dbaron --- layout/tools/reftest/reftest.js | 44 +++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/layout/tools/reftest/reftest.js b/layout/tools/reftest/reftest.js index 5d7d8caeaa8e..6ff2e82370e9 100644 --- a/layout/tools/reftest/reftest.js +++ b/layout/tools/reftest/reftest.js @@ -68,6 +68,7 @@ var gRemote = false; var gIgnoreWindowSize = false; var gTotalChunks = 0; var gThisChunk = 0; +var gContainingWindow = null; // "" const BLANK_URL_FOR_CLEARING = "data:text/html,%3C%21%2D%2DCLEAR%2D%2D%3E"; @@ -189,12 +190,10 @@ function FlushTestLog() function AllocateCanvas() { - var windowElem = document.documentElement; - if (gRecycledCanvases.length > 0) return gRecycledCanvases.shift(); - var canvas = document.createElementNS(XHTML_NS, "canvas"); + var canvas = gContainingWindow.document.createElementNS(XHTML_NS, "canvas"); var r = gBrowser.getBoundingClientRect(); canvas.setAttribute("width", Math.ceil(r.width)); canvas.setAttribute("height", Math.ceil(r.height)); @@ -236,8 +235,12 @@ function OnRefTestLoad() } catch (e) { gBrowserIsRemote = false; } + + if (gContainingWindow == null && window != null) { + gContainingWindow = window; + } - gBrowser = document.createElementNS(XUL_NS, "xul:browser"); + gBrowser = gContainingWindow.document.createElementNS(XUL_NS, "xul:browser"); gBrowser.setAttribute("id", "browser"); gBrowser.setAttribute("type", "content-primary"); gBrowser.setAttribute("remote", gBrowserIsRemote ? "true" : "false"); @@ -310,15 +313,13 @@ function InitAndStartRefTests() } try { - gWindowUtils = window.QueryInterface(CI.nsIInterfaceRequestor).getInterface(CI.nsIDOMWindowUtils); + gWindowUtils = gContainingWindow.QueryInterface(CI.nsIInterfaceRequestor).getInterface(CI.nsIDOMWindowUtils); if (gWindowUtils && !gWindowUtils.compareCanvases) gWindowUtils = null; } catch (e) { gWindowUtils = null; } - var windowElem = document.documentElement; - gIOService = CC[IO_SERVICE_CONTRACTID].getService(CI.nsIIOService); gDebug = CC[DEBUG_CONTRACTID].getService(CI.nsIDebug2); @@ -471,6 +472,8 @@ function BuildConditionSandbox(aURL) { // see if we have the test plugin available, // and set a sandox prop accordingly sandbox.haveTestPlugin = false; + + var navigator = gContainingWindow.navigator; for (var i = 0; i < navigator.mimeTypes.length; i++) { if (navigator.mimeTypes[i].type == "application/x-test" && navigator.mimeTypes[i].enabledPlugin != null && @@ -481,11 +484,11 @@ function BuildConditionSandbox(aURL) { } // Set a flag on sandbox if the windows default theme is active - var box = document.createElement("box"); + var box = gContainingWindow.document.createElement("box"); box.setAttribute("id", "_box_windowsDefaultTheme"); - document.documentElement.appendChild(box); - sandbox.windowsDefaultTheme = (getComputedStyle(box, null).display == "none"); - document.documentElement.removeChild(box); + gContainingWindow.document.documentElement.appendChild(box); + sandbox.windowsDefaultTheme = (gContainingWindow.getComputedStyle(box, null).display == "none"); + gContainingWindow.document.documentElement.removeChild(box); var prefs = CC["@mozilla.org/preferences-service;1"]. getService(CI.nsIPrefBranch2); @@ -506,7 +509,10 @@ function BuildConditionSandbox(aURL) { } sandbox.testPluginIsOOP = function () { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + try { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + } catch (ex) {} + var prefservice = Components.classes["@mozilla.org/preferences-service;1"] .getService(CI.nsIPrefBranch); @@ -883,7 +889,7 @@ function Focus() } var fm = CC["@mozilla.org/focus-manager;1"].getService(CI.nsIFocusManager); - fm.activeWindow = window; + fm.activeWindow = gContainingWindow; try { var dock = CC["@mozilla.org/widget/macdocksupport;1"].getService(CI.nsIMacDockSupport); dock.activateApplication(true); @@ -921,7 +927,7 @@ function StartCurrentTest() } else { var currentTest = gTotalTests - gURLs.length; - document.title = "reftest: " + currentTest + " / " + gTotalTests + + gContainingWindow.document.title = "reftest: " + currentTest + " / " + gTotalTests + " (" + Math.floor(100 * (currentTest / gTotalTests)) + "%)"; StartCurrentURI(1); } @@ -938,7 +944,7 @@ function StartCurrentURI(aState) gURLs[0].maxAsserts == 0) { // Pretend the document loaded --- RecordResult will notice // there's already a canvas for this URL - setTimeout(RecordResult, 0); + gContainingWindow.setTimeout(RecordResult, 0); } else { var currentTest = gTotalTests - gURLs.length; gDumpLog("REFTEST TEST-START | " + gCurrentURL + " | " + currentTest + " / " + gTotalTests + @@ -1023,8 +1029,8 @@ function DoDrawWindow(ctx, x, y, w, h) if (gIgnoreWindowSize || (0 <= testRect.left && 0 <= testRect.top && - window.innerWidth >= testRect.right && - window.innerHeight >= testRect.bottom)) { + gContainingWindow.innerWidth >= testRect.right && + gContainingWindow.innerHeight >= testRect.bottom)) { // We can use the window's retained layer manager // because the window is big enough to display the entire // browser element @@ -1046,13 +1052,13 @@ function DoDrawWindow(ctx, x, y, w, h) gDumpLog("REFTEST INFO | WARNING: USE_WIDGET_LAYERS disabled\n"); } gDumpLog("REFTEST INFO | drawWindow flags = " + flagsStr + - "; window size = " + window.innerWidth + "," + window.innerHeight + + "; window size = " + gContainingWindow.innerWidth + "," + gContainingWindow.innerHeight + "; test browser size = " + testRect.width + "," + testRect.height + "\n"); } LogInfo("DoDrawWindow " + x + "," + y + "," + w + "," + h); - ctx.drawWindow(window, x, y, w, h, "rgb(255,255,255)", + ctx.drawWindow(gContainingWindow, x, y, w, h, "rgb(255,255,255)", gDrawWindowFlags); } From 4e091e58c0e124ed46f33439535d9316c57e4612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?= Date: Thu, 15 Dec 2011 08:37:05 -0500 Subject: [PATCH 19/26] Bug 710708 - Finalize statement. r=mak. --- .../tests/migration/test_database_from_v6_no_frecency.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/toolkit/components/places/tests/migration/test_database_from_v6_no_frecency.js b/toolkit/components/places/tests/migration/test_database_from_v6_no_frecency.js index 005193873bcf..dba00a8b69bf 100644 --- a/toolkit/components/places/tests/migration/test_database_from_v6_no_frecency.js +++ b/toolkit/components/places/tests/migration/test_database_from_v6_no_frecency.js @@ -10,7 +10,8 @@ add_test(function database_is_valid() { do_check_eq(PlacesUtils.history.databaseStatus, PlacesUtils.history.DATABASE_STATUS_UPGRADED); // This throws if frecency column does not exist. - DBConn().createStatement("SELECT frecency from moz_places"); + stmt = DBConn().createStatement("SELECT frecency from moz_places"); + stmt.finalize(); // Check moz_inputhistory is in place. do_check_true(DBConn().tableExists("moz_inputhistory")); run_next_test(); From 08c0b654f9ed30ec2f9a150d374f85524417797a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?= Date: Thu, 15 Dec 2011 08:42:48 -0500 Subject: [PATCH 20/26] Bug 710723. Finalize statement. r=mak. --- toolkit/components/places/nsPlacesAutoComplete.js | 1 + 1 file changed, 1 insertion(+) diff --git a/toolkit/components/places/nsPlacesAutoComplete.js b/toolkit/components/places/nsPlacesAutoComplete.js index 7bac60d4b858..88e9dc9f92ae 100644 --- a/toolkit/components/places/nsPlacesAutoComplete.js +++ b/toolkit/components/places/nsPlacesAutoComplete.js @@ -264,6 +264,7 @@ function nsPlacesAutoComplete() } stmt.bindParameters(params); stmt.executeAsync(); + stmt.finalize(); delete this._openPagesCache; } From d7c7b61b9fc85dab4e4fd28b7b01124bdfc09775 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 15 Dec 2011 08:53:06 -0500 Subject: [PATCH 21/26] Bug 709384. Manage our scheduled state better when animation frame requests are canceled. r=roc --- content/base/crashtests/709384.html | 5 +++++ content/base/crashtests/crashtests.list | 1 + content/base/src/nsDocument.cpp | 11 ++++++----- 3 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 content/base/crashtests/709384.html diff --git a/content/base/crashtests/709384.html b/content/base/crashtests/709384.html new file mode 100644 index 000000000000..9f268a17d7f5 --- /dev/null +++ b/content/base/crashtests/709384.html @@ -0,0 +1,5 @@ + + diff --git a/content/base/crashtests/crashtests.list b/content/base/crashtests/crashtests.list index 3303d6bae28d..2c794d672690 100644 --- a/content/base/crashtests/crashtests.list +++ b/content/base/crashtests/crashtests.list @@ -102,3 +102,4 @@ load 700090-1.html load 700090-2.html load 700512.html load xhr_html_nullresponse.html +load 709384.html diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 96552ba20410..3a5845047dca 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -8095,11 +8095,12 @@ void nsIDocument::CancelFrameRequestCallback(PRInt32 aHandle) { // mFrameRequestCallbacks is stored sorted by handle - mFrameRequestCallbacks.RemoveElementSorted(aHandle); - - // Not going to worry about unscheduling our refresh driver - // callback. It'll just be a no-op when it happens, if we have no - // more frame request callbacks. + if (mFrameRequestCallbacks.RemoveElementSorted(aHandle) && + mFrameRequestCallbacks.IsEmpty() && + mPresShell && IsEventHandlingEnabled()) { + mPresShell->GetPresContext()->RefreshDriver()-> + RevokeFrameRequestCallbacks(this); + } } nsresult From 98ad98b225e928c55fb9b664f063e5c6bd41422b Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 15 Dec 2011 08:53:06 -0500 Subject: [PATCH 22/26] Bug 708169. Warn when null or no argument is passed to mozRequestAnimationFrame. r=roc --- content/base/public/nsDeprecatedOperationList.h | 1 + dom/base/nsGlobalWindow.cpp | 1 + dom/interfaces/base/nsIDOMWindow.idl | 3 ++- dom/locales/en-US/chrome/dom/dom.properties | 2 ++ 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/content/base/public/nsDeprecatedOperationList.h b/content/base/public/nsDeprecatedOperationList.h index 9b4c141eda22..501044649104 100644 --- a/content/base/public/nsDeprecatedOperationList.h +++ b/content/base/public/nsDeprecatedOperationList.h @@ -75,3 +75,4 @@ DEPRECATED_OPERATION(Position) DEPRECATED_OPERATION(TotalSize) DEPRECATED_OPERATION(GlobalStorage) DEPRECATED_OPERATION(InputEncoding) +DEPRECATED_OPERATION(MozBeforePaint) diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index e66295ecfeb9..e2169f80847a 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -3885,6 +3885,7 @@ nsGlobalWindow::MozRequestAnimationFrame(nsIFrameRequestCallback* aCallback, } if (!aCallback) { + mDoc->WarnOnceAbout(nsIDocument::eMozBeforePaint); return NS_ERROR_XPC_BAD_CONVERT_JS; } diff --git a/dom/interfaces/base/nsIDOMWindow.idl b/dom/interfaces/base/nsIDOMWindow.idl index dcc23c04719a..770f5ac469c7 100644 --- a/dom/interfaces/base/nsIDOMWindow.idl +++ b/dom/interfaces/base/nsIDOMWindow.idl @@ -417,8 +417,9 @@ interface nsIDOMWindow : nsISupports * * @see */ + // Argument is optional only so we can warn when it's null long - mozRequestAnimationFrame(in nsIFrameRequestCallback aCallback); + mozRequestAnimationFrame([optional] in nsIFrameRequestCallback aCallback); /** * Cancel a refresh callback. diff --git a/dom/locales/en-US/chrome/dom/dom.properties b/dom/locales/en-US/chrome/dom/dom.properties index d21801d4f6a5..59d286057ac0 100644 --- a/dom/locales/en-US/chrome/dom/dom.properties +++ b/dom/locales/en-US/chrome/dom/dom.properties @@ -115,6 +115,8 @@ nsIJSONEncodeDeprecatedWarning=nsIJSON.encode is deprecated. Please use JSON.st nsIDOMWindowInternalWarning=Use of nsIDOMWindowInternal is deprecated. Use nsIDOMWindow instead. InputEncodingWarning=Use of inputEncoding is deprecated. GlobalStorageWarning=Use of globalStorage is deprecated. Please use localStorage instead. +# LOCALIZATION NOTE: Do not translate "MozBeforePaint" and "mozRequestAnimationFrame" +MozBeforePaintWarning=MozBeforePaint events are no longer supported. mozRequestAnimationFrame must be passed a non-null callback argument. FullScreenDeniedDisabled=Request for full-screen was denied because full-screen API is disabled by user preference. FullScreenDeniedPlugins=Request for full-screen was denied because a document on this page contains a windowed plugin. FullScreenDeniedHidden=Request for full-screen was denied because the document is no longer visible. From 047b6669c7733836c713e8b2671db80e725a7cca Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 15 Dec 2011 08:53:06 -0500 Subject: [PATCH 23/26] Bug 710981. Add the new name for cancelAnimationFrame. r=roc --- content/base/test/test_bug647518.html | 2 +- dom/base/nsGlobalWindow.cpp | 8 +++++++- dom/interfaces/base/nsIDOMWindow.idl | 4 +++- toolkit/content/widgets/scrollbox.xml | 4 ++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/content/base/test/test_bug647518.html b/content/base/test/test_bug647518.html index 03bc169b002a..29030d36f713 100644 --- a/content/base/test/test_bug647518.html +++ b/content/base/test/test_bug647518.html @@ -37,7 +37,7 @@ function checker() { } } window.mozRequestAnimationFrame(checker); -window.mozCancelRequestAnimationFrame(handle1); +window.mozCancelAnimationFrame(handle1); diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index e2169f80847a..8c96b2e5c685 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -3895,7 +3895,13 @@ nsGlobalWindow::MozRequestAnimationFrame(nsIFrameRequestCallback* aCallback, NS_IMETHODIMP nsGlobalWindow::MozCancelRequestAnimationFrame(PRInt32 aHandle) { - FORWARD_TO_INNER(MozCancelRequestAnimationFrame, (aHandle), + return MozCancelAnimationFrame(aHandle); +} + +NS_IMETHODIMP +nsGlobalWindow::MozCancelAnimationFrame(PRInt32 aHandle) +{ + FORWARD_TO_INNER(MozCancelAnimationFrame, (aHandle), NS_ERROR_NOT_INITIALIZED); if (!mDoc) { diff --git a/dom/interfaces/base/nsIDOMWindow.idl b/dom/interfaces/base/nsIDOMWindow.idl index 770f5ac469c7..980e3e8c52a1 100644 --- a/dom/interfaces/base/nsIDOMWindow.idl +++ b/dom/interfaces/base/nsIDOMWindow.idl @@ -70,7 +70,7 @@ interface nsIDOMMozURLProperty : nsISupports * @see */ -[scriptable, uuid(973e7219-40d5-4f94-b78d-53c2a0b8a13c)] +[scriptable, uuid(f6e3b10d-d5f4-4fcd-aa4c-5f98626d428a)] interface nsIDOMWindow : nsISupports { // the current browsing context @@ -424,6 +424,8 @@ interface nsIDOMWindow : nsISupports /** * Cancel a refresh callback. */ + void mozCancelAnimationFrame(in long aHandle); + // Backwards-compat shim for now to make Google maps work void mozCancelRequestAnimationFrame(in long aHandle); /** diff --git a/toolkit/content/widgets/scrollbox.xml b/toolkit/content/widgets/scrollbox.xml index e38469c85dae..28b82515db16 100644 --- a/toolkit/content/widgets/scrollbox.xml +++ b/toolkit/content/widgets/scrollbox.xml @@ -283,7 +283,7 @@ this.requestHandle = window.mozRequestAnimationFrame(this); }, stop: function scrollAnim_stop() { - window.mozCancelRequestAnimationFrame(this.requestHandle); + window.mozCancelAnimationFrame(this.requestHandle); this.requestHandle = 0; }, sample: function scrollAnim_handleEvent(timeStamp) { @@ -648,7 +648,7 @@ this.requestHandle = window.mozRequestAnimationFrame(this); }, stop: function arrowSmoothScroll_stop() { - window.mozCancelRequestAnimationFrame(this.requestHandle); + window.mozCancelAnimationFrame(this.requestHandle); this.requestHandle = 0; }, sample: function arrowSmoothScroll_handleEvent(timeStamp) { From 919fdf2cf1319842d9e4dd145e4bf47cfb83cb92 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Thu, 15 Dec 2011 10:46:36 -0500 Subject: [PATCH 24/26] Bug 702624 - Fix regex for replaceAll so it doesn't die. r=blassey --- mobile/android/base/CrashReporter.java.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobile/android/base/CrashReporter.java.in b/mobile/android/base/CrashReporter.java.in index 8498808836d0..880c06e26e7d 100644 --- a/mobile/android/base/CrashReporter.java.in +++ b/mobile/android/base/CrashReporter.java.in @@ -331,6 +331,6 @@ public class CrashReporter extends Activity } private String unescape(String string) { - return string.replaceAll("\\\\", "\\").replaceAll("\\n", "\n").replaceAll("\\t", "\t"); + return string.replaceAll("\\\\\\\\", "\\").replaceAll("\\\\n", "\n").replaceAll("\\\\t", "\t"); } } From 352c9162cb9cb77129e33b62e490ff9978be6b7d Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Thu, 15 Dec 2011 10:46:36 -0500 Subject: [PATCH 25/26] Bug 710864 - Close stream after we're done with it. r=blassey --- mobile/android/base/AboutHomeContent.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/mobile/android/base/AboutHomeContent.java b/mobile/android/base/AboutHomeContent.java index 96b3771dddb9..b51e2a9d0e5d 100644 --- a/mobile/android/base/AboutHomeContent.java +++ b/mobile/android/base/AboutHomeContent.java @@ -42,6 +42,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; +import java.io.IOException; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -253,9 +254,19 @@ public class AboutHomeContent extends ScrollView { if (fileStream == null) return; StringBuffer jsonString = new StringBuffer(); - int read = 0; - while ((read = fileStream.read(buf, 0, 32768)) != -1) { - jsonString.append(new String(buf, 0, read)); + try { + int read = 0; + while ((read = fileStream.read(buf, 0, 32768)) != -1) { + jsonString.append(new String(buf, 0, read)); + } + } finally { + try { + fileStream.close(); + } catch (IOException ioe) { + // catch this here because we can continue even if the + // close failed + Log.i(LOGTAG, "error closing json file", ioe); + } } final JSONArray array = new JSONObject(jsonString.toString()).getJSONArray("addons"); GeckoApp.mAppContext.mMainHandler.post(new Runnable() { From a0b7a9c911e741b81bbc292c3a89b37c670ceba8 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Thu, 15 Dec 2011 10:46:36 -0500 Subject: [PATCH 26/26] Bug 710864 - (Cleanup) Fix up incorrect logtags. r=blassey --- mobile/android/base/AboutHomeContent.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mobile/android/base/AboutHomeContent.java b/mobile/android/base/AboutHomeContent.java index b51e2a9d0e5d..f064d1ebd371 100644 --- a/mobile/android/base/AboutHomeContent.java +++ b/mobile/android/base/AboutHomeContent.java @@ -275,15 +275,15 @@ public class AboutHomeContent extends ScrollView { for (int i = 0; i < array.length(); i++) { JSONObject jsonobj = array.getJSONObject(i); mAddonsAdapter.add(jsonobj.getString("name")); - Log.i("GeckoAddons", "addon #" + i +": " + jsonobj.getString("name")); + Log.i(LOGTAG, "addon #" + i +": " + jsonobj.getString("name")); } } catch (Exception e) { - Log.i("GeckoAddons", "error reading json file", e); + Log.i(LOGTAG, "error reading json file", e); } } }); } catch (Exception e) { - Log.i("GeckoAddons", "error reading json file", e); + Log.i(LOGTAG, "error reading json file", e); } } });