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

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