Skip to content

Commit

Permalink
Bug 1274635: Have OperatingSystem an enum class, change All to mean A…
Browse files Browse the repository at this point in the history
…ll Windows. r=BenWa

MozReview-Commit-ID: ADe4EmPzTuc

--HG--
extra : rebase_source : c3a7ee2846935291297f51cb1898ec46543a6870
  • Loading branch information
msreckovic committed Jun 3, 2016
1 parent 7d36f32 commit d5f46d2
Show file tree
Hide file tree
Showing 8 changed files with 190 additions and 154 deletions.
2 changes: 1 addition & 1 deletion widget/GfxDriverInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ GfxDeviceFamily* GfxDriverInfo::mDeviceFamilies[DeviceFamilyMax];
nsAString* GfxDriverInfo::mDeviceVendors[DeviceVendorMax];

GfxDriverInfo::GfxDriverInfo()
: mOperatingSystem(DRIVER_OS_UNKNOWN),
: mOperatingSystem(OperatingSystem::Unknown),
mOperatingSystemVersion(0),
mAdapterVendor(GfxDriverInfo::GetDeviceVendor(VendorAll)),
mDevices(allDevices),
Expand Down
43 changes: 23 additions & 20 deletions widget/GfxDriverInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,27 @@
namespace mozilla {
namespace widget {

enum OperatingSystem {
DRIVER_OS_UNKNOWN = 0,
DRIVER_OS_WINDOWS_XP,
DRIVER_OS_WINDOWS_SERVER_2003,
DRIVER_OS_WINDOWS_VISTA,
DRIVER_OS_WINDOWS_7,
DRIVER_OS_WINDOWS_8,
DRIVER_OS_WINDOWS_8_1,
DRIVER_OS_WINDOWS_10,
DRIVER_OS_LINUX,
DRIVER_OS_OS_X_10_5,
DRIVER_OS_OS_X_10_6,
DRIVER_OS_OS_X_10_7,
DRIVER_OS_OS_X_10_8,
DRIVER_OS_OS_X_10_9,
DRIVER_OS_OS_X_10_10,
DRIVER_OS_OS_X_10_11,
DRIVER_OS_ANDROID,
DRIVER_OS_IOS,
DRIVER_OS_ALL
enum class OperatingSystem {
Unknown,
Windows,
WindowsXP,
WindowsServer2003,
WindowsVista,
Windows7,
Windows8,
Windows8_1,
Windows10,
Linux,
OSX,
OSX10_5,
OSX10_6,
OSX10_7,
OSX10_8,
OSX10_9,
OSX10_10,
OSX10_11,
Android,
Ios
};

enum VersionComparisonOp {
Expand Down Expand Up @@ -277,11 +278,13 @@ ParseDriverVersion(const nsAString& aVersion, uint64_t *aNumericVersion)
if (d < 0 || d > 0xffff) return false;

*aNumericVersion = GFX_DRIVER_VERSION(a, b, c, d);
MOZ_ASSERT(*aNumericVersion != GfxDriverInfo::allDriverVersions);
return true;
#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());
MOZ_ASSERT(*aNumericVersion != GfxDriverInfo::allDriverVersions);
return true;
#else
return false;
Expand Down
90 changes: 59 additions & 31 deletions widget/GfxInfoBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,44 +245,42 @@ static OperatingSystem
BlacklistOSToOperatingSystem(const nsAString& os)
{
if (os.EqualsLiteral("WINNT 5.1"))
return DRIVER_OS_WINDOWS_XP;
return OperatingSystem::WindowsXP;
else if (os.EqualsLiteral("WINNT 5.2"))
return DRIVER_OS_WINDOWS_SERVER_2003;
return OperatingSystem::WindowsServer2003;
else if (os.EqualsLiteral("WINNT 6.0"))
return DRIVER_OS_WINDOWS_VISTA;
return OperatingSystem::WindowsVista;
else if (os.EqualsLiteral("WINNT 6.1"))
return DRIVER_OS_WINDOWS_7;
return OperatingSystem::Windows7;
else if (os.EqualsLiteral("WINNT 6.2"))
return DRIVER_OS_WINDOWS_8;
return OperatingSystem::Windows8;
else if (os.EqualsLiteral("WINNT 6.3"))
return DRIVER_OS_WINDOWS_8_1;
return OperatingSystem::Windows8_1;
else if (os.EqualsLiteral("WINNT 10.0"))
return DRIVER_OS_WINDOWS_10;
return OperatingSystem::Windows10;
else if (os.EqualsLiteral("Linux"))
return DRIVER_OS_LINUX;
return OperatingSystem::Linux;
else if (os.EqualsLiteral("Darwin 9"))
return DRIVER_OS_OS_X_10_5;
return OperatingSystem::OSX10_5;
else if (os.EqualsLiteral("Darwin 10"))
return DRIVER_OS_OS_X_10_6;
return OperatingSystem::OSX10_6;
else if (os.EqualsLiteral("Darwin 11"))
return DRIVER_OS_OS_X_10_7;
return OperatingSystem::OSX10_7;
else if (os.EqualsLiteral("Darwin 12"))
return DRIVER_OS_OS_X_10_8;
return OperatingSystem::OSX10_8;
else if (os.EqualsLiteral("Darwin 13"))
return DRIVER_OS_OS_X_10_9;
return OperatingSystem::OSX10_9;
else if (os.EqualsLiteral("Darwin 14"))
return DRIVER_OS_OS_X_10_10;
return OperatingSystem::OSX10_10;
else if (os.EqualsLiteral("Darwin 15"))
return DRIVER_OS_OS_X_10_11;
return OperatingSystem::OSX10_11;
else if (os.EqualsLiteral("Android"))
return DRIVER_OS_ANDROID;
#if defined (XP_WIN)
return OperatingSystem::Android;
// For historical reasons, "All" in blocklist means "All Windows"
else if (os.EqualsLiteral("All"))
return DRIVER_OS_ALL;
#endif
return OperatingSystem::Windows;

return DRIVER_OS_UNKNOWN;
return OperatingSystem::Unknown;
}

static GfxDeviceFamily*
Expand Down Expand Up @@ -614,6 +612,44 @@ GfxInfoBase::GetFeatureStatus(int32_t aFeature, nsACString& aFailureId, int32_t*
return rv;
}

// Matching OS go somewhat beyond the simple equality check because of the
// "All Windows" and "All OS X" variations.
//
// aBlockedOS is describing the system(s) we are trying to block.
// aSystemOS is describing the system we are running on.
//
// aSystemOS should not be "Windows" or "OSX" - it should be set to
// a particular version instead.
// However, it is valid for aBlockedOS to be one of those generic values,
// as we could be blocking all of the versions.
inline bool
MatchingOperatingSystems(OperatingSystem aBlockedOS, OperatingSystem aSystemOS)
{
MOZ_ASSERT(aSystemOS != OperatingSystem::Windows &&
aSystemOS != OperatingSystem::OSX);

// If the block entry OS is unknown, it doesn't match
if (aBlockedOS == OperatingSystem::Unknown) {
return false;
}

#if defined (XP_WIN)
if (aBlockedOS == OperatingSystem::Windows) {
// We do want even "unknown" aSystemOS to fall under "all windows"
return true;
}
#endif

#if defined (XP_MACOSX)
if (aBlockedOS == OperatingSystem::OSX) {
// We do want even "unknown" aSystemOS to fall under "all OS X"
return true;
}
#endif

return aSystemOS == aBlockedOS;
}

int32_t
GfxInfoBase::FindBlocklistedDeviceInList(const nsTArray<GfxDriverInfo>& info,
nsAString& aSuggestedVersion,
Expand All @@ -626,14 +662,8 @@ GfxInfoBase::FindBlocklistedDeviceInList(const nsTArray<GfxDriverInfo>& info,
uint32_t i = 0;
for (; i < info.Length(); i++) {
// Do the operating system check first, no point in getting the driver
// info if we won't need to use it. If the OS of the system we are running
// on is unknown, we still let DRIVER_OS_ALL catch and disable it;
// if the OS of the downloadable entry is unknown, we skip the entry
// as invalid.
if (info[i].mOperatingSystem == DRIVER_OS_UNKNOWN ||
(info[i].mOperatingSystem != DRIVER_OS_ALL &&
info[i].mOperatingSystem != os))
{
// info if we won't need to use it.
if (!MatchingOperatingSystems(info[i].mOperatingSystem, os)) {
continue;
}

Expand Down Expand Up @@ -822,9 +852,7 @@ GfxInfoBase::GetFeatureStatusImpl(int32_t aFeature,

// 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;
OperatingSystem os = (aOS ? *aOS : OperatingSystem::Unknown);

nsAutoString adapterVendorID;
nsAutoString adapterDeviceID;
Expand Down
2 changes: 1 addition & 1 deletion widget/GfxInfoX11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ GfxInfo::GetFeatureStatusImpl(int32_t aFeature,
NS_ENSURE_ARG_POINTER(aStatus);
*aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN;
aSuggestedDriverVersion.SetIsVoid(true);
OperatingSystem os = DRIVER_OS_LINUX;
OperatingSystem os = OperatingSystem::Linux;
if (aOS)
*aOS = os;

Expand Down
2 changes: 1 addition & 1 deletion widget/android/GfxInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ const nsTArray<GfxDriverInfo>&
GfxInfo::GetGfxDriverInfo()
{
if (mDriverInfo->IsEmpty()) {
APPEND_TO_DRIVER_BLOCKLIST2( DRIVER_OS_ALL,
APPEND_TO_DRIVER_BLOCKLIST2(OperatingSystem::Android,
(nsAString&) GfxDriverInfo::GetDeviceVendor(VendorAll), GfxDriverInfo::allDevices,
nsIGfxInfo::FEATURE_OPENGL_LAYERS, nsIGfxInfo::FEATURE_STATUS_OK,
DRIVER_COMPARISON_IGNORED, GfxDriverInfo::allDriverVersions,
Expand Down
35 changes: 20 additions & 15 deletions widget/cocoa/GfxInfo.mm
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,21 @@
if (nsCocoaFeatures::ExtractMajorVersion(aOSXVersion) == 10) {
switch (nsCocoaFeatures::ExtractMinorVersion(aOSXVersion)) {
case 6:
return DRIVER_OS_OS_X_10_6;
return OperatingSystem::OSX10_6;
case 7:
return DRIVER_OS_OS_X_10_7;
return OperatingSystem::OSX10_7;
case 8:
return DRIVER_OS_OS_X_10_8;
return OperatingSystem::OSX10_8;
case 9:
return DRIVER_OS_OS_X_10_9;
return OperatingSystem::OSX10_9;
case 10:
return DRIVER_OS_OS_X_10_10;
return OperatingSystem::OSX10_10;
case 11:
return DRIVER_OS_OS_X_10_11;
return OperatingSystem::OSX10_11;
}
}

return DRIVER_OS_UNKNOWN;
return OperatingSystem::Unknown;
}
// The following three functions are derived from Chromium code
static CFTypeRef SearchPortForProperty(io_registry_entry_t dspPort,
Expand Down Expand Up @@ -310,13 +310,13 @@ static uint32_t IntValueOfCFData(CFDataRef d)
GfxInfo::GetGfxDriverInfo()
{
if (!mDriverInfo->Length()) {
IMPLEMENT_MAC_DRIVER_BLOCKLIST(DRIVER_OS_ALL,
IMPLEMENT_MAC_DRIVER_BLOCKLIST(OperatingSystem::OSX,
(nsAString&) GfxDriverInfo::GetDeviceVendor(VendorATI), GfxDriverInfo::allDevices,
nsIGfxInfo::FEATURE_WEBGL_MSAA, nsIGfxInfo::FEATURE_BLOCKED_OS_VERSION, "FEATURE_FAILURE_MAC_ATI_NO_MSAA");
IMPLEMENT_MAC_DRIVER_BLOCKLIST(DRIVER_OS_ALL,
IMPLEMENT_MAC_DRIVER_BLOCKLIST(OperatingSystem::OSX,
(nsAString&) GfxDriverInfo::GetDeviceVendor(VendorATI), (GfxDeviceFamily*) GfxDriverInfo::GetDeviceFamily(RadeonX1000),
nsIGfxInfo::FEATURE_OPENGL_LAYERS, nsIGfxInfo::FEATURE_BLOCKED_DEVICE, "FEATURE_FAILURE_MAC_RADEONX1000_NO_TEXTURE2D");
IMPLEMENT_MAC_DRIVER_BLOCKLIST(DRIVER_OS_ALL,
IMPLEMENT_MAC_DRIVER_BLOCKLIST(OperatingSystem::OSX,
(nsAString&) GfxDriverInfo::GetDeviceVendor(VendorNVIDIA), (GfxDeviceFamily*) GfxDriverInfo::GetDeviceFamily(Geforce7300GT),
nsIGfxInfo::FEATURE_WEBGL_OPENGL, nsIGfxInfo::FEATURE_BLOCKED_DEVICE, "FEATURE_FAILURE_MAC_7300_NO_WEBGL");
}
Expand Down Expand Up @@ -351,11 +351,16 @@ static uint32_t IntValueOfCFData(CFDataRef d)
}
} else if (aFeature == nsIGfxInfo::FEATURE_CANVAS2D_ACCELERATION) {
// See bug 1249659
if (os > DRIVER_OS_OS_X_10_7) {
*aStatus = nsIGfxInfo::FEATURE_STATUS_OK;
} else {
*aStatus = nsIGfxInfo::FEATURE_BLOCKED_OS_VERSION;
aFailureId = "FEATURE_FAILURE_CANVAS_OSX_VERSION";
switch(os) {
case OperatingSystem::OSX10_5:
case OperatingSystem::OSX10_6:
case OperatingSystem::OSX10_7:
*aStatus = nsIGfxInfo::FEATURE_BLOCKED_OS_VERSION;
aFailureId = "FEATURE_FAILURE_CANVAS_OSX_VERSION";
break;
default:
*aStatus = nsIGfxInfo::FEATURE_STATUS_OK;
break;
}
return NS_OK;
}
Expand Down
4 changes: 2 additions & 2 deletions widget/uikit/GfxInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ const nsTArray<GfxDriverInfo>&
GfxInfo::GetGfxDriverInfo()
{
if (mDriverInfo->IsEmpty()) {
APPEND_TO_DRIVER_BLOCKLIST2( DRIVER_OS_ALL,
APPEND_TO_DRIVER_BLOCKLIST2(OperatingSystem::Ios,
(nsAString&) GfxDriverInfo::GetDeviceVendor(VendorAll), GfxDriverInfo::allDevices,
nsIGfxInfo::FEATURE_OPENGL_LAYERS, nsIGfxInfo::FEATURE_STATUS_OK,
DRIVER_COMPARISON_IGNORED, GfxDriverInfo::allDriverVersions );
Expand All @@ -173,7 +173,7 @@ GfxInfo::GetFeatureStatusImpl(int32_t aFeature,
aSuggestedDriverVersion.SetIsVoid(true);
*aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN;
if (aOS)
*aOS = DRIVER_OS_IOS;
*aOS = OperatingSystem::Ios;

// OpenGL layers are never blacklisted on iOS.
// This early return is so we avoid potentially slow
Expand Down
Loading

0 comments on commit d5f46d2

Please sign in to comment.