Bug 1481694 - Use GLContextGLX::FindVisual() when webrender is not enabled if possible r=stransky
authorsotaro <sotaro.ikeda.g@gmail.com>
Fri, 12 Oct 2018 08:49:21 +0900
changeset 499277 ba0c3051a9ed3b8e3120eb25d770ea459d3f719d
parent 499276 81c3640eaebc47516247f546b2203ec550fdd37a
child 499278 d699af334ae27f961d06def962b91bb9f1063309
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersstransky
bugs1481694
milestone64.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 1481694 - Use GLContextGLX::FindVisual() when webrender is not enabled if possible r=stransky
widget/gtk/nsWindow.cpp
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -3719,56 +3719,57 @@ nsWindow::Create(nsIWidget* aParent,
         // 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();
 
         // 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.
-        if (mIsX11Display && useWebRender) {
+        if (mIsX11Display) {
             auto display =
                 GDK_DISPLAY_XDISPLAY(gtk_widget_get_display(mShell));
             auto screen = gtk_widget_get_screen(mShell);
             int screenNumber = GDK_SCREEN_XNUMBER(screen);
             int visualId = 0;
             if (GLContextGLX::FindVisual(display, screenNumber,
                                          useWebRender, needsAlphaVisual,
                                          &visualId)) {
                 // If we're using CSD, rendering will go through mContainer, but
                 // it will inherit this visual as it is a child of mShell.
                 gtk_widget_set_visual(mShell,
                                       gdk_x11_screen_lookup_visual(screen,
                                                                    visualId));
                 mHasAlphaVisual = needsAlphaVisual;
+                isSetVisual = true;
             } else {
-                NS_WARNING("We're missing X11 Visual for WebRender!");
+                NS_WARNING("We're missing X11 Visual!");
             }
-        } else
+        }
 #endif // MOZ_X11
-        {
-            if (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;
-                    }
+
+        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;
                 }
             }
         }
 
         // We have a toplevel window with transparency. Mark it as transparent
         // now as nsWindow::SetTransparencyMode() can't be called after
         // nsWindow is created (Bug 1344839).
         if (mWindowType == eWindowType_toplevel && mHasAlphaVisual) {