b=1015218 add pref to remove Xlib offscreen surfaces on GTK3 platform r=karlt
authorFrederic Plourde <frederic.plourde@collabora.com>
Wed, 23 Jul 2014 11:04:47 +1200
changeset 195628 6e532c9826e7
parent 195627 742e074af971
child 195629 a500c62330d4
push id27188
push usercbook@mozilla.com
push date2014-07-23 13:53 +0000
treeherdermozilla-central@785acfd2ae48 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs1015218
milestone34.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
b=1015218 add pref to remove Xlib offscreen surfaces on GTK3 platform r=karlt This patch adds a new pref called "layers.use-image-offscreen-surfaces" that makes GTK3 platform create gfxImageSurfaces for content layers instead of gfxXlibSurfaces.
gfx/thebes/gfxPlatformGtk.cpp
gfx/thebes/gfxPlatformGtk.h
gfx/thebes/gfxPrefs.h
widget/shared/nsShmImage.cpp
--- a/gfx/thebes/gfxPlatformGtk.cpp
+++ b/gfx/thebes/gfxPlatformGtk.cpp
@@ -88,17 +88,19 @@ gfxPlatformGtk::CreateOffscreenSurface(c
     bool needsClear = true;
     gfxImageFormat imageFormat = OptimalFormatForContent(contentType);
 #ifdef MOZ_X11
     // XXX we really need a different interface here, something that passes
     // in more context, including the display and/or target surface type that
     // we should try to match
     GdkScreen *gdkScreen = gdk_screen_get_default();
     if (gdkScreen) {
-        if (UseXRender()) {
+        // When forcing Thebes Layers to use image surfaces for content,
+        // force creation of gfxImageSurface surfaces.
+        if (UseXRender() && !UseImageOffscreenSurfaces()) {
             Screen *screen = gdk_x11_screen_get_xscreen(gdkScreen);
             XRenderPictFormat* xrenderFormat =
                 gfxXlibSurface::FindRenderFormat(DisplayOfScreen(screen),
                                                  imageFormat);
 
             if (xrenderFormat) {
                 newSurface = gfxXlibSurface::Create(screen, xrenderFormat,
                                                     ThebesIntSize(size));
--- a/gfx/thebes/gfxPlatformGtk.h
+++ b/gfx/thebes/gfxPlatformGtk.h
@@ -2,16 +2,17 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef GFX_PLATFORM_GTK_H
 #define GFX_PLATFORM_GTK_H
 
 #include "gfxPlatform.h"
+#include "gfxPrefs.h"
 #include "nsAutoRef.h"
 #include "nsTArray.h"
 
 #if (MOZ_WIDGET_GTK == 2)
 extern "C" {
     typedef struct _GdkDrawable GdkDrawable;
 }
 #endif
@@ -83,16 +84,26 @@ public:
             return false;
 
         return sUseXRender;
 #else
         return false;
 #endif
     }
 
+    bool UseImageOffscreenSurfaces() {
+        // We want to turn on image offscreen surfaces ONLY for GTK3 builds
+        // since GTK2 theme rendering still requires xlib surfaces per se.
+#if (MOZ_WIDGET_GTK == 3)
+        return gfxPrefs::UseImageOffscreenSurfaces();
+#else
+        return false;
+#endif
+    }
+
     virtual gfxImageFormat GetOffscreenFormat();
 
     virtual int GetScreenDepth() const;
 
 protected:
     static gfxFontconfigUtils *sFontconfigUtils;
 
 private:
--- a/gfx/thebes/gfxPrefs.h
+++ b/gfx/thebes/gfxPrefs.h
@@ -235,16 +235,17 @@ private:
   DECL_GFX_PREF(Live, "layers.frame-counter",                  DrawFrameCounter, bool, false);
   DECL_GFX_PREF(Live, "layers.low-precision-buffer",           UseLowPrecisionBuffer, bool, false);
   DECL_GFX_PREF(Live, "layers.low-precision-resolution",       LowPrecisionResolution, float, 0.25f);
   DECL_GFX_PREF(Live, "layers.low-precision-opacity",          LowPrecisionOpacity, float, 1.0f);
   DECL_GFX_PREF(Once, "layers.offmainthreadcomposition.enabled", LayersOffMainThreadCompositionEnabled, bool, false);
   DECL_GFX_PREF(Live, "layers.offmainthreadcomposition.frame-rate", LayersCompositionFrameRate, int32_t,-1);
   DECL_GFX_PREF(Once, "layers.offmainthreadcomposition.force-enabled", LayersOffMainThreadCompositionForceEnabled, bool, false);
   DECL_GFX_PREF(Once, "layers.offmainthreadcomposition.testing.enabled", LayersOffMainThreadCompositionTestingEnabled, bool, false);
+  DECL_GFX_PREF(Once, "layers.use-image-offscreen-surfaces",   UseImageOffscreenSurfaces, bool, false);
   DECL_GFX_PREF(Live, "layers.orientation.sync.timeout",       OrientationSyncMillis, uint32_t, (uint32_t)0);
   DECL_GFX_PREF(Once, "layers.prefer-d3d9",                    LayersPreferD3D9, bool, false);
   DECL_GFX_PREF(Once, "layers.prefer-opengl",                  LayersPreferOpenGL, bool, false);
   DECL_GFX_PREF(Once, "layers.progressive-paint",              UseProgressiveTilePainting, bool, false);
   DECL_GFX_PREF(Once, "layers.scroll-graph",                   LayersScrollGraph, bool, false);
   DECL_GFX_PREF(Once, "layers.uniformity-info",                UniformityInfo, bool, false);
 
   DECL_GFX_PREF(Once, "layout.css.touch_action.enabled",       TouchActionEnabled, bool, false);
--- a/widget/shared/nsShmImage.cpp
+++ b/widget/shared/nsShmImage.cpp
@@ -7,31 +7,35 @@
 #if defined(MOZ_WIDGET_GTK)
 #include <gtk/gtk.h>
 #include <gdk/gdkx.h>
 #elif defined(MOZ_WIDGET_QT)
 #include <QWindow>
 #endif
 
 #include "nsShmImage.h"
-#include "gfxPlatform.h"
+#ifdef MOZ_WIDGET_GTK
+#include "gfxPlatformGtk.h"
+#endif
 #include "gfxImageSurface.h"
 
 #ifdef MOZ_HAVE_SHMIMAGE
 
 using namespace mozilla::ipc;
 
 // If XShm isn't available to our client, we'll try XShm once, fail,
 // set this to false and then never try again.
 static bool gShmAvailable = true;
 bool nsShmImage::UseShm()
 {
-    return gfxPlatform::GetPlatform()->
-        ScreenReferenceSurface()->GetType() == gfxSurfaceType::Image
-        && gShmAvailable;
+#ifdef MOZ_WIDGET_GTK
+    return (gShmAvailable && !gfxPlatformGtk::GetPlatform()->UseXRender());
+#else
+    return gShmAvailable;
+#endif
 }
 
 already_AddRefed<nsShmImage>
 nsShmImage::Create(const gfxIntSize& aSize,
                    Visual* aVisual, unsigned int aDepth)
 {
     Display* dpy = DISPLAY();