Backout Bug 594876, Bug 675474, and Bug 675532, to fix OSX64 Reftest orange, and Linux perf regression. rs+=edmorly
authorJustin Wood <Callek@gmail.com>
Sat, 20 Aug 2011 15:07:06 -0400
changeset 75603 7797172fc164f2f75bb739b47e99f1a5eaaa53a6
parent 75594 0a920411e64c019db924a46ae617074f868df3b1
child 75604 955f83dc4372d50ab24ff685d462f036b68aae1e
push id21040
push userbmo@edmorley.co.uk
push dateSun, 21 Aug 2011 18:16:59 +0000
treeherdermozilla-central@482742e6fff7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs594876, 675474, 675532
milestone9.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
Backout Bug 594876, Bug 675474, and Bug 675532, to fix OSX64 Reftest orange, and Linux perf regression. rs+=edmorly changeset 0a920411e64c, changeset 58147380793b, and changeset 96e052b3e845
gfx/layers/opengl/ContainerLayerOGL.cpp
gfx/layers/opengl/ContainerLayerOGL.h
gfx/layers/opengl/LayerManagerOGL.cpp
gfx/layers/opengl/LayerManagerOGL.h
gfx/layers/opengl/ThebesLayerOGL.cpp
gfx/layers/opengl/ThebesLayerOGL.h
gfx/src/X11Util.h
gfx/tests/mochitest/test_acceleration.html
gfx/thebes/GLContext.h
gfx/thebes/GLContextProviderGLX.cpp
gfx/thebes/GLXLibrary.h
widget/src/xpwidgets/nsBaseWidget.cpp
--- a/gfx/layers/opengl/ContainerLayerOGL.cpp
+++ b/gfx/layers/opengl/ContainerLayerOGL.cpp
@@ -327,26 +327,16 @@ ContainerLayerOGL::GetFirstChildOGL()
 {
   if (!mFirstChild) {
     return nsnull;
   }
   return static_cast<LayerOGL*>(mFirstChild->ImplData());
 }
 
 void
-ContainerLayerOGL::Validate()
-{
-  for (LayerOGL* child = GetFirstChildOGL();
-       child != nsnull;
-       child = mozilla::layers::GetNextSibling(child)) {
-    child->Validate();
-  }
-}
-
-void
 ContainerLayerOGL::RenderLayer(int aPreviousFrameBuffer,
                                const nsIntPoint& aOffset)
 {
   ContainerRender(this, aPreviousFrameBuffer, aOffset, mOGLManager);
 }
 
 
 ShadowContainerLayerOGL::ShadowContainerLayerOGL(LayerManagerOGL *aManager)
--- a/gfx/layers/opengl/ContainerLayerOGL.h
+++ b/gfx/layers/opengl/ContainerLayerOGL.h
@@ -84,17 +84,16 @@ public:
 
   /** LayerOGL implementation */
   Layer* GetLayer() { return this; }
 
   void Destroy();
 
   LayerOGL* GetFirstChildOGL();
 
-  virtual void Validate();
   virtual void RenderLayer(int aPreviousFrameBuffer,
                            const nsIntPoint& aOffset);
 
   virtual void ComputeEffectiveTransforms(const gfx3DMatrix& aTransformToSurface)
   {
     DefaultComputeEffectiveTransforms(aTransformToSurface);
   }
 };
--- a/gfx/layers/opengl/LayerManagerOGL.cpp
+++ b/gfx/layers/opengl/LayerManagerOGL.cpp
@@ -786,19 +786,16 @@ LayerManagerOGL::Render()
     mGLContext->fScissor(0, 0, width, height);
   }
 
   mGLContext->fEnable(LOCAL_GL_SCISSOR_TEST);
 
   mGLContext->fClearColor(0.0, 0.0, 0.0, 0.0);
   mGLContext->fClear(LOCAL_GL_COLOR_BUFFER_BIT | LOCAL_GL_DEPTH_BUFFER_BIT);
 
