Bug 743830: Added 'gfx.xrender.enableded' pref (true by default). The pref is fetched in gfPlatformGtk.cpp and can be accessed through gfxPlatformGtk::UseXRender(). UseXRender is used in GLContextProviderGLX to set mUseTextureFromPixmap. r=jrmuizel,gw280
☠☠ backed out by 19780b0d3567 ☠ ☠
authorNicolas Silva <nsilva@mozilla.com>
Wed, 11 Apr 2012 14:04:54 -0400
changeset 94944 e20a19a790dd484cf270d8cad262dfaeacd6d3f3
parent 94943 c7145f4ebd47111a29062433fda105df6ab223ef
child 94945 33552f5d803d7983325f893562a0e3e3591e617d
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel, gw280
bugs743830
milestone14.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 743830: Added 'gfx.xrender.enableded' pref (true by default). The pref is fetched in gfPlatformGtk.cpp and can be accessed through gfxPlatformGtk::UseXRender(). UseXRender is used in GLContextProviderGLX to set mUseTextureFromPixmap. r=jrmuizel,gw280
gfx/gl/GLContextProviderGLX.cpp
gfx/gl/GLXLibrary.h
gfx/thebes/gfxPlatformGtk.cpp
gfx/thebes/gfxPlatformGtk.h
modules/libpref/src/init/all.js
--- a/gfx/gl/GLContextProviderGLX.cpp
+++ b/gfx/gl/GLContextProviderGLX.cpp
@@ -52,17 +52,17 @@
 #include "GLContextProvider.h"
 #include "GLLibraryLoader.h"
 #include "nsDebug.h"
 #include "nsIWidget.h"
 #include "GLXLibrary.h"
 #include "gfxXlibSurface.h"
 #include "gfxContext.h"
 #include "gfxImageSurface.h"
