Bug 896287 - NVIDIA specific GLX server vendor check for pixmap depth and fbConfig depth. r=karlt
authorJoseph Yasi <joe.yasi@gmail.com>
Tue, 20 Aug 2013 08:30:26 -0400
changeset 143227 1346fc77965ae2deea3068d544514d9bc93e8634
parent 143226 f673d2423e08629add2442cb8edf3f06f8450225
child 143228 6245b87ea6b108797c20209d641de7d68cf9a5dc
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewerskarlt
bugs896287
milestone26.0a1
Bug 896287 - NVIDIA specific GLX server vendor check for pixmap depth and fbConfig depth. r=karlt
gfx/gl/GLContextProviderGLX.cpp
gfx/gl/GLXLibrary.h
--- a/gfx/gl/GLContextProviderGLX.cpp
+++ b/gfx/gl/GLContextProviderGLX.cpp
@@ -258,16 +258,17 @@ GLXLibrary::EnsureInitialized(LibType li
     }
 
     if (HasExtension(extensionsStr, "GLX_ARB_create_context_robustness") &&
         GLLibraryLoader::LoadSymbols(mOGLLibrary, symbols_robustness)) {
         mHasRobustness = true;
     }
 
     mIsATI = serverVendor && DoesStringMatch(serverVendor, "ATI");
+    mIsNVIDIA = serverVendor && DoesStringMatch(serverVendor, "NVIDIA Corporation");
     mClientIsMesa = clientVendor && DoesStringMatch(clientVendor, "Mesa");
 
     mInitialized = true;
     mLibType = libType;
 
     return true;
 }
 
@@ -362,17 +363,20 @@ GLXLibrary::CreatePixmap(gfxASurface* aS
         // Usually GLX counts only color bits in the Visual depth, but the
         // depth of Composite's ARGB Visual includes alpha bits.  However,
         // bits not in the color masks are not necessarily alpha bits because
         // sometimes (NVIDIA) 32 bit Visuals are added for fbconfigs with 32
         // bit BUFFER_SIZE but zero alpha bits and 24 color bits (NVIDIA
         // again).
         //
         // This checks that the depth matches in one of the two ways.
-        if (depth != format->depth && depth != format->depth - alphaSize) {
+        // NVIDIA now forces format->depth == depth so only the first way
+        // is checked for NVIDIA
+        if (depth != format->depth &&
+            (mIsNVIDIA || depth != format->depth - alphaSize) ) {
             continue;
         }
 
         // If all bits of the Pixmap are color bits and the Pixmap depth
         // matches the depth of the fbconfig visual, then we can assume that
         // the driver will do whatever is necessary to ensure that any
         // GLXPixmap alpha bits are treated as set.  We can skip the
         // ALPHA_SIZE check in this situation.  We need to skip this check for
--- a/gfx/gl/GLXLibrary.h
+++ b/gfx/gl/GLXLibrary.h
@@ -13,17 +13,17 @@ typedef realGLboolean GLboolean;
 namespace mozilla {
 namespace gl {
 
 class GLXLibrary
 {
 public:
     GLXLibrary() : mInitialized(false), mTriedInitializing(false),
                    mUseTextureFromPixmap(false), mDebug(false),
-                   mHasRobustness(false), mIsATI(false),
+                   mHasRobustness(false), mIsATI(false), mIsNVIDIA(false),
                    mClientIsMesa(false), mGLXMajorVersion(0),
                    mGLXMinorVersion(0), mLibType(OPENGL_LIB),
                    mOGLLibrary(nullptr) {}
 
     void xDestroyContext(Display* display, GLXContext context);
     Bool xMakeCurrent(Display* display, 
                       GLXDrawable drawable, 
                       GLXContext context);
@@ -197,16 +197,17 @@ private:
 #endif
 
     bool mInitialized;
     bool mTriedInitializing;
     bool mUseTextureFromPixmap;
     bool mDebug;
     bool mHasRobustness;
     bool mIsATI;
+    bool mIsNVIDIA;
     bool mClientIsMesa;
     int mGLXMajorVersion;
     int mGLXMinorVersion;
     LibraryType mLibType;
     PRLibrary *mOGLLibrary;
 };
 
 // a global GLXLibrary instance