-  RootLayer()->Validate();
-  mGLContext->WaitForDrawing();
-
   // Render our layers.
   RootLayer()->RenderLayer(mGLContext->IsDoubleBuffered() ? 0 : mBackBufferFBO,
                            nsIntPoint(0, 0));
                            
   mWidget->DrawOver(this, rect);
 
   if (mTarget) {
     CopyToTarget();
--- a/gfx/layers/opengl/LayerManagerOGL.h
+++ b/gfx/layers/opengl/LayerManagerOGL.h
@@ -526,18 +526,16 @@ public:
 
   /* Do NOT call this from the generic LayerOGL destructor.  Only from the
    * concrete class destructor
    */
   virtual void Destroy() = 0;
 
   virtual Layer* GetLayer() = 0;
 
-  virtual void Validate() {}
-
   virtual void RenderLayer(int aPreviousFrameBuffer,
                            const nsIntPoint& aOffset) = 0;
 
   typedef mozilla::gl::GLContext GLContext;
 
   LayerManagerOGL* OGLManager() const { return mOGLManager; }
   GLContext *gl() const { return mOGLManager->gl(); }
 
--- a/gfx/layers/opengl/ThebesLayerOGL.cpp
+++ b/gfx/layers/opengl/ThebesLayerOGL.cpp
@@ -729,31 +729,38 @@ ThebesLayerOGL::SetVisibleRegion(const n
 
 void
 ThebesLayerOGL::InvalidateRegion(const nsIntRegion &aRegion)
 {
   mValidRegion.Sub(mValidRegion, aRegion);
 }
 
 void
-ThebesLayerOGL::Validate()
+ThebesLayerOGL::RenderLayer(int aPreviousFrameBuffer,
+                            const nsIntPoint& aOffset)
 {
   if (!mBuffer && !CreateSurface()) {
     return;
   }
   NS_ABORT_IF_FALSE(mBuffer, "should have a buffer here");
 
+  mOGLManager->MakeCurrent();
+  gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
+
   TextureImage::ContentType contentType =
     CanUseOpaqueSurface() ? gfxASurface::CONTENT_COLOR :
                             gfxASurface::CONTENT_COLOR_ALPHA;
 
   gfxMatrix transform2d;
   PRUint32 flags = 0;
-  if (!GetEffectiveTransform().Is2D(&transform2d) ||
-      transform2d.HasNonIntegerTranslation()) {
+  if (GetEffectiveTransform().Is2D(&transform2d)) {
+    if (transform2d.HasNonIntegerTranslation()) {
+      flags |= ThebesLayerBufferOGL::PAINT_WILL_RESAMPLE;
+    }
+  } else {
     flags |= ThebesLayerBufferOGL::PAINT_WILL_RESAMPLE;
   }
 
   Buffer::PaintState state = mBuffer->BeginPaint(contentType, flags);
   mValidRegion.Sub(mValidRegion, state.mRegionToInvalidate);
 
   if (state.mContext) {
     state.mRegionToInvalidate.And(state.mRegionToInvalidate, mVisibleRegion);
@@ -771,33 +778,19 @@ ThebesLayerOGL::Validate()
       // OR-ing with aRegionToDraw, since that can lead to a very complex region
       // here (OR doesn't automatically simplify to the simplest possible
       // representation of a region.)
       nsIntRegion tmp;
       tmp.Or(mVisibleRegion, state.mRegionToDraw);
       mValidRegion.Or(mValidRegion, tmp);
     }
   }
-}
 
-void
-ThebesLayerOGL::RenderLayer(int aPreviousFrameBuffer,
-                            const nsIntPoint& aOffset)
-{
-  NS_ABORT_IF_FALSE(mBuffer, "should have a buffer here");
-  
-  gfxMatrix transform2d;
-  PRUint32 flags = 0;
-  if (!GetEffectiveTransform().Is2D(&transform2d) ||
-      transform2d.HasNonIntegerTranslation()) {
-    flags |= ThebesLayerBufferOGL::PAINT_WILL_RESAMPLE;
-  }
-
+  // Drawing thebes layers can change the current context, reset it.
   gl()->MakeCurrent();
-  gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
 
   gl()->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, aPreviousFrameBuffer);
   mBuffer->RenderTo(aOffset, mOGLManager, flags);
 }
 
 Layer*
 ThebesLayerOGL::GetLayer()
 {
--- a/gfx/layers/opengl/ThebesLayerOGL.h
+++ b/gfx/layers/opengl/ThebesLayerOGL.h
@@ -68,17 +68,16 @@ public:
 
   /** ThebesLayer implementation */
   void InvalidateRegion(const nsIntRegion& aRegion);
 
   /** LayerOGL implementation */
   void Destroy();
   Layer* GetLayer();
   virtual PRBool IsEmpty();
-  virtual void Validate();
   virtual void RenderLayer(int aPreviousFrameBuffer,
                            const nsIntPoint& aOffset);
 
 private:
   friend class BasicBufferOGL;
 
   PRBool CreateSurface();
 
--- a/gfx/src/X11Util.h
+++ b/gfx/src/X11Util.h
@@ -121,30 +121,27 @@ private:
  * ScopedXErrorHandler was in place may then be caught by the other ScopedXErrorHandler. This is just a result of X being
  * asynchronous and us not doing any implicit syncing: the only method in this class what causes syncing is SyncAndGetError().
  *
  * This class is not thread-safe at all. It is assumed that only one thread is using any ScopedXErrorHandler's. Given that it's
  * not used on Mac, it should be easy to make it thread-safe by using thread-local storage with __thread.
  */
 class NS_GFX ScopedXErrorHandler
 {
-public:
     // trivial wrapper around XErrorEvent, just adding ctor initializing by zero.
     struct ErrorEvent
     {
         XErrorEvent mError;
 
         ErrorEvent()
         {
             memset(this, 0, sizeof(ErrorEvent));
         }
     };
 
-private:
-
     // this ScopedXErrorHandler's ErrorEvent object
     ErrorEvent mXError;
 
     // static pointer for use by the error handler
     static ErrorEvent* sXErrorPtr;
 
     // what to restore sXErrorPtr to on destruction
     ErrorEvent* mOldXErrorPtr;
--- a/gfx/tests/mochitest/test_acceleration.html
+++ b/gfx/tests/mochitest/test_acceleration.html
@@ -66,20 +66,16 @@ switch(osName)
       ok(!gfxInfo.D2DEnabled, "Direct2D not supported on Windows 2003 or older");
       ok(!gfxInfo.DWriteEnabled, "DirectWrite not supported on Windows 2003 or older");
     } else {
       ok(gfxInfo.D2DEnabled, "Direct2D enabled on Windows Vista or newer");
       ok(gfxInfo.DWriteEnabled, "DirectWrite enabled on Windows Vista or newer");
     }
     break;
 
-  case "Linux":
-    isnot(acceleratedWindows, 0, "Acceleration enabled on Linux");
-    break;
-
   default:
     is(acceleratedWindows, 0, "Acceleration not supported on '" + osName + "'");
 }
 
 </script>
 </pre>
 </body>
 </html>
--- a/gfx/thebes/GLContext.h
+++ b/gfx/thebes/GLContext.h
@@ -645,22 +645,16 @@ 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.
      */
     virtual PRBool SwapBuffers() { return PR_FALSE; }
 
     /**
-     * Insert a sync point to wait for any platform specific
-     * drawing to soure surfaces to complete.
-     */
-    virtual void WaitForDrawing() {}
-
-    /**
      * Defines a two-dimensional texture image for context target surface
      */
     virtual PRBool BindTexImage() { return PR_FALSE; }
     /*
      * Releases a color buffer that is being used as a texture
      */
     virtual PRBool ReleaseTexImage() { return PR_FALSE; }
 
--- a/gfx/thebes/GLContextProviderGLX.cpp
+++ b/gfx/thebes/GLContextProviderGLX.cpp
@@ -107,80 +107,75 @@ GLXLibrary::EnsureInitialized()
         mOGLLibrary = PR_LoadLibrary(libGLfilename);
         if (!mOGLLibrary) {
             NS_WARNING("Couldn't load OpenGL shared library.");
             return PR_FALSE;
         }
         reporter.SetSuccessful();
     }
 
