Bug 1516224 - [Linux/Gtk] Disable ARGB toplevel visual on X11 SW compositor due to visible graphics artifacts, r=lsalzman
authorMartin Stransky <stransky@redhat.com>
Tue, 15 Jan 2019 17:45:35 +0000
changeset 511078 8d104c49d7e2e5063a2cd1027586e39fd5a7f0bb
parent 511077 06f2abbc4a597718dc4ada6823c11e2d6b8dbeaa
child 511079 006df494925adbd6ad79a3281b78dcb506939b8b
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslsalzman
bugs1516224
milestone66.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 1516224 - [Linux/Gtk] Disable ARGB toplevel visual on X11 SW compositor due to visible graphics artifacts, r=lsalzman Differential Revision: https://phabricator.services.mozilla.com/D16561
widget/gtk/nsWindow.cpp
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -3169,24 +3169,16 @@ nsresult nsWindow::Create(nsIWidget *aPa
   GdkWindow *parentGdkWindow = nullptr;
   GtkWindow *topLevelParent = nullptr;
   nsWindow *parentnsWindow = nullptr;
   GtkWidget *eventWidget = nullptr;
   bool drawToContainer = false;
   bool needsAlphaVisual =
       (mWindowType == eWindowType_popup && aInitData->mSupportTranslucency);
 
-  // Some Gtk+ themes use non-rectangular toplevel windows. To fully support
-  // such themes we need to make toplevel window transparent with ARGB visual.
-  // It may cause performanance issue so make it configurable
-  // and enable it by default for selected window managers.
-  if (mWindowType == eWindowType_toplevel) {
-    needsAlphaVisual = TopLevelWindowUseARGBVisual();
-  }
-
   if (aParent) {
     parentnsWindow = static_cast<nsWindow *>(aParent);
     parentGdkWindow = parentnsWindow->mGdkWindow;
   } else if (aNativeParent && GDK_IS_WINDOW(aNativeParent)) {
     parentGdkWindow = GDK_WINDOW(aNativeParent);
     parentnsWindow = get_window_for_gdk_window(parentGdkWindow);
     if (!parentnsWindow) return NS_ERROR_FAILURE;
 
@@ -3223,28 +3215,38 @@ nsresult nsWindow::Create(nsIWidget *aPa
       // popup window position.
       GtkWindowType type = GTK_WINDOW_TOPLEVEL;
       if (mWindowType == eWindowType_popup) {
         type = (mIsX11Display && aInitData->mNoAutoHide) ? GTK_WINDOW_TOPLEVEL
                                                          : GTK_WINDOW_POPUP;
       }
       mShell = gtk_window_new(type);
 
-      bool isSetVisual = false;
-#ifdef MOZ_X11
       // Ensure gfxPlatform is initialized, since that is what initializes
       // gfxVars, used below.
       Unused << gfxPlatform::GetPlatform();
 
       bool useWebRender =
           gfx::gfxVars::UseWebRender() && AllowWebRenderForThisWindow();
 
       bool shouldAccelerate = ComputeShouldAccelerate();
       MOZ_ASSERT(shouldAccelerate | !useWebRender);
 
+      // Some Gtk+ themes use non-rectangular toplevel windows. To fully support
+      // such themes we need to make toplevel window transparent with ARGB visual.
+      // It may cause performanance issue so make it configurable
+      // and enable it by default for selected window managers.
+      // Also disable it for X11 SW rendering (Bug 1516224) by default.
+      if (mWindowType == eWindowType_toplevel &&
+          (shouldAccelerate || !mIsX11Display ||
+            Preferences::HasUserValue("mozilla.widget.use-argb-visuals"))) {
+          needsAlphaVisual = TopLevelWindowUseARGBVisual();
+      }
+
+      bool isSetVisual = false;
       // If using WebRender on X11, we need to select a visual with a depth
       // buffer, as well as an alpha channel if transparency is requested. This
       // must be done before the widget is realized.
 
       // Use GL/WebRender compatible visual only when it is necessary, since
       // the visual consumes more memory.
       if (mIsX11Display && shouldAccelerate) {
         auto display = GDK_DISPLAY_XDISPLAY(gtk_widget_get_display(mShell));
@@ -3258,17 +3260,16 @@ nsresult nsWindow::Create(nsIWidget *aPa
           gtk_widget_set_visual(mShell,
                                 gdk_x11_screen_lookup_visual(screen, visualId));
           mHasAlphaVisual = needsAlphaVisual;
           isSetVisual = true;
         } else {
           NS_WARNING("We're missing X11 Visual!");
         }
       }
-#endif  // MOZ_X11
 
       if (!isSetVisual && needsAlphaVisual) {
         GdkScreen *screen = gtk_widget_get_screen(mShell);
         if (gdk_screen_is_composited(screen)) {
           GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
           if (visual) {
             gtk_widget_set_visual(mShell, visual);
             mHasAlphaVisual = true;