Blame SOURCES/0001-iconcache-Avoid-xrender-picture-formats-when-creatin.patch

657d8e
From 80f79e0cc7509b79b38193a006b0d98d03432044 Mon Sep 17 00:00:00 2001
657d8e
From: Ray Strode <rstrode@redhat.com>
657d8e
Date: Mon, 5 Aug 2019 14:39:21 -0400
657d8e
Subject: [PATCH] iconcache: Avoid xrender picture formats when creating cairo
657d8e
 surface
657d8e
657d8e
If an application provides its window icon via wmhints, then mutter
657d8e
loads the pixmap specified by the application into a cairo xlib surface. When
657d8e
creating the surface it specifies the visual, indirectly, via an XRender
657d8e
picture format.
657d8e
657d8e
This is suboptimal, since XRender picture formats don't have a way to specify
657d8e
16bpp depth, which an application may be using.
657d8e
657d8e
In particular, applications are likely to use 16bpp depth pixmaps for their
657d8e
icons, if the video card offers a 16bpp framebuffer/root window.
657d8e
657d8e
This commit drops the XRender middleman, and just tells cairo a visual to use
657d8e
directly.
657d8e
657d8e
https://gitlab.gnome.org/GNOME/mutter/merge_requests/715
657d8e
---
657d8e
 src/x11/iconcache.c | 31 ++++++-------------------------
657d8e
 1 file changed, 6 insertions(+), 25 deletions(-)
657d8e
657d8e
diff --git a/src/x11/iconcache.c b/src/x11/iconcache.c
657d8e
index 15d72da65..521c77b8d 100644
657d8e
--- a/src/x11/iconcache.c
657d8e
+++ b/src/x11/iconcache.c
657d8e
@@ -261,97 +261,78 @@ get_pixmap_geometry (MetaX11Display *x11_display,
657d8e
                      Pixmap          pixmap,
657d8e
                      int            *w,
657d8e
                      int            *h,
657d8e
                      int            *d)
657d8e
 {
657d8e
   Window root_ignored;
657d8e
   int x_ignored, y_ignored;
657d8e
   guint width, height;
657d8e
   guint border_width_ignored;
657d8e
   guint depth;
657d8e
 
657d8e
   if (w)
657d8e
     *w = 1;
657d8e
   if (h)
657d8e
     *h = 1;
657d8e
   if (d)
657d8e
     *d = 1;
657d8e
 
657d8e
   XGetGeometry (x11_display->xdisplay,
657d8e
                 pixmap, &root_ignored, &x_ignored, &y_ignored,
657d8e
                 &width, &height, &border_width_ignored, &depth);
657d8e
 
657d8e
   if (w)
657d8e
     *w = width;
657d8e
   if (h)
657d8e
     *h = height;
657d8e
   if (d)
657d8e
     *d = depth;
657d8e
 }
657d8e
 
657d8e
-static int
657d8e
-standard_pict_format_for_depth (int depth)
657d8e
-{
657d8e
-  switch (depth)
657d8e
-    {
657d8e
-    case 1:
657d8e
-      return PictStandardA1;
657d8e
-    case 24:
657d8e
-      return PictStandardRGB24;
657d8e
-    case 32:
657d8e
-      return PictStandardARGB32;
657d8e
-    default:
657d8e
-      g_assert_not_reached ();
657d8e
-    }
657d8e
-  return 0;
657d8e
-}
657d8e
-
657d8e
-static XRenderPictFormat *
657d8e
-pict_format_for_depth (Display *xdisplay, int depth)
657d8e
-{
657d8e
-  return XRenderFindStandardFormat (xdisplay, standard_pict_format_for_depth (depth));
657d8e
-}
657d8e
-
657d8e
 static cairo_surface_t *
657d8e
 surface_from_pixmap (Display *xdisplay, Pixmap xpixmap,
657d8e
                      int width, int height)
657d8e
 {
657d8e
   Window root_return;
657d8e
+  XVisualInfo visual_info;
657d8e
   int x_ret, y_ret;
657d8e
   unsigned int w_ret, h_ret, bw_ret, depth_ret;
657d8e
 
657d8e
   if (!XGetGeometry (xdisplay, xpixmap, &root_return,
657d8e
                      &x_ret, &y_ret, &w_ret, &h_ret, &bw_ret, &depth_ret))
657d8e
     return NULL;
657d8e
 
657d8e
-  return cairo_xlib_surface_create_with_xrender_format (xdisplay, xpixmap, DefaultScreenOfDisplay (xdisplay),
657d8e
-                                                        pict_format_for_depth (xdisplay, depth_ret), w_ret, h_ret);
657d8e
+  if (!XMatchVisualInfo (xdisplay, DefaultScreen (xdisplay),
657d8e
+                         depth_ret, TrueColor, &visual_info))
657d8e
+    return NULL;
657d8e
+
657d8e
+  return cairo_xlib_surface_create (xdisplay, xpixmap, visual_info.visual, w_ret, h_ret);
657d8e
 }
657d8e
 
657d8e
 static gboolean
657d8e
 try_pixmap_and_mask (MetaX11Display   *x11_display,
657d8e
                      Pixmap            src_pixmap,
657d8e
                      Pixmap            src_mask,
657d8e
                      cairo_surface_t **iconp)
657d8e
 {
657d8e
   Display *xdisplay = x11_display->xdisplay;
657d8e
   cairo_surface_t *icon, *mask = NULL;
657d8e
   int w, h, d;
657d8e
 
657d8e
   if (src_pixmap == None)
657d8e
     return FALSE;
657d8e
 
657d8e
   meta_x11_error_trap_push (x11_display);
657d8e
 
657d8e
   get_pixmap_geometry (x11_display, src_pixmap, &w, &h, &d);
657d8e
   icon = surface_from_pixmap (xdisplay, src_pixmap, w, h);
657d8e
 
657d8e
   if (icon && src_mask != None)
657d8e
     {
657d8e
       get_pixmap_geometry (x11_display, src_mask, &w, &h, &d);
657d8e
 
657d8e
       if (d == 1)
657d8e
         mask = surface_from_pixmap (xdisplay, src_mask, w, h);
657d8e
     }
657d8e
 
657d8e
   meta_x11_error_trap_pop (x11_display);
657d8e
 
657d8e
-- 
657d8e
2.21.0
657d8e