-    if (PR_GetEnv("MOZ_GLX_DEBUG")) {
-        mDebug = PR_TRUE;
-    }
-
     LibrarySymbolLoader::SymLoadStruct symbols[] = {
         /* functions that were in GLX 1.0 */
-        { (PRFuncPtr*) &xDestroyContextInternal, { "glXDestroyContext", NULL } },
-        { (PRFuncPtr*) &xMakeCurrentInternal, { "glXMakeCurrent", NULL } },
-        { (PRFuncPtr*) &xSwapBuffersInternal, { "glXSwapBuffers", NULL } },
-        { (PRFuncPtr*) &xQueryVersionInternal, { "glXQueryVersion", NULL } },
-        { (PRFuncPtr*) &xGetCurrentContextInternal, { "glXGetCurrentContext", NULL } },
-        { (PRFuncPtr*) &xWaitGLInternal, { "glXWaitGL", NULL } },
-        { (PRFuncPtr*) &xWaitXInternal, { "glXWaitX", NULL } },
+        { (PRFuncPtr*) &xDestroyContext, { "glXDestroyContext", NULL } },
+        { (PRFuncPtr*) &xMakeCurrent, { "glXMakeCurrent", NULL } },
+        { (PRFuncPtr*) &xSwapBuffers, { "glXSwapBuffers", NULL } },
+        { (PRFuncPtr*) &xQueryVersion, { "glXQueryVersion", NULL } },
+        { (PRFuncPtr*) &xGetCurrentContext, { "glXGetCurrentContext", NULL } },
+        { (PRFuncPtr*) &xWaitGL, { "glXWaitGL", NULL } },
         /* functions introduced in GLX 1.1 */
-        { (PRFuncPtr*) &xQueryExtensionsStringInternal, { "glXQueryExtensionsString", NULL } },
-        { (PRFuncPtr*) &xGetClientStringInternal, { "glXGetClientString", NULL } },
-        { (PRFuncPtr*) &xQueryServerStringInternal, { "glXQueryServerString", NULL } },
+        { (PRFuncPtr*) &xQueryExtensionsString, { "glXQueryExtensionsString", NULL } },
+        { (PRFuncPtr*) &xGetClientString, { "glXGetClientString", NULL } },
+        { (PRFuncPtr*) &xQueryServerString, { "glXQueryServerString", NULL } },
         { NULL, { NULL } }
     };
 
     LibrarySymbolLoader::SymLoadStruct symbols13[] = {
         /* functions introduced in GLX 1.3 */
-        { (PRFuncPtr*) &xChooseFBConfigInternal, { "glXChooseFBConfig", NULL } },
-        { (PRFuncPtr*) &xGetFBConfigAttribInternal, { "glXGetFBConfigAttrib", NULL } },
+        { (PRFuncPtr*) &xChooseFBConfig, { "glXChooseFBConfig", NULL } },
+        { (PRFuncPtr*) &xGetFBConfigAttrib, { "glXGetFBConfigAttrib", NULL } },
         // WARNING: xGetFBConfigs not set in symbols13_ext
-        { (PRFuncPtr*) &xGetFBConfigsInternal, { "glXGetFBConfigs", NULL } },
-        { (PRFuncPtr*) &xGetVisualFromFBConfigInternal, { "glXGetVisualFromFBConfig", NULL } },
+        { (PRFuncPtr*) &xGetFBConfigs, { "glXGetFBConfigs", NULL } },
+        { (PRFuncPtr*) &xGetVisualFromFBConfig, { "glXGetVisualFromFBConfig", NULL } },
         // WARNING: symbols13_ext sets xCreateGLXPixmapWithConfig instead
-        { (PRFuncPtr*) &xCreatePixmapInternal, { "glXCreatePixmap", NULL } },
-        { (PRFuncPtr*) &xDestroyPixmapInternal, { "glXDestroyPixmap", NULL } },
-        { (PRFuncPtr*) &xCreateNewContextInternal, { "glXCreateNewContext", NULL } },
+        { (PRFuncPtr*) &xCreatePixmap, { "glXCreatePixmap", NULL } },
+        { (PRFuncPtr*) &xDestroyPixmap, { "glXDestroyPixmap", NULL } },
+        { (PRFuncPtr*) &xCreateNewContext, { "glXCreateNewContext", NULL } },
         { NULL, { NULL } }
     };
 
     LibrarySymbolLoader::SymLoadStruct symbols13_ext[] = {
         /* extension equivalents for functions introduced in GLX 1.3 */
         // GLX_SGIX_fbconfig extension
-        { (PRFuncPtr*) &xChooseFBConfigInternal, { "glXChooseFBConfigSGIX", NULL } },
-        { (PRFuncPtr*) &xGetFBConfigAttribInternal, { "glXGetFBConfigAttribSGIX", NULL } },
+        { (PRFuncPtr*) &xChooseFBConfig, { "glXChooseFBConfigSGIX", NULL } },
+        { (PRFuncPtr*) &xGetFBConfigAttrib, { "glXGetFBConfigAttribSGIX", NULL } },
         // WARNING: no xGetFBConfigs equivalent in extensions
-        { (PRFuncPtr*) &xGetVisualFromFBConfigInternal, { "glXGetVisualFromFBConfig", NULL } },
+        { (PRFuncPtr*) &xGetVisualFromFBConfig, { "glXGetVisualFromFBConfig", NULL } },
         // WARNING: different from symbols13:
-        { (PRFuncPtr*) &xCreateGLXPixmapWithConfigInternal, { "glXCreateGLXPixmapWithConfigSGIX", NULL } },
-        { (PRFuncPtr*) &xDestroyPixmapInternal, { "glXDestroyGLXPixmap", NULL } }, // not from ext
-        { (PRFuncPtr*) &xCreateNewContextInternal, { "glXCreateContextWithConfigSGIX", NULL } },
+        { (PRFuncPtr*) &xCreateGLXPixmapWithConfig, { "glXCreateGLXPixmapWithConfigSGIX", NULL } },
+        { (PRFuncPtr*) &xDestroyPixmap, { "glXDestroyGLXPixmap", NULL } }, // not from ext
+        { (PRFuncPtr*) &xCreateNewContext, { "glXCreateContextWithConfigSGIX", NULL } },
         { NULL, { NULL } }
     };
 
     LibrarySymbolLoader::SymLoadStruct symbols14[] = {
         /* functions introduced in GLX 1.4 */
-        { (PRFuncPtr*) &xGetProcAddressInternal, { "glXGetProcAddress", NULL } },
+        { (PRFuncPtr*) &xGetProcAddress, { "glXGetProcAddress", NULL } },
         { NULL, { NULL } }
     };
 
     LibrarySymbolLoader::SymLoadStruct symbols14_ext[] = {
         /* extension equivalents for functions introduced in GLX 1.4 */
         // GLX_ARB_get_proc_address extension
-        { (PRFuncPtr*) &xGetProcAddressInternal, { "glXGetProcAddressARB", NULL } },
+        { (PRFuncPtr*) &xGetProcAddress, { "glXGetProcAddressARB", NULL } },
         { NULL, { NULL } }
     };
 
     LibrarySymbolLoader::SymLoadStruct symbols_texturefrompixmap[] = {
-        { (PRFuncPtr*) &xBindTexImageInternal, { "glXBindTexImageEXT", NULL } },
-        { (PRFuncPtr*) &xReleaseTexImageInternal, { "glXReleaseTexImageEXT", NULL } },
+        { (PRFuncPtr*) &xBindTexImage, { "glXBindTexImageEXT", NULL } },
+        { (PRFuncPtr*) &xReleaseTexImage, { "glXReleaseTexImageEXT", NULL } },
         { NULL, { NULL } }
     };
 
     if (!LibrarySymbolLoader::LoadSymbols(mOGLLibrary, &symbols[0])) {
         NS_WARNING("Couldn't find required entry point in OpenGL shared library");
         return PR_FALSE;
     }
 
