aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-02-04 08:51:24 +0800
committerPo Lu2022-02-04 08:54:01 +0800
commitd539d00c4263e1d494213a0bcec655036405bd2e (patch)
tree3aa696fa7a2570c2b82b6761bf161506b45168c5 /src
parent12a6d319dcff5f1954f926be979b81170df2806c (diff)
downloademacs-d539d00c4263e1d494213a0bcec655036405bd2e.tar.gz
emacs-d539d00c4263e1d494213a0bcec655036405bd2e.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/image.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/image.c b/src/image.c
index 32e03ab6f75..7f2bd77781e 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,
2848{ 2848{
2849 Display *display = FRAME_X_DISPLAY (f); 2849 Display *display = FRAME_X_DISPLAY (f);
2850 Drawable drawable = FRAME_X_DRAWABLE (f); 2850 Drawable drawable = FRAME_X_DRAWABLE (f);
2851 Screen *screen = FRAME_X_SCREEN (f);
2852 2851
2853 eassert (input_blocked_p ()); 2852 eassert (input_blocked_p ());
2854 2853
2855 if (depth <= 0) 2854 if (depth <= 0)
2856 depth = DefaultDepthOfScreen (screen); 2855 depth = FRAME_DISPLAY_INFO (f)->n_planes;
2857 *ximg = XCreateImage (display, DefaultVisualOfScreen (screen), 2856 *ximg = XCreateImage (display, FRAME_X_VISUAL (f),
2858 depth, ZPixmap, 0, NULL, width, height, 2857 depth, ZPixmap, 0, NULL, width, height,
2859 depth > 16 ? 32 : depth > 8 ? 16 : 8, 0); 2858 depth > 16 ? 32 : depth > 8 ? 16 : 8, 0);
2860 if (*ximg == NULL) 2859 if (*ximg == NULL)
@@ -2910,7 +2909,7 @@ x_create_xrender_picture (struct frame *f, Emacs_Pixmap pixmap, int depth)
2910 if (FRAME_DISPLAY_INFO (f)->xrender_supported_p) 2909 if (FRAME_DISPLAY_INFO (f)->xrender_supported_p)
2911 { 2910 {
2912 if (depth <= 0) 2911 if (depth <= 0)
2913 depth = DefaultDepthOfScreen (FRAME_X_SCREEN (f)); 2912 depth = FRAME_DISPLAY_INFO (f)->n_planes;
2914 if (depth == 32 || depth == 24 || depth == 8 || depth == 4 || depth == 1) 2913 if (depth == 32 || depth == 24 || depth == 8 || depth == 4 || depth == 1)
2915 { 2914 {
2916 /* FIXME: Do we need to handle all possible bit depths? 2915 /* FIXME: Do we need to handle all possible bit depths?
@@ -4632,8 +4631,10 @@ xpm_load (struct frame *f, struct image *img)
4632#ifndef HAVE_NTGUI 4631#ifndef HAVE_NTGUI
4633 attrs.visual = FRAME_X_VISUAL (f); 4632 attrs.visual = FRAME_X_VISUAL (f);
4634 attrs.colormap = FRAME_X_COLORMAP (f); 4633 attrs.colormap = FRAME_X_COLORMAP (f);
4634 attrs.depth = FRAME_DISPLAY_INFO (f)->n_planes;
4635 attrs.valuemask |= XpmVisual; 4635 attrs.valuemask |= XpmVisual;
4636 attrs.valuemask |= XpmColormap; 4636 attrs.valuemask |= XpmColormap;
4637 attrs.valuemask |= XpmDepth;
4637#endif /* HAVE_NTGUI */ 4638#endif /* HAVE_NTGUI */
4638 4639
4639#ifdef ALLOC_XPM_COLORS 4640#ifdef ALLOC_XPM_COLORS
@@ -11024,7 +11025,7 @@ gs_load (struct frame *f, struct image *img)
11024 block_input (); 11025 block_input ();
11025 img->pixmap = XCreatePixmap (FRAME_X_DISPLAY (f), FRAME_X_DRAWABLE (f), 11026 img->pixmap = XCreatePixmap (FRAME_X_DISPLAY (f), FRAME_X_DRAWABLE (f),
11026 img->width, img->height, 11027 img->width, img->height,
11027 DefaultDepthOfScreen (FRAME_X_SCREEN (f))); 11028 FRAME_DISPLAY_INFO (f)->n_planes);
11028 unblock_input (); 11029 unblock_input ();
11029 } 11030 }
11030 11031