Bug 1094338 - Allow depth texture on OS X 10.8.3 and higher. Clean up some OS X versioning tracking in the process. r=jgilbert

This commit is contained in:
Milan Sreckovic 2014-11-10 22:15:22 -05:00
Родитель d88351efcf
Коммит e879ad97c7
5 изменённых файлов: 82 добавлений и 49 удалений

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

@ -1830,8 +1830,7 @@ WebGLContext::InitAndValidateGL()
#ifdef XP_MACOSX
if (gl->WorkAroundDriverBugs() &&
gl->Vendor() == gl::GLVendor::ATI &&
nsCocoaFeatures::OSXVersionMajor() == 10 &&
nsCocoaFeatures::OSXVersionMinor() < 9)
!nsCocoaFeatures::IsAtLeastVersion(10,9))
{
// The Mac ATI driver, in all known OSX version up to and including 10.8,
// renders points sprites upside-down. Apple bug 11778921

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

@ -683,11 +683,12 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
}
#ifdef XP_MACOSX
// The Mac Nvidia driver, for versions up to and including 10.8, don't seem
// to properly support this. See 814839
// The Mac Nvidia driver, for versions up to and including 10.8,
// don't seem to properly support this. See 814839
// this has been fixed in Mac OS X 10.9. See 907946
// and it also works in 10.8.3 and higher. See 1094338.
if (Vendor() == gl::GLVendor::NVIDIA &&
!nsCocoaFeatures::OnMavericksOrLater())
!nsCocoaFeatures::IsAtLeastVersion(10,8,3))
{
MarkUnsupported(GLFeature::depth_texture);
}

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

@ -21,12 +21,11 @@ public:
static bool SupportCoreAnimationPlugins();
static bool AccelerateByDefault();
static bool IsAtLeastVersion(int32_t aMajor, int32_t aMinor, int32_t aBugFix=0);
private:
static void InitializeVersionNumbers();
static int32_t mOSXVersion;
static int32_t mOSXVersionMajor;
static int32_t mOSXVersionMinor;
static int32_t mOSXVersionBugFix;
};
#endif // nsCocoaFeatures_h_

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