@@ -235,17 +230,17 @@ GLXLibrary::EnsureInitialized()
     }
     if (!LibrarySymbolLoader::LoadSymbols(mOGLLibrary, sym14)) {
         NS_WARNING("Couldn't find required entry point in OpenGL shared library");
         return PR_FALSE;
     }
 
     if (HasExtension(extensionsStr, "GLX_EXT_texture_from_pixmap") &&
         LibrarySymbolLoader::LoadSymbols(mOGLLibrary, symbols_texturefrompixmap, 
-                                         (LibrarySymbolLoader::PlatformLookupFunction)&xGetProcAddress))
+                                         (LibrarySymbolLoader::PlatformLookupFunction)xGetProcAddress))
     {
         mHasTextureFromPixmap = PR_TRUE;
     } else {
         NS_WARNING("Texture from pixmap disabled");
     }
 
     gIsATI = serverVendor && DoesVendorStringMatch(serverVendor, "ATI");
     gIsChromium = (serverVendor &&
@@ -293,17 +288,16 @@ GLXLibrary::CreatePixmap(gfxASurface* aS
                                                  &numFormats));
     if (!cfg) {
         return 0;
     }
     NS_ABORT_IF_FALSE(numFormats > 0,
                  "glXChooseFBConfig() failed to match our requested format and violated its spec (!)");
 
     gfxXlibSurface *xs = static_cast<gfxXlibSurface*>(aSurface);
