Bug 1280653 - Read into the X11 event queue in GLContextGLX::MakeCurrent to queue DRI invalidation events. r?lsalzman draft
authorAndrew Comminos <andrew@comminos.com>
Wed, 24 Aug 2016 20:23:39 -0400
changeset 405180 98ec7ad2c13939048e6f27ff1069fbd9ff3e9cf9
parent 404988 01748a2b1a463f24efd9cd8abad9ccfd76b037b8
child 529380 cbcf98dda994fa58cdb8cf96ae9499a10d7d3a31
push id27422
push userbmo:andrew@comminos.com
push dateThu, 25 Aug 2016 00:25:11 +0000
reviewerslsalzman
bugs1280653
milestone51.0a1
Bug 1280653 - Read into the X11 event queue in GLContextGLX::MakeCurrent to queue DRI invalidation events. r?lsalzman MozReview-Commit-ID: 5N076lUlCkl
gfx/gl/GLContextProviderGLX.cpp
gfx/gl/GLXLibrary.h
--- a/gfx/gl/GLContextProviderGLX.cpp
+++ b/gfx/gl/GLContextProviderGLX.cpp
@@ -10,16 +10,17 @@
 #endif
 
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
 
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/widget/CompositorWidget.h"
+#include "mozilla/unused.h"
 
 #include "prenv.h"
 #include "GLContextProvider.h"
 #include "GLLibraryLoader.h"
 #include "nsDebug.h"
 #include "nsIWidget.h"
 #include "GLXLibrary.h"
 #include "gfxXlibSurface.h"
@@ -935,16 +936,22 @@ GLContextGLX::MakeCurrentImpl(bool aForc
 
     // With the ATI FGLRX driver, glxMakeCurrent is very slow even when the context doesn't change.
     // (This is not the case with other drivers such as NVIDIA).
     // So avoid calling it more than necessary. Since GLX documentation says that:
     //     "glXGetCurrentContext returns client-side information.
     //      It does not make a round trip to the server."
     // I assume that it's not worth using our own TLS slot here.
     if (aForce || mGLX->xGetCurrentContext() != mContext) {
+        if (mGLX->IsMesa()) {
+          // Read into the event queue to ensure that Mesa receives a
+          // DRI2InvalidateBuffers event before drawing. See bug 1280653.
+          Unused << XPending(mDisplay);
+        }
+
         succeeded = mGLX->xMakeCurrent(mDisplay, mDrawable, mContext);
         NS_ASSERTION(succeeded, "Failed to make GL context current!");
 
         if (!IsOffscreen() && mGLX->SupportsSwapControl()) {
             // Many GLX implementations default to blocking until the next
             // VBlank when calling glXSwapBuffers. We want to run unthrottled
             // in ASAP mode. See bug 1280744.
             const bool isASAP = (gfxPrefs::LayoutFrameRate() == 0);
--- a/gfx/gl/GLXLibrary.h
+++ b/gfx/gl/GLXLibrary.h
@@ -138,16 +138,17 @@ public:
 
     bool UseTextureFromPixmap() { return mUseTextureFromPixmap; }
     bool HasRobustness() { return mHasRobustness; }
     bool HasCreateContextAttribs() { return mHasCreateContextAttribs; }
     bool SupportsTextureFromPixmap(gfxASurface* aSurface);
     bool SupportsVideoSync();
     bool SupportsSwapControl() const { return bool(xSwapIntervalInternal); }
     bool IsATI() { return mIsATI; }
+    bool IsMesa() { return mClientIsMesa; }
     bool GLXVersionCheck(int aMajor, int aMinor);
 
 private:
 
     typedef void (GLAPIENTRY * PFNGLXDESTROYCONTEXTPROC) (Display*,
                                                           GLXContext);
     PFNGLXDESTROYCONTEXTPROC xDestroyContextInternal;
     typedef Bool (GLAPIENTRY * PFNGLXMAKECURRENTPROC) (Display*,