@ -3,7 +3,18 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// This file makes some assumptions about the versions of OS X.
// Instead of making it work major version 11 right now,
// we will wait until that happens and worry about it then.
// There are MOZ_ASSERTs to remind us to do that.
// We are assuming that the minor version is less than 16.
// There are MOZ_ASSERTs for that as well.
// The formula for the version integer based on OS X version 10.minor.bugfix is
// 0x1000 + (minor << 4) + bugifix. See AssembleVersion() below.
#define MAC_OS_X_VERSION_MASK 0x0000FFFF
#define MAC_OS_X_VERSION_10_0_HEX 0x00001000
#define MAC_OS_X_VERSION_10_6_HEX 0x00001060
#define MAC_OS_X_VERSION_10_7_HEX 0x00001070
#define MAC_OS_X_VERSION_10_8_HEX 0x00001080
@ -18,9 +29,31 @@
#import <Cocoa/Cocoa.h>
int32_t nsCocoaFeatures::mOSXVersion = 0;
int32_t nsCocoaFeatures::mOSXVersionMajor = 0;
int32_t nsCocoaFeatures::mOSXVersionMinor = 0;
int32_t nsCocoaFeatures::mOSXVersionBugFix = 0;
inline int32_t AssembleVersion(int32_t aMajor, int32_t aMinor, int32_t aBugFix)
{
MOZ_ASSERT(aMajor == 10);
return MAC_OS_X_VERSION_10_0_HEX + (aMinor << 4) + aBugFix;
}
inline int32_t ExtractMajorVersion(int32_t aVersion)
{
MOZ_ASSERT((aVersion & MAC_OS_X_VERSION_MASK) == aVersion);
MOZ_ASSERT((aVersion & MAC_OS_X_VERSION_10_0_HEX) == MAC_OS_X_VERSION_10_0_HEX);
return 10;
}
inline int32_t ExtractMinorVersion(int32_t aVersion)
{
MOZ_ASSERT((aVersion & MAC_OS_X_VERSION_MASK) == aVersion);
return (aVersion & 0xF0) >> 4;
}
inline int32_t ExtractBugFixVersion(int32_t aVersion)
{
MOZ_ASSERT((aVersion & MAC_OS_X_VERSION_MASK) == aVersion);
return aVersion & 0x0F;
}
static int intAtStringIndex(NSArray *array, int index)
{
@ -46,6 +79,30 @@ static void GetSystemVersion(int &major, int &minor, int &bugfix)
}
}
static int32_t GetFullVersion(int32_t aMajor, int32_t aMinor, int32_t aBugFix)
{
int32_t osxVersion;
if (aMajor < 10) {
aMajor = 10;
NS_ERROR("Couldn't determine OS X version, assuming 10.6");
osxVersion = MAC_OS_X_VERSION_10_6_HEX;
} else if (aMinor < 6) {
aMinor = 6;
NS_ERROR("OS X version too old, assuming 10.6");
osxVersion = MAC_OS_X_VERSION_10_6_HEX;
} else {
MOZ_ASSERT(aMajor == 10);
MOZ_ASSERT(aMinor < 16);
MOZ_ASSERT(aBugFix >= 0);
MOZ_ASSERT(aBugFix < 16);
osxVersion = AssembleVersion(aMajor, aMinor, aBugFix);
}
MOZ_ASSERT(aMajor == ExtractMajorVersion(osxVersion));
MOZ_ASSERT(aMinor == ExtractMinorVersion(osxVersion));
MOZ_ASSERT(aBugFix == ExtractBugFixVersion(osxVersion));
return osxVersion;
}
/*static*/ void
nsCocoaFeatures::InitializeVersionNumbers()
{
@ -57,25 +114,7 @@ nsCocoaFeatures::InitializeVersionNumbers()
int major, minor, bugfix;
GetSystemVersion(major, minor, bugfix);
mOSXVersionMajor = major;
mOSXVersionMinor = minor;
mOSXVersionBugFix = bugfix;
if (major < 10) {
NS_ERROR("Couldn't determine OS X version, assuming 10.6");
mOSXVersion = MAC_OS_X_VERSION_10_6_HEX;
mOSXVersionMajor = 10;
mOSXVersionMinor = 6;
mOSXVersionBugFix = 0;
} else if (minor < 6) {
NS_ERROR("OS X version too old, assuming 10.6");
mOSXVersion = MAC_OS_X_VERSION_10_6_HEX;
mOSXVersionMinor = 6;
mOSXVersionBugFix = 0;
} else {
mOSXVersion = 0x1000 + (minor << 4);
}
mOSXVersion = GetFullVersion(major, minor, bugfix);
NS_OBJC_END_TRY_ABORT_BLOCK;
}
@ -83,7 +122,10 @@ nsCocoaFeatures::InitializeVersionNumbers()
/* static */ int32_t
nsCocoaFeatures::OSXVersion()
{
// Don't let this be called while we're first setting the value...
MOZ_ASSERT((mOSXVersion & MAC_OS_X_VERSION_MASK) >= 0);
if (!mOSXVersion) {
mOSXVersion = -1;
InitializeVersionNumbers();
}
return mOSXVersion;
@ -92,28 +134,20 @@ nsCocoaFeatures::OSXVersion()
/* static */ int32_t
nsCocoaFeatures::OSXVersionMajor()
{
if (!mOSXVersion) {
InitializeVersionNumbers();
}
return mOSXVersionMajor;
MOZ_ASSERT((OSXVersion() & MAC_OS_X_VERSION_10_0_HEX) == MAC_OS_X_VERSION_10_0_HEX);
return 10;
}
/* static */ int32_t
nsCocoaFeatures::OSXVersionMinor()
{
if (!mOSXVersion) {
InitializeVersionNumbers();
}
return mOSXVersionMinor;
return ExtractMinorVersion(OSXVersion());
}
/* static */ int32_t
nsCocoaFeatures::OSXVersionBugFix()
{
if (!mOSXVersion) {
InitializeVersionNumbers();
}
return mOSXVersionBugFix;
return ExtractBugFixVersion(OSXVersion());
}
/* static */ bool
@ -151,8 +185,11 @@ nsCocoaFeatures::OnYosemiteOrLater()
/* static */ bool
nsCocoaFeatures::AccelerateByDefault()
{
return !(OSXVersionMajor() == 10 &&
OSXVersionMinor() == 6 &&
OSXVersionBugFix() <= 2);
return IsAtLeastVersion(10, 6, 3);
}
/* static */ bool
nsCocoaFeatures::IsAtLeastVersion(int32_t aMajor, int32_t aMinor, int32_t aBugFix)
{
return OSXVersion() >= GetFullVersion(aMajor, aMinor, aBugFix);
}

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

@ -1095,10 +1095,7 @@ nsNativeThemeCocoa::DrawMenuIcon(CGContextRef cgContext, const CGRect& aRect,
// On 10.6 and at least on 10.7.0, Apple doesnt seem to have implemented all
// keys and values used on 10.7.5 and later. We can however draw menu icons
// on earlier OS versions by using different keys/values.
BOOL otherKeysAndValues = !nsCocoaFeatures::OnLionOrLater() ||
(nsCocoaFeatures::OSXVersionMajor() == 10 &&
nsCocoaFeatures::OSXVersionMinor() == 7 &&
nsCocoaFeatures::OSXVersionBugFix() < 5);
BOOL otherKeysAndValues = !nsCocoaFeatures::IsAtLeastVersion(10,7,5);
// 2 states combined with 2 different backgroundTypeKeys on earlier versions.
NSString* state = isDisabled ? @"disabled" :