-    NS_ABORT_IF_FALSE(xs->XDisplay() == display, "This is bad");
 
     int pixmapAttribs[] = { GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
                             GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGBA_EXT,
                             None};
 
     GLXPixmap glxpixmap = xCreatePixmap(display,
                                         cfg[0],
                                         xs->XDrawable(),
@@ -327,311 +321,31 @@ void
 GLXLibrary::BindTexImage(GLXPixmap aPixmap)
 {    
     if (!mHasTextureFromPixmap) {
         return;
     }
 
     Display *display = DefaultXDisplay();
     // Make sure all X drawing to the surface has finished before binding to a texture.
+    XSync(DefaultXDisplay(), False);
     xBindTexImage(display, aPixmap, GLX_FRONT_LEFT_EXT, NULL);
 }
 
 void
 GLXLibrary::ReleaseTexImage(GLXPixmap aPixmap)
 {
     if (!mHasTextureFromPixmap) {
         return;
     }
 
     Display *display = DefaultXDisplay();
     xReleaseTexImage(display, aPixmap, GLX_FRONT_LEFT_EXT);
 }
 
-#ifdef DEBUG
-
-static int (*sOldErrorHandler)(Display *, XErrorEvent *);
-ScopedXErrorHandler::ErrorEvent sErrorEvent;
-static int GLXErrorHandler(Display *display, XErrorEvent *ev)
-{
-    if (!sErrorEvent.mError.error_code) {
-        sErrorEvent.mError = *ev;
-    }
-    return 0;
-}
-
-void
-GLXLibrary::BeforeGLXCall()
-{
-    if (mDebug) {
-        sOldErrorHandler = XSetErrorHandler(GLXErrorHandler);
-    }
-}
-
-void
-GLXLibrary::AfterGLXCall()
-{
-    XSync(DefaultXDisplay(), False);
-    if (mDebug && sErrorEvent.mError.error_code) {
-        char buffer[2048];
-        XGetErrorText(DefaultXDisplay(), sErrorEvent.mError.error_code, buffer, sizeof(buffer));
-        printf_stderr("X ERROR: %s (%i) - Request: %i.%i, Serial: %i",
-                      buffer,
-                      sErrorEvent.mError.error_code,
-                      sErrorEvent.mError.request_code,
-                      sErrorEvent.mError.minor_code,
-                      sErrorEvent.mError.serial);
-        NS_ABORT();
-    }
-    XSetErrorHandler(sOldErrorHandler);
-}
-
-#define BEFORE_GLX_CALL do {                     \
-    sGLXLibrary.BeforeGLXCall();                 \
-} while (0)
-    
-#define AFTER_GLX_CALL do {                      \
-    sGLXLibrary.AfterGLXCall();                  \
-} while (0)
-
-#else
-
-#define BEFORE_GLX_CALL do { } while(0)
-#define AFTER_GLX_CALL do { } while(0)
-
-#endif
-    
-void 
-GLXLibrary::xDestroyContext(Display* display, GLXContext context)
-{
-    BEFORE_GLX_CALL;
-    xDestroyContextInternal(display, context);
-    AFTER_GLX_CALL;
-}
-
-Bool 
-GLXLibrary::xMakeCurrent(Display* display, 
-                         GLXDrawable drawable, 
-                         GLXContext context)
-{
-    BEFORE_GLX_CALL;
-    Bool result = xMakeCurrentInternal(display, drawable, context);
-    AFTER_GLX_CALL;
-    return result;
-}
-
-GLXContext 
-GLXLibrary::xGetCurrentContext()
-{
-    BEFORE_GLX_CALL;
-    GLXContext result = xGetCurrentContextInternal();
-    AFTER_GLX_CALL;
-    return result;
-}
-
-/* static */ void* 
-GLXLibrary::xGetProcAddress(const char *procName)
-{
-    BEFORE_GLX_CALL;
-    void* result = sGLXLibrary.xGetProcAddressInternal(procName);
-    AFTER_GLX_CALL;
-    return result;
-}
-
-GLXFBConfig*
-GLXLibrary::xChooseFBConfig(Display* display, 
-                            int screen, 
-                            const int *attrib_list, 
-                            int *nelements)
-{
-    BEFORE_GLX_CALL;
-    GLXFBConfig* result = xChooseFBConfigInternal(display, screen, attrib_list, nelements);
-    AFTER_GLX_CALL;
-    return result;
-}
-
-GLXFBConfig* 
-GLXLibrary::xGetFBConfigs(Display* display, 
-                          int screen, 
-                          int *nelements)
-{
-    BEFORE_GLX_CALL;
-    GLXFBConfig* result = xGetFBConfigsInternal(display, screen, nelements);
-    AFTER_GLX_CALL;
-    return result;
-}
-    
-GLXContext
-GLXLibrary::xCreateNewContext(Display* display, 
-                              GLXFBConfig config, 
-                              int render_type, 
-                              GLXContext share_list, 
-                              Bool direct)
-{
-    BEFORE_GLX_CALL;
-    GLXContext result = xCreateNewContextInternal(display, config, 
-	                                              render_type,
-	                                              share_list, direct);
-    AFTER_GLX_CALL;
-    return result;
-}
-
-XVisualInfo*
-GLXLibrary::xGetVisualFromFBConfig(Display* display, 
-                                   GLXFBConfig config)
-{
-    BEFORE_GLX_CALL;
-    XVisualInfo* result = xGetVisualFromFBConfigInternal(display, config);
-    AFTER_GLX_CALL;
-    return result;
-}
-
-int
-GLXLibrary::xGetFBConfigAttrib(Display *display,
-                               GLXFBConfig config,
-                               int attribute,
-                               int *value)
-{
-    BEFORE_GLX_CALL;
-    int result = xGetFBConfigAttribInternal(display, config,
-                                            attribute, value);
-    AFTER_GLX_CALL;
-    return result;
-}
-
-void
-GLXLibrary::xSwapBuffers(Display *display, GLXDrawable drawable)
-{
-    BEFORE_GLX_CALL;
-    xSwapBuffersInternal(display, drawable);
-    AFTER_GLX_CALL;
-}
-
-const char *
-GLXLibrary::xQueryExtensionsString(Display *display,
-                                   int screen)
-{
-    BEFORE_GLX_CALL;
-    const char *result = xQueryExtensionsStringInternal(display, screen);
-    AFTER_GLX_CALL;
-    return result;
-}
-
-const char *
-GLXLibrary::xGetClientString(Display *display,
-                             int screen)
-{
-    BEFORE_GLX_CALL;
-    const char *result = xGetClientStringInternal(display, screen);
-    AFTER_GLX_CALL;
-    return result;
-}
-
-const char *
-GLXLibrary::xQueryServerString(Display *display,
-                               int screen, int name)
-{
-    BEFORE_GLX_CALL;
-    const char *result = xQueryServerStringInternal(display, screen, name);
-    AFTER_GLX_CALL;
-    return result;
-}
-
-GLXPixmap
-GLXLibrary::xCreatePixmap(Display *display, 
-                          GLXFBConfig config,
-                          Pixmap pixmap,
-                          const int *attrib_list)
-{
-    BEFORE_GLX_CALL;
-    GLXPixmap result = xCreatePixmapInternal(display, config,
-                                             pixmap, attrib_list);
-    AFTER_GLX_CALL;
-    return result;
-}
-
-GLXPixmap
-GLXLibrary::xCreateGLXPixmapWithConfig(Display *display,
-                                       GLXFBConfig config,
-                                       Pixmap pixmap)
-{
-    BEFORE_GLX_CALL;
-    GLXPixmap result = xCreateGLXPixmapWithConfigInternal(display, config, pixmap);
-    AFTER_GLX_CALL;
-    return result;
-}
-
-void
-GLXLibrary::xDestroyPixmap(Display *display, GLXPixmap pixmap)
-{
-    BEFORE_GLX_CALL;
-    xDestroyPixmapInternal(display, pixmap);
-    AFTER_GLX_CALL;
-}
-
-GLXContext
-GLXLibrary::xCreateContext(Display *display,
-                           XVisualInfo *vis,
-                           GLXContext shareList,
-                           Bool direct)
-{
-    BEFORE_GLX_CALL;
-    GLXContext result = xCreateContextInternal(display, vis, shareList, direct);
-    AFTER_GLX_CALL;
-    return result;
-}
-
-Bool
-GLXLibrary::xQueryVersion(Display *display,
-                          int *major,
-                          int *minor)
-{
-    BEFORE_GLX_CALL;
-    Bool result = xQueryVersionInternal(display, major, minor);
-    AFTER_GLX_CALL;
-    return result;
-}
-
-void
-GLXLibrary::xBindTexImage(Display *display,
-                          GLXDrawable drawable,
-                          int buffer,
-                          const int *attrib_list)
-{
-    BEFORE_GLX_CALL;
-    xBindTexImageInternal(display, drawable, buffer, attrib_list);
-    AFTER_GLX_CALL;
-}
-
-void
-GLXLibrary::xReleaseTexImage(Display *display,
-                             GLXDrawable drawable,
-                             int buffer)
-{
-    BEFORE_GLX_CALL;
-    xReleaseTexImageInternal(display, drawable, buffer);
-    AFTER_GLX_CALL;
-}
-
-void 
-GLXLibrary::xWaitGL()
-{
-    BEFORE_GLX_CALL;
-    xWaitGLInternal();
-    AFTER_GLX_CALL;
-}
-
-void
-GLXLibrary::xWaitX()
-{
-    BEFORE_GLX_CALL;
-    xWaitXInternal();
-    AFTER_GLX_CALL;
-}
-
 GLXLibrary sGLXLibrary;
 
 class GLContextGLX : public GLContext
 {
 public:
     static already_AddRefed<GLContextGLX>
     CreateGLContext(const ContextFormat& format,
                     Display *display,
@@ -747,17 +461,17 @@ TRY_AGAIN_NO_SHARING:
             NS_ASSERTION(succeeded, "Failed to make GL context current!");
         }
 
         return succeeded;
     }
 
     PRBool SetupLookupFunction()
     {
-        mLookupFunc = (PlatformLookupFunction)&GLXLibrary::xGetProcAddress;
+        mLookupFunc = (PlatformLookupFunction)sGLXLibrary.xGetProcAddress;
         return PR_TRUE;
     }
 
     void *GetNativeData(NativeDataType aType)
     {
         switch(aType) {
         case NativeGLContext:
             return mContext;
@@ -779,21 +493,16 @@ TRY_AGAIN_NO_SHARING:
     {
         if (!mDoubleBuffered)
             return PR_FALSE;
         sGLXLibrary.xSwapBuffers(mDisplay, mDrawable);
         sGLXLibrary.xWaitGL();
         return PR_TRUE;
     }
 
-    void WaitForDrawing()
-    {
-        sGLXLibrary.xWaitX();
-    }
-
     PRBool TextureImageSupportsGetBackingSurface()
     {
         return sGLXLibrary.HasTextureFromPixmap();
     }
 
     virtual already_AddRefed<TextureImage>
     CreateTextureImage(const nsIntSize& aSize,
                        TextureImage::ContentType aContentType,
@@ -1336,9 +1045,8 @@ GLContextProviderGLX::GetGlobalContext()
 void
 GLContextProviderGLX::Shutdown()
 {
     gGlobalContext = nsnull;
 }
 
 } /* namespace gl */
 } /* namespace mozilla */
-
--- a/gfx/thebes/GLXLibrary.h
+++ b/gfx/thebes/GLXLibrary.h
@@ -44,185 +44,118 @@ typedef realGLboolean GLboolean;
 
 namespace mozilla {
 namespace gl {
 
 class GLXLibrary
 {
 public:
     GLXLibrary() : mInitialized(PR_FALSE), mTriedInitializing(PR_FALSE),
-                   mHasTextureFromPixmap(PR_FALSE), mDebug(PR_FALSE),
-                   mOGLLibrary(nsnull) {}
+                   mHasTextureFromPixmap(PR_FALSE), mOGLLibrary(nsnull) {}
+
+    typedef void (GLAPIENTRY * PFNGLXDESTROYCONTEXTPROC) (Display*,
+                                                          GLXContext);
+    PFNGLXDESTROYCONTEXTPROC xDestroyContext;
+    typedef Bool (GLAPIENTRY * PFNGLXMAKECURRENTPROC) (Display*,
+                                                       GLXDrawable,
+                                                       GLXContext);
+    PFNGLXMAKECURRENTPROC xMakeCurrent;
+    typedef GLXContext (GLAPIENTRY * PFNGLXGETCURRENTCONTEXT) ();
+    PFNGLXGETCURRENTCONTEXT xGetCurrentContext;
+    typedef void* (GLAPIENTRY * PFNGLXGETPROCADDRESSPROC) (const char *);
+    PFNGLXGETPROCADDRESSPROC xGetProcAddress;
+    typedef GLXFBConfig* (GLAPIENTRY * PFNGLXCHOOSEFBCONFIG) (Display *,
+                                                              int,
+                                                              const int *,
+                                                              int *);
+    PFNGLXCHOOSEFBCONFIG xChooseFBConfig;
+    typedef GLXFBConfig* (GLAPIENTRY * PFNGLXGETFBCONFIGS) (Display *,
+                                                            int,
+                                                            int *);
+    PFNGLXGETFBCONFIGS xGetFBConfigs;
+    typedef GLXContext (GLAPIENTRY * PFNGLXCREATENEWCONTEXT) (Display *,
+                                                              GLXFBConfig,
+                                                              int,
+                                                              GLXContext,
+                                                              Bool);
+    PFNGLXCREATENEWCONTEXT xCreateNewContext;
+    typedef XVisualInfo* (GLAPIENTRY * PFNGLXGETVISUALFROMFBCONFIG) (Display *,
+                                                                     GLXFBConfig);
+    PFNGLXGETVISUALFROMFBCONFIG xGetVisualFromFBConfig;
+    typedef int (GLAPIENTRY * PFNGLXGETFBCONFIGATTRIB) (Display *, 
+                                                        GLXFBConfig,
+                                                        int,
+                                                        int *);
+    PFNGLXGETFBCONFIGATTRIB xGetFBConfigAttrib;
 
-    void xDestroyContext(Display* display, GLXContext context);
-    Bool xMakeCurrent(Display* display, 
-                      GLXDrawable drawable, 
-                      GLXContext context);
-    GLXContext xGetCurrentContext();
-    static void* xGetProcAddress(const char *procName);
-    GLXFBConfig* xChooseFBConfig(Display* display, 
-                                 int screen, 
-                                 const int *attrib_list, 
-                                 int *nelements);
-    GLXFBConfig* xGetFBConfigs(Display* display, 
-                               int screen, 
-                               int *nelements);
-    GLXContext xCreateNewContext(Display* display, 
-                                 GLXFBConfig config, 
-                                 int render_type, 
-                                 GLXContext share_list, 
-                                 Bool direct);
-    XVisualInfo* xGetVisualFromFBConfig(Display* display, 
-                                        GLXFBConfig config);
-    int xGetFBConfigAttrib(Display *display,
-                           GLXFBConfig config,
-                           int attribute,
-                           int *value);
-    void xSwapBuffers(Display *display, GLXDrawable drawable);
-    const char * xQueryExtensionsString(Display *display,
-                                        int screen);
-    const char * xGetClientString(Display *display,
-                                  int screen);
-    const char * xQueryServerString(Display *display,
-                                    int screen, int name);
-    GLXPixmap xCreatePixmap(Display *display, 
-                            GLXFBConfig config,
-                            Pixmap pixmap,
-                            const int *attrib_list);
-    GLXPixmap xCreateGLXPixmapWithConfig(Display *display,
-                                         GLXFBConfig config,
-                                         Pixmap pixmap);
-    void xDestroyPixmap(Display *display, GLXPixmap pixmap);
-    GLXContext xCreateContext(Display *display,
-                              XVisualInfo *vis,
-                              GLXContext shareList,
-                              Bool direct);
-    Bool xQueryVersion(Display *display,
-                       int *major,
-                       int *minor);
-    void xBindTexImage(Display *display,
-                       GLXDrawable drawable,
-                       int buffer,
-                       const int *attrib_list);
-    void xReleaseTexImage(Display *display,
-                          GLXDrawable drawable,
-                          int buffer);
-    void xWaitGL();
-    void xWaitX();
+    typedef void (GLAPIENTRY * PFNGLXSWAPBUFFERS) (Display *,
+                                                   GLXDrawable);
+    PFNGLXSWAPBUFFERS xSwapBuffers;
+    typedef const char * (GLAPIENTRY * PFNGLXQUERYEXTENSIONSSTRING) (Display *,
+                                                                     int);
+    PFNGLXQUERYEXTENSIONSSTRING xQueryExtensionsString;
+    typedef const char * (GLAPIENTRY * PFNGLXGETCLIENTSTRING) (Display *,
+                                                               int);
+    PFNGLXGETCLIENTSTRING xGetClientString;
+    typedef const char * (GLAPIENTRY * PFNGLXQUERYSERVERSTRING) (Display *,
+                                                                 int,
+                                                                 int);
+    PFNGLXQUERYSERVERSTRING xQueryServerString;
+
+    typedef GLXPixmap (GLAPIENTRY * PFNGLXCREATEPIXMAP) (Display *,
+                                                         GLXFBConfig,
+                                                         Pixmap,
+                                                         const int *);
+    PFNGLXCREATEPIXMAP xCreatePixmap;
+    typedef GLXPixmap (GLAPIENTRY * PFNGLXCREATEGLXPIXMAPWITHCONFIG)
+                                                        (Display *,
+                                                         GLXFBConfig,
+                                                         Pixmap);
+    PFNGLXCREATEGLXPIXMAPWITHCONFIG xCreateGLXPixmapWithConfig;
+    typedef void (GLAPIENTRY * PFNGLXDESTROYPIXMAP) (Display *,
+                                                     GLXPixmap);
+    PFNGLXDESTROYPIXMAP xDestroyPixmap;
+    typedef GLXContext (GLAPIENTRY * PFNGLXCREATECONTEXT) (Display *,
+                                                           XVisualInfo *,
+                                                           GLXContext,
+                                                           Bool);
+    PFNGLXCREATECONTEXT xCreateContext;
+    typedef Bool (GLAPIENTRY * PFNGLXQUERYVERSION) (Display *,
+                                                    int *,
+                                                    int *);
+    PFNGLXQUERYVERSION xQueryVersion;
+
+    typedef void (GLAPIENTRY * PFNGLXBINDTEXIMAGE) (Display *,
+                                                    GLXDrawable,
+                                                    int,
+                                                    const int *);
+    PFNGLXBINDTEXIMAGE xBindTexImage;
+
+    typedef void (GLAPIENTRY * PFNGLXRELEASETEXIMAGE) (Display *,
+                                                       GLXDrawable,
+                                                       int);
+    PFNGLXRELEASETEXIMAGE xReleaseTexImage;
+
+    typedef void (GLAPIENTRY * PFNGLXWAITGL) ();
+    PFNGLXWAITGL xWaitGL;
 
     PRBool EnsureInitialized();
 
     GLXPixmap CreatePixmap(gfxASurface* aSurface);
     void DestroyPixmap(GLXPixmap aPixmap);
     void BindTexImage(GLXPixmap aPixmap);
     void ReleaseTexImage(GLXPixmap aPixmap);
 
     PRBool HasTextureFromPixmap() { return mHasTextureFromPixmap; }
     PRBool SupportsTextureFromPixmap(gfxASurface* aSurface);
 
 private:
-    
-    typedef void (GLAPIENTRY * PFNGLXDESTROYCONTEXTPROC) (Display*,
-                                                          GLXContext);
-    PFNGLXDESTROYCONTEXTPROC xDestroyContextInternal;
-    typedef Bool (GLAPIENTRY * PFNGLXMAKECURRENTPROC) (Display*,
-                                                       GLXDrawable,
-                                                       GLXContext);
-    PFNGLXMAKECURRENTPROC xMakeCurrentInternal;
-    typedef GLXContext (GLAPIENTRY * PFNGLXGETCURRENTCONTEXT) ();
-    PFNGLXGETCURRENTCONTEXT xGetCurrentContextInternal;
-    typedef void* (GLAPIENTRY * PFNGLXGETPROCADDRESSPROC) (const char *);
-    PFNGLXGETPROCADDRESSPROC xGetProcAddressInternal;
-    typedef GLXFBConfig* (GLAPIENTRY * PFNGLXCHOOSEFBCONFIG) (Display *,
-                                                              int,
-                                                              const int *,
-                                                              int *);
-    PFNGLXCHOOSEFBCONFIG xChooseFBConfigInternal;
-    typedef GLXFBConfig* (GLAPIENTRY * PFNGLXGETFBCONFIGS) (Display *,
-                                                            int,
-                                                            int *);
-    PFNGLXGETFBCONFIGS xGetFBConfigsInternal;
-    typedef GLXContext (GLAPIENTRY * PFNGLXCREATENEWCONTEXT) (Display *,
-                                                              GLXFBConfig,
-                                                              int,
-                                                              GLXContext,
-                                                              Bool);
-    PFNGLXCREATENEWCONTEXT xCreateNewContextInternal;
-    typedef XVisualInfo* (GLAPIENTRY * PFNGLXGETVISUALFROMFBCONFIG) (Display *,
-                                                                     GLXFBConfig);
-    PFNGLXGETVISUALFROMFBCONFIG xGetVisualFromFBConfigInternal;
-    typedef int (GLAPIENTRY * PFNGLXGETFBCONFIGATTRIB) (Display *, 
-                                                        GLXFBConfig,
-                                                        int,
-                                                        int *);
-    PFNGLXGETFBCONFIGATTRIB xGetFBConfigAttribInternal;
-
-    typedef void (GLAPIENTRY * PFNGLXSWAPBUFFERS) (Display *,
-                                                   GLXDrawable);
-    PFNGLXSWAPBUFFERS xSwapBuffersInternal;
-    typedef const char * (GLAPIENTRY * PFNGLXQUERYEXTENSIONSSTRING) (Display *,
-                                                                     int);
-    PFNGLXQUERYEXTENSIONSSTRING xQueryExtensionsStringInternal;
-    typedef const char * (GLAPIENTRY * PFNGLXGETCLIENTSTRING) (Display *,
-                                                               int);
-    PFNGLXGETCLIENTSTRING xGetClientStringInternal;
-    typedef const char * (GLAPIENTRY * PFNGLXQUERYSERVERSTRING) (Display *,
-                                                                 int,
-                                                                 int);
-    PFNGLXQUERYSERVERSTRING xQueryServerStringInternal;
-
-    typedef GLXPixmap (GLAPIENTRY * PFNGLXCREATEPIXMAP) (Display *,
-                                                         GLXFBConfig,
-                                                         Pixmap,
-                                                         const int *);
-    PFNGLXCREATEPIXMAP xCreatePixmapInternal;
-    typedef GLXPixmap (GLAPIENTRY * PFNGLXCREATEGLXPIXMAPWITHCONFIG)
-                                                        (Display *,
-                                                         GLXFBConfig,
-                                                         Pixmap);
-    PFNGLXCREATEGLXPIXMAPWITHCONFIG xCreateGLXPixmapWithConfigInternal;
-    typedef void (GLAPIENTRY * PFNGLXDESTROYPIXMAP) (Display *,
-                                                     GLXPixmap);
-    PFNGLXDESTROYPIXMAP xDestroyPixmapInternal;
-    typedef GLXContext (GLAPIENTRY * PFNGLXCREATECONTEXT) (Display *,
-                                                           XVisualInfo *,
-                                                           GLXContext,
-                                                           Bool);
-    PFNGLXCREATECONTEXT xCreateContextInternal;
-    typedef Bool (GLAPIENTRY * PFNGLXQUERYVERSION) (Display *,
-                                                    int *,
-                                                    int *);
-    PFNGLXQUERYVERSION xQueryVersionInternal;
-
-    typedef void (GLAPIENTRY * PFNGLXBINDTEXIMAGE) (Display *,
-                                                    GLXDrawable,
-                                                    int,
-                                                    const int *);
-    PFNGLXBINDTEXIMAGE xBindTexImageInternal;
-
-    typedef void (GLAPIENTRY * PFNGLXRELEASETEXIMAGE) (Display *,
-                                                       GLXDrawable,
-                                                       int);
-    PFNGLXRELEASETEXIMAGE xReleaseTexImageInternal;
-
-    typedef void (GLAPIENTRY * PFNGLXWAITGL) ();
-    PFNGLXWAITGL xWaitGLInternal;
-    
-    typedef void (GLAPIENTRY * PFNGLXWAITX) ();
-    PFNGLXWAITGL xWaitXInternal;
-
-#ifdef DEBUG
-    void BeforeGLXCall();
-    void AfterGLXCall();
-#endif
-
     PRBool mInitialized;
     PRBool mTriedInitializing;
     PRBool mHasTextureFromPixmap;
-    PRBool mDebug;
     PRLibrary *mOGLLibrary;
 };
 
 // a global GLXLibrary instance
 extern GLXLibrary sGLXLibrary;
 
 } /* namespace gl */
 } /* namespace mozilla */
--- a/widget/src/xpwidgets/nsBaseWidget.cpp
+++ b/widget/src/xpwidgets/nsBaseWidget.cpp
@@ -773,17 +773,17 @@ nsBaseWidget::AutoUseBasicLayerManager::
 nsBaseWidget::AutoUseBasicLayerManager::~AutoUseBasicLayerManager()
 {
   mWidget->mTemporarilyUseBasicLayerManager = PR_FALSE;
 }
 
 PRBool
 nsBaseWidget::GetShouldAccelerate()
 {
-#if defined(XP_WIN) || defined(ANDROID) || (MOZ_PLATFORM_MAEMO > 5) || (!defined(MOZ_PLATFORM_MAEMO) && defined(MOZ_X11))
+#if defined(XP_WIN) || defined(ANDROID) || (MOZ_PLATFORM_MAEMO > 5)
   PRBool accelerateByDefault = PR_TRUE;
 #elif defined(XP_MACOSX)
 /* quickdraw plugins don't work with OpenGL so we need to avoid OpenGL when we want to support
  * them. e.g. 10.5 */
 # if defined(NP_NO_QUICKDRAW)
   PRBool accelerateByDefault = PR_TRUE;
 
   // 10.6.2 and lower have a bug involving textures and pixel buffer objects