Bug 1498982 - Use GL/WebRender compatible visual only when it is necessary necessary r=nical
authorsotaro <sotaro.ikeda.g@gmail.com>
Tue, 16 Oct 2018 21:14:52 +0900
changeset 489762 085738995db1c63fd00b3ddec8f084190833eb0a
parent 489761 daed617054ce114772d208c79bbe8cd8d858d310
child 489763 97be1d70d0cd4637a4bd02e984d179b3f1a600e8
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersnical
bugs1498982
milestone64.0a1
Bug 1498982 - Use GL/WebRender compatible visual only when it is necessary necessary r=nical
widget/gtk/nsWindow.cpp
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -3726,22 +3726,28 @@ nsWindow::Create(nsIWidget* aParent,
 
         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();
+             AllowWebRenderForThisWindow();
+
+        bool shouldAccelerate = ComputeShouldAccelerate();
+        MOZ_ASSERT(shouldAccelerate | !useWebRender);
 
         // 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) {
+
+        // 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));
             auto screen = gtk_widget_get_screen(mShell);
             int screenNumber = GDK_SCREEN_XNUMBER(screen);
             int visualId = 0;
             if (GLContextGLX::FindVisual(display, screenNumber,
                                          useWebRender, needsAlphaVisual,
                                          &visualId)) {