Bug 1251984 - allow gfx.xrender.enabled pref to work for compositing even if content backend is not Cairo. r=jrmuizel
authorLee Salzman <lsalzman@mozilla.com>
Tue, 01 Mar 2016 14:33:53 -0500
changeset 322684 e13aaaaf196229acb1bcd77f0ab9e5ad3ada7d9a
parent 322683 1846e981637e0547c9b7935b2329580e03780259
child 322685 134e5a1235557d8ffa0a9b04dd00fef1ff10ae3e
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1251984
milestone47.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 1251984 - allow gfx.xrender.enabled pref to work for compositing even if content backend is not Cairo. r=jrmuizel
gfx/thebes/gfxPlatformGtk.cpp
gfx/thebes/gfxPlatformGtk.h
gfx/thebes/gfxXlibNativeRenderer.cpp
widget/gtk/nsWindow.cpp
widget/nsShmImage.cpp
--- a/gfx/thebes/gfxPlatformGtk.cpp
+++ b/gfx/thebes/gfxPlatformGtk.cpp
@@ -345,23 +345,18 @@ gfxPlatformGtk::GetDPIScale()
     // to CSS dpi (96)
     int32_t dpi = GetDPI();
     return (dpi > 96) ? round(dpi/96.0) : 1.0;
 }
 
 bool
 gfxPlatformGtk::UseImageOffscreenSurfaces()
 {
-    // We want to turn on image offscreen surfaces ONLY for GTK3 builds since
-    // GTK2 theme rendering still requires xlib surfaces.
-#if (MOZ_WIDGET_GTK == 3)
-    return gfxPrefs::UseImageOffscreenSurfaces();
-#else
-    return false;
-#endif
+    return GetDefaultContentBackend() != mozilla::gfx::BackendType::CAIRO ||
+           gfxPrefs::UseImageOffscreenSurfaces();
 }
 
 gfxImageFormat
 gfxPlatformGtk::GetOffscreenFormat()
 {
     // Make sure there is a screen
     GdkScreen *screen = gdk_screen_get_default();
     if (screen && gdk_visual_get_depth(gdk_visual_get_system()) == 16) {
--- a/gfx/thebes/gfxPlatformGtk.h
+++ b/gfx/thebes/gfxPlatformGtk.h
@@ -95,20 +95,16 @@ public:
     static GdkDrawable *GetGdkDrawable(cairo_surface_t *target);
 #endif
 
     static int32_t GetDPI();
     static double  GetDPIScale();
 
     bool UseXRender() {
 #if defined(MOZ_X11)
-        if (GetDefaultContentBackend() != mozilla::gfx::BackendType::NONE &&
-            GetDefaultContentBackend() != mozilla::gfx::BackendType::CAIRO)
-            return false;
-
         return sUseXRender;
 #else
         return false;
 #endif
     }
 
 #ifdef MOZ_X11
     virtual void GetAzureBackendInfo(mozilla::widget::InfoObject &aObj) override {
--- a/gfx/thebes/gfxXlibNativeRenderer.cpp
+++ b/gfx/thebes/gfxXlibNativeRenderer.cpp
@@ -532,21 +532,17 @@ gfxXlibNativeRenderer::Draw(gfxContext* 
 
     gfxPoint offset(drawingRect.x, drawingRect.y);
 
     DrawingMethod method;
     Matrix dtTransform = drawTarget->GetTransform();
     gfxPoint deviceTranslation = gfxPoint(dtTransform._31, dtTransform._32);
     cairo_t* cairo = static_cast<cairo_t*>
         (drawTarget->GetNativeSurface(NativeSurfaceType::CAIRO_CONTEXT));
-    if (!cairo) {
-        return;
-    }
-
-    cairo_surface_t* cairoTarget = cairo_get_group_target(cairo);
+    cairo_surface_t* cairoTarget = cairo ? cairo_get_group_target(cairo) : nullptr;
     cairo_surface_t* tempXlibSurface =
         CreateTempXlibSurface(cairoTarget, drawTarget, size,
                               canDrawOverBackground, flags, screen, visual,
                               &method);
     if (!tempXlibSurface) {
         return;
     }
 
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -6491,16 +6491,19 @@ nsWindow::GetDrawTarget(const LayoutDevi
   if (!mGdkWindow || aRegion.IsEmpty()) {
     return nullptr;
   }
 
   RefPtr<DrawTarget> dt;
 
 #ifdef MOZ_X11
 #  ifdef MOZ_HAVE_SHMIMAGE
+#    ifdef MOZ_WIDGET_GTK
+  if (!gfxPlatformGtk::GetPlatform()->UseXRender())
+#    endif
   if (nsShmImage::UseShm()) {
     mBackShmImage.swap(mFrontShmImage);
     if (!mBackShmImage) {
       mBackShmImage = new nsShmImage(mXDisplay, mXWindow, mXVisual, mXDepth);
     }
     dt = mBackShmImage->CreateDrawTarget(aRegion);
     *aBufferMode = BufferMode::BUFFER_NONE;
     if (!dt) {
--- a/widget/nsShmImage.cpp
+++ b/widget/nsShmImage.cpp
@@ -1,22 +1,20 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  *
  * 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/. */
 
 #include "nsShmImage.h"
-#ifdef MOZ_WIDGET_GTK
-#include "gfxPlatformGtk.h"
-#endif
 
 #ifdef MOZ_HAVE_SHMIMAGE
 #include "mozilla/X11Util.h"
 #include "mozilla/ipc/SharedMemory.h"
+#include "gfxPlatform.h"
 #include "nsPrintfCString.h"
 #include "nsTArray.h"
 
 #include <errno.h>
 #include <string.h>
 #include <sys/ipc.h>
 #include <sys/shm.h>
 
@@ -46,21 +44,17 @@ nsShmImage::~nsShmImage()
   DestroyImage();
 }
 
 // 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()
 {
-#ifdef MOZ_WIDGET_GTK
-  return (gShmAvailable && !gfxPlatformGtk::GetPlatform()->UseXRender());
-#else
   return gShmAvailable;
-#endif
 }
 
 static int gShmError = 0;
 
 static int
 TrapShmError(Display* aDisplay, XErrorEvent* aEvent)
 {
   // store the error code and ignore the error
@@ -149,17 +143,17 @@ nsShmImage::InitExtension()
 
   gShmEvent = XShmGetEventBase(mDisplay);
   if (gShmEvent < 0) {
     gShmAvailable = false;
     return false;
   }
 
   if (pixmaps && XShmPixmapFormat(mDisplay) == ZPixmap) {
-    gShmPixmapAtom = XInternAtom(mDisplay, "_MOZ_SHM_PIXMAP", 0);
+    gShmPixmapAtom = XInternAtom(mDisplay, "_MOZ_SHM_PIXMAP", False);
   }
 
   return true;
 }
 
 bool
 nsShmImage::CreateImage(const IntSize& aSize)
 {