Bug 689598: implement Android gfx blocklisting r=joe

Also includes changes to support using the "driver version" field as the Android
SDK version.
This commit is contained in:
Doug Sherk 2011-12-14 21:03:03 -08:00
Родитель 44ee4e573e
Коммит 778e94f157
4 изменённых файлов: 53 добавлений и 56 удалений

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -100,6 +100,11 @@ private:
nsString mDriverDate;
nsString mDeviceKey;
nsString mAdapterDeviceID;
nsString mAdapterVendorID;
nsString mAdapterDescription;
PRInt32 mAndroidSDKVersion;
PRUint32 mRendererIDs[16];
};

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -664,7 +664,7 @@ GfxInfoBase::FindBlocklistedDeviceInList(const nsTArray<GfxDriverInfo>& 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<GfxDriverInfo>& info,
match = true;
#endif
if (match) {
if (match || info[i].mDriverVersion == GfxDriverInfo::allDriverVersions) {
if (info[i].mFeature == GfxDriverInfo::allFeatures ||
info[i].mFeature == aFeature)
{