Bug 1280653 - Read into the X11 event queue in GLContextGLX::MakeCurrent to queue DRI invalidation events. r?lsalzman
MozReview-Commit-ID: 5N076lUlCkl
--- 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*,