-#include "gfxPlatform.h"
+#include "gfxPlatformGtk.h"
 #include "GLContext.h"
 #include "gfxUtils.h"
 
 #include "gfxCrashReporterUtils.h"
 
 namespace mozilla {
 namespace gl {
 
@@ -246,17 +246,17 @@ GLXLibrary::EnsureInitialized()
         NS_WARNING("Couldn't find required entry point in OpenGL shared library");
         return false;
     }
 
     if (HasExtension(extensionsStr, "GLX_EXT_texture_from_pixmap") &&
         GLLibraryLoader::LoadSymbols(mOGLLibrary, symbols_texturefrompixmap, 
                                          (GLLibraryLoader::PlatformLookupFunction)&xGetProcAddress))
     {
-        mHasTextureFromPixmap = true;
+        mUseTextureFromPixmap = gfxPlatformGtk::UseXRender();
     } else {
         NS_WARNING("Texture from pixmap disabled");
     }
 
     if (HasExtension(extensionsStr, "GLX_ARB_create_context_robustness") &&
         GLLibraryLoader::LoadSymbols(mOGLLibrary, symbols_robustness)) {
         mHasRobustness = true;
     }
@@ -273,17 +273,17 @@ GLXLibrary::EnsureInitialized()
 
 bool
 GLXLibrary::SupportsTextureFromPixmap(gfxASurface* aSurface)
 {
     if (!EnsureInitialized()) {
         return false;
     }
     
-    if (aSurface->GetType() != gfxASurface::SurfaceTypeXlib || !mHasTextureFromPixmap) {
+    if (aSurface->GetType() != gfxASurface::SurfaceTypeXlib || !mUseTextureFromPixmap) {
         return false;
     }
 
     return true;
 }
 
 GLXPixmap 
 GLXLibrary::CreatePixmap(gfxASurface* aSurface)
@@ -323,41 +323,41 @@ GLXLibrary::CreatePixmap(gfxASurface* aS
                                         pixmapAttribs);
 
     return glxpixmap;
 }
 
 void
 GLXLibrary::DestroyPixmap(GLXPixmap aPixmap)
 {
-    if (!mHasTextureFromPixmap) {
+    if (!mUseTextureFromPixmap) {
         return;
     }
 
     Display *display = DefaultXDisplay();
     xDestroyPixmap(display, aPixmap);
 }
 
 void
 GLXLibrary::BindTexImage(GLXPixmap aPixmap)
 {    
-    if (!mHasTextureFromPixmap) {
+    if (!mUseTextureFromPixmap) {
         return;
     }
 
     Display *display = DefaultXDisplay();
     // Make sure all X drawing to the surface has finished before binding to a texture.
     xWaitX();
     xBindTexImage(display, aPixmap, GLX_FRONT_LEFT_EXT, NULL);
 }
 
 void
 GLXLibrary::ReleaseTexImage(GLXPixmap aPixmap)
 {
-    if (!mHasTextureFromPixmap) {
+    if (!mUseTextureFromPixmap) {
         return;
     }
 
     Display *display = DefaultXDisplay();
     xReleaseTexImage(display, aPixmap, GLX_FRONT_LEFT_EXT);
 }
 
 #ifdef DEBUG
@@ -838,17 +838,17 @@ TRY_AGAIN_NO_SHARING:
             return false;
         sGLXLibrary.xSwapBuffers(mDisplay, mDrawable);
         sGLXLibrary.xWaitGL();
         return true;
     }
 
     bool TextureImageSupportsGetBackingSurface()
     {
-        return sGLXLibrary.HasTextureFromPixmap();
+        return sGLXLibrary.UseTextureFromPixmap();
     }
 
     virtual already_AddRefed<TextureImage>
     CreateTextureImage(const nsIntSize& aSize,
                        TextureImage::ContentType aContentType,
                        GLenum aWrapMode,
                        bool aUseNearestFilter = false);
 
--- a/gfx/gl/GLXLibrary.h
+++ b/gfx/gl/GLXLibrary.h
@@ -44,17 +44,17 @@ typedef realGLboolean GLboolean;
 
 namespace mozilla {
 namespace gl {
 
 class GLXLibrary
 {
 public:
     GLXLibrary() : mInitialized(false), mTriedInitializing(false),
-                   mHasTextureFromPixmap(false), mDebug(false),
+                   mUseTextureFromPixmap(false), mDebug(false),
                    mHasRobustness(false), mOGLLibrary(nsnull) {}
 
     void xDestroyContext(Display* display, GLXContext context);
     Bool xMakeCurrent(Display* display, 
                       GLXDrawable drawable, 
                       GLXContext context);
     GLXContext xGetCurrentContext();
     static void* xGetProcAddress(const char *procName);
@@ -116,17 +116,17 @@ public:
 
     bool EnsureInitialized();
 
     GLXPixmap CreatePixmap(gfxASurface* aSurface);
     void DestroyPixmap(GLXPixmap aPixmap);
     void BindTexImage(GLXPixmap aPixmap);
     void ReleaseTexImage(GLXPixmap aPixmap);
 
-    bool HasTextureFromPixmap() { return mHasTextureFromPixmap; }
+    bool UseTextureFromPixmap() { return mUseTextureFromPixmap; }
     bool HasRobustness() { return mHasRobustness; }
     bool SupportsTextureFromPixmap(gfxASurface* aSurface);
 
 private:
     
     typedef void (GLAPIENTRY * PFNGLXDESTROYCONTEXTPROC) (Display*,
                                                           GLXContext);
     PFNGLXDESTROYCONTEXTPROC xDestroyContextInternal;
@@ -225,17 +225,17 @@ private:
 
 #ifdef DEBUG
     void BeforeGLXCall();
     void AfterGLXCall();
 #endif
 
     bool mInitialized;
     bool mTriedInitializing;
-    bool mHasTextureFromPixmap;
+    bool mUseTextureFromPixmap;
     bool mDebug;
     bool mHasRobustness;
     PRLibrary *mOGLLibrary;
 };
 
 // a global GLXLibrary instance
 extern GLXLibrary sGLXLibrary;
 
--- a/gfx/thebes/gfxPlatformGtk.cpp
+++ b/gfx/thebes/gfxPlatformGtk.cpp
@@ -62,16 +62,17 @@
 #include "cairo.h"
 #include <gtk/gtk.h>
 
 #include "gfxImageSurface.h"
 #ifdef MOZ_X11
 #include <gdk/gdkx.h>
 #include "gfxXlibSurface.h"
 #include "cairo-xlib.h"
+#include "mozilla/Preferences.h"
 
 /* Undefine the Status from Xlib since it will conflict with system headers on OSX */
 #if defined(__APPLE__) && defined(Status)
 #undef Status
 #endif
 
 #endif /* MOZ_X11 */
 
@@ -99,24 +100,30 @@ static FT_Library gPlatformFTLibrary = N
 
 static cairo_user_data_key_t cairo_gdk_drawable_key;
 static void do_gdk_drawable_unref (void *data)
 {
     GdkDrawable *d = (GdkDrawable*) data;
     g_object_unref (d);
 }
 
+#ifdef MOZ_X11
+    bool gfxPlatformGtk::sUseXRender = false;
+#endif
+
 gfxPlatformGtk::gfxPlatformGtk()
 {
     if (!sFontconfigUtils)
         sFontconfigUtils = gfxFontconfigUtils::GetFontconfigUtils();
+#ifdef MOZ_X11
+    sUseXRender = mozilla::Preferences::GetBool("gfx.xrender.enabled");
+#endif
 
 #ifndef MOZ_PANGO
     FT_Init_FreeType(&gPlatformFTLibrary);
-
     gPlatformFonts = new FontTable();
     gPlatformFonts->Init(100);
     gPlatformFontAliases = new FontTable();
     gPlatformFontAliases->Init(100);
     gPrefFonts = new PrefFontTable();
     gPrefFonts->Init(100);
     gCodepointsWithNoFonts = new gfxSparseBitSet();
     UpdateFontList();
@@ -173,17 +180,17 @@ gfxPlatformGtk::CreateOffscreenSurface(c
     // we should try to match
     GdkScreen *gdkScreen = gdk_screen_get_default();
     if (gdkScreen) {
         // try to optimize it for 16bpp default screen
         if (gfxASurface::CONTENT_COLOR == contentType) {
             imageFormat = GetOffscreenFormat();
         }
 
-        if (UseClientSideRendering()) {
+        if (UseXRender()) {
             // We're not going to use XRender, so we don't need to
             // search for a render format
             newSurface = new gfxImageSurface(size, imageFormat);
             // The gfxImageSurface ctor zeroes this for us, no need to
             // waste time clearing again
             needsClear = false;
         } else {
             Screen *screen = gdk_x11_screen_get_xscreen(gdkScreen);
--- a/gfx/thebes/gfxPlatformGtk.h
+++ b/gfx/thebes/gfxPlatformGtk.h
@@ -124,35 +124,40 @@ public:
 #endif
 
     static void SetGdkDrawable(gfxASurface *target,
                                GdkDrawable *drawable);
     static GdkDrawable *GetGdkDrawable(gfxASurface *target);
 
     static PRInt32 GetDPI();
 
-    static bool UseClientSideRendering() {
+    static bool UseXRender() {
 #if defined(MOZ_X11) && defined(MOZ_PLATFORM_MAEMO)
         // XRender is not accelerated on the Maemo at the moment, and 
         // X server pixman is out of our control; it's likely to be 
         // older than (our) cairo's.   So fall back on software 
         // rendering for more predictable performance.
         // This setting will likely not be relevant when we have
         // GL-accelerated compositing. We know of other platforms 
         // with bad drivers where we'd like to also use client side 
         // rendering, but until we have the ability to featuer test 
         // this, we'll only disable this for maemo.
         return true;
+#elif defined(MOZ_X11)
+        return sUseXRender;
 #else
         return false;
 #endif
     }
 
     virtual gfxImageFormat GetOffscreenFormat();
 
 protected:
     static gfxFontconfigUtils *sFontconfigUtils;
 
 private:
     virtual qcms_profile *GetPlatformCMSOutputProfile();
+#ifdef MOZ_X11
+    static bool sUseXRender;
+#endif
 };
 
 #endif /* GFX_PLATFORM_GTK_H */
--- a/modules/libpref/src/init/all.js
+++ b/modules/libpref/src/init/all.js
@@ -3426,16 +3426,20 @@ pref("layers.acceleration.disabled", fal
 
 // Whether to force acceleration on, ignoring blacklists.
 pref("layers.acceleration.force-enabled", false);
 
 pref("layers.acceleration.draw-fps", false);
 
 pref("layers.offmainthreadcomposition.enabled", false);
 
+#ifdef MOZ_X11
+pref("gfx.xrender.enabled",true);
+#endif
+
 #ifdef XP_WIN
 // Whether to disable the automatic detection and use of direct2d.
 #ifdef MOZ_E10S_COMPAT
 pref("gfx.direct2d.disabled", true);
 #else
 pref("gfx.direct2d.disabled", false);
 #endif
 // Whether to attempt to enable Direct2D regardless of automatic detection or