emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master d539d00c42: Improve image depth handling


From: Po Lu
Subject: master d539d00c42: Improve image depth handling
Date: Thu, 3 Feb 2022 19:54:12 -0500 (EST)

branch: master
commit d539d00c4263e1d494213a0bcec655036405bd2e
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Improve image depth handling
    
    Emacs defaults to a 32-bit TrueColor visual, but if that happens
    on a display which defaults to 16-bit TrueColor, yet happens to
    have 32-bit color, and doesn't have the X Render Extension, an
    error will occur in x_composite_image as libXpm will load
    pixmaps of depth 16 instead of depth 32.
    
    * src/image.c (x_create_x_image_and_pixmap): Explictly specify
    display depth.
    (x_create_xrender_picture):
    (xpm_load):
    (gs_load): Use dpyinfo->n_planes instead of
    DefaultDepthOfScreen.
---
 src/image.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/image.c b/src/image.c
index 32e03ab6f7..7f2bd77781 100644
--- a/src/image.c
+++ b/src/image.c
@@ -2848,13 +2848,12 @@ x_create_x_image_and_pixmap (struct frame *f, int 
width, int height, int depth,
 {
   Display *display = FRAME_X_DISPLAY (f);
   Drawable drawable = FRAME_X_DRAWABLE (f);
-  Screen *screen = FRAME_X_SCREEN (f);
 
   eassert (input_blocked_p ());
 
   if (depth <= 0)
-    depth = DefaultDepthOfScreen (screen);
-  *ximg = XCreateImage (display, DefaultVisualOfScreen (screen),
+    depth = FRAME_DISPLAY_INFO (f)->n_planes;
+  *ximg = XCreateImage (display, FRAME_X_VISUAL (f),
                        depth, ZPixmap, 0, NULL, width, height,
                        depth > 16 ? 32 : depth > 8 ? 16 : 8, 0);
   if (*ximg == NULL)
@@ -2910,7 +2909,7 @@ x_create_xrender_picture (struct frame *f, Emacs_Pixmap 
pixmap, int depth)
   if (FRAME_DISPLAY_INFO (f)->xrender_supported_p)
     {
       if (depth <= 0)
-       depth = DefaultDepthOfScreen (FRAME_X_SCREEN (f));
+       depth = FRAME_DISPLAY_INFO (f)->n_planes;
       if (depth == 32 || depth == 24 || depth == 8 || depth == 4 || depth == 1)
         {
           /* FIXME: Do we need to handle all possible bit depths?
@@ -4632,8 +4631,10 @@ xpm_load (struct frame *f, struct image *img)
 #ifndef HAVE_NTGUI
   attrs.visual = FRAME_X_VISUAL (f);
   attrs.colormap = FRAME_X_COLORMAP (f);
+  attrs.depth = FRAME_DISPLAY_INFO (f)->n_planes;
   attrs.valuemask |= XpmVisual;
   attrs.valuemask |= XpmColormap;
+  attrs.valuemask |= XpmDepth;
 #endif /* HAVE_NTGUI */
 
 #ifdef ALLOC_XPM_COLORS
@@ -11024,7 +11025,7 @@ gs_load (struct frame *f, struct image *img)
       block_input ();
       img->pixmap = XCreatePixmap (FRAME_X_DISPLAY (f), FRAME_X_DRAWABLE (f),
                                   img->width, img->height,
-                                  DefaultDepthOfScreen (FRAME_X_SCREEN (f)));
+                                  FRAME_DISPLAY_INFO (f)->n_planes);
       unblock_input ();
     }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]