Bug 1516224 - [Linux/Gtk] Disable ARGB toplevel visual on X11 SW compositor due to visible graphics artifacts, r=lsalzman, a=RyanVM
authorMartin Stransky <stransky@redhat.com>
Tue, 15 Jan 2019 17:45:35 +0000
changeset 509517 561137bf321030c3bb2c7cfb692f85d3ccda4622
parent 509516 b0abaa9984f6b6434da2477ffdbfa0307b115f32
child 509518 7f847507d3bb84ed438fe58b898d07e15cab9a32
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslsalzman, RyanVM
bugs1516224
milestone65.0
Bug 1516224 - [Linux/Gtk] Disable ARGB toplevel visual on X11 SW compositor due to visible graphics artifacts, r=lsalzman, a=RyanVM Differential Revision: https://phabricator.services.mozilla.com/D16561
widget/gtk/nsWindow.cpp
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -3359,24 +3359,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;
 
@@ -3413,28 +3405,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));
@@ -3448,17 +3450,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;