Bug 942499 - Part 3: Move CanReadSRGBFromFBOTexture out of GLContext - r=gal,jgilbert
authorBenoit Jacob <bjacob@mozilla.com>
Tue, 03 Dec 2013 13:44:38 -0500
changeset 173311 c789f25ca86e68ab8a8e15d74cd966c1bfbf0a13
parent 173310 22a1c5c1371632d71b0babaa0d908172a8fb8069
child 173312 b82424f061f4cb5f5d8f123340b849d0cd74ab7b
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgal, jgilbert
bugs942499
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 942499 - Part 3: Move CanReadSRGBFromFBOTexture out of GLContext - r=gal,jgilbert
gfx/gl/GLContext.cpp
gfx/gl/GLContext.h
gfx/gl/GLContextFeatures.cpp
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -1140,38 +1140,16 @@ GLContext::InitExtensions()
         MarkExtensionSupported(OES_rgb8_rgba8);
     }
 
 #ifdef DEBUG
     firstRun = false;
 #endif
 }
 
-bool
-GLContext::CanReadSRGBFromFBOTexture()
-{
-    if (!mWorkAroundDriverBugs)
-        return true;
-
-#ifdef XP_MACOSX
-    // Bug 843668:
-    // MacOSX 10.6 reports to support EXT_framebuffer_sRGB and
-    // EXT_texture_sRGB but fails to convert from sRGB to linear
-    // when writing to an sRGB texture attached to an FBO.
-    SInt32 major, minor;
-    ::Gestalt(gestaltSystemVersionMajor, &major);
-    ::Gestalt(gestaltSystemVersionMinor, &minor);
-    if (major == 10 && minor <= 6) {
-        return false;
-    }
-#endif // XP_MACOSX
-    return true;
-}
-
-
 void
 GLContext::PlatformStartup()
 {
   RegisterStrongMemoryReporter(new GfxTexturesReporter());
 }
 
 // Common code for checking for both GL extensions and GLX extensions.
 bool
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -2468,18 +2468,16 @@ public:
      *
      * If surf is null, this removes any previously set override, and makes the
      * context current again against its primary surface.
      */
     virtual void SetEGLSurfaceOverride(EGLSurface surf) {
         MOZ_CRASH("Must be called against a GLContextEGL.");
     }
 
-    bool CanReadSRGBFromFBOTexture();
-
     static void PlatformStartup();
 
 public:
     /**
      * If this context wraps a double-buffered target, swap the back
      * and front buffers.  It should be assumed that after a swap, the
      * contents of the new back buffer are undefined.
      */
--- a/gfx/gl/GLContextFeatures.cpp
+++ b/gfx/gl/GLContextFeatures.cpp
@@ -2,16 +2,20 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 
 #include "GLContext.h"
 #include "nsPrintfCString.h"
 
+#ifdef XP_MACOSX
+#include "nsCocoaFeatures.h"
+#endif
+
 namespace mozilla {
 namespace gl {
 
 const size_t kMAX_EXTENSION_GROUP_SIZE = 5;
 
 // ARB_ES2_compatibility is natively supported in OpenGL 4.1.
 static const unsigned int kGLCoreVersionForES2Compat = 410;
 
@@ -361,16 +365,34 @@ IsFeatureIsPartOfProfileVersion(GLFeatur
 }
 
 const char*
 GLContext::GetFeatureName(GLFeature::Enum feature)
 {
     return GetFeatureInfo(feature).mName;
 }
 
+static bool
+CanReadSRGBFromFBOTexture(GLContext* gl)
+{
+    if (!gl->WorkAroundDriverBugs())
+        return true;
+
+#ifdef XP_MACOSX
+    // Bug 843668:
+    // MacOSX 10.6 reports to support EXT_framebuffer_sRGB and
+    // EXT_texture_sRGB but fails to convert from sRGB to linear
+    // when writing to an sRGB texture attached to an FBO.
+    if (!nsCocoaFeatures::OnLionOrLater()) {
+        return false;
+    }
+#endif // XP_MACOSX
+    return true;
+}
+
 void
 GLContext::InitFeatures()
 {
     for (size_t i = 0; i < GLFeature::EnumMax; i++)
     {
         GLFeature::Enum feature = GLFeature::Enum(i);
 
         if (IsFeatureIsPartOfProfileVersion(feature, mProfile, mVersion)) {
@@ -402,17 +424,17 @@ GLContext::InitFeatures()
     // EXT_texture_sRGB and EXT_framebuffer_sRGB is required.
     const bool aresRGBExtensionsAvailable =
         IsExtensionSupported(EXT_texture_sRGB) &&
         (IsExtensionSupported(ARB_framebuffer_sRGB) ||
          IsExtensionSupported(EXT_framebuffer_sRGB));
 
     mAvailableFeatures[GLFeature::sRGB] =
         aresRGBExtensionsAvailable &&
-        CanReadSRGBFromFBOTexture();
+        CanReadSRGBFromFBOTexture(this);
 }
 
 void
 GLContext::MarkUnsupported(GLFeature::Enum feature)
 {
     mAvailableFeatures[feature] = false;
 
     const FeatureInfo& featureInfo = GetFeatureInfo(feature);