aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-02-01 12:58:00 +0800
committerPo Lu2022-02-01 12:58:00 +0800
commit103ddfe387333891780b93eec652cbcf1519156c (patch)
treed5ff696b3ffeb4a01cb9d3827f2e601f56af741d /src
parent99c637499ec2bc0babb5d98b16f9c578952d54fd (diff)
downloademacs-103ddfe387333891780b93eec652cbcf1519156c.tar.gz
emacs-103ddfe387333891780b93eec652cbcf1519156c.zip
Display images with a mask correctly when `alpha-background' is set
* src/xterm.c (x_query_frame_background_color): Return value adjusted for background alpha. (x_draw_image_glyph_string): Respect `alpha-background' when generating background pixmap.
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c49
1 files changed, 41 insertions, 8 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 2fc336f72a9..843483b594a 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -2993,12 +2993,23 @@ x_query_colors (struct frame *f, XColor *colors, int ncolors)
2993 XQueryColors (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), colors, ncolors); 2993 XQueryColors (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), colors, ncolors);
2994} 2994}
2995 2995
2996/* Store F's background color into *BGCOLOR. */ 2996/* Store F's real background color into *BGCOLOR. */
2997 2997
2998static void 2998static void
2999x_query_frame_background_color (struct frame *f, XColor *bgcolor) 2999x_query_frame_background_color (struct frame *f, XColor *bgcolor)
3000{ 3000{
3001 bgcolor->pixel = FRAME_BACKGROUND_PIXEL (f); 3001 unsigned long background = FRAME_BACKGROUND_PIXEL (f);
3002
3003 if (FRAME_DISPLAY_INFO (f)->alpha_bits)
3004 {
3005 background = (background & ~FRAME_DISPLAY_INFO (f)->alpha_mask);
3006 background |= (((unsigned long) (f->alpha_background * 0xffff)
3007 >> (16 - FRAME_DISPLAY_INFO (f)->alpha_bits))
3008 << FRAME_DISPLAY_INFO (f)->alpha_offset);
3009 }
3010
3011 bgcolor->pixel = background;
3012
3002 x_query_colors (f, bgcolor, 1); 3013 x_query_colors (f, bgcolor, 1);
3003} 3014}
3004 3015
@@ -4075,12 +4086,34 @@ x_draw_image_glyph_string (struct glyph_string *s)
4075 else 4086 else
4076 { 4087 {
4077 XGCValues xgcv; 4088 XGCValues xgcv;
4078 XGetGCValues (display, s->gc, GCForeground | GCBackground, 4089#if defined HAVE_XRENDER && (RENDER_MAJOR > 0 || (RENDER_MINOR >= 2))
4079 &xgcv); 4090 if (FRAME_DISPLAY_INFO (s->f)->alpha_bits
4080 XSetForeground (display, s->gc, xgcv.background); 4091 && FRAME_CHECK_XR_VERSION (s->f, 0, 2)
4081 XFillRectangle (display, pixmap, s->gc, 4092 && FRAME_X_PICTURE_FORMAT (s->f))
4082 0, 0, s->background_width, s->height); 4093 {
4083 XSetForeground (display, s->gc, xgcv.foreground); 4094 XRenderColor xc;
4095 XRenderPictureAttributes attrs;
4096 Picture pict;
4097 memset (&attrs, 0, sizeof attrs);
4098
4099 pict = XRenderCreatePicture (display, pixmap,
4100 FRAME_X_PICTURE_FORMAT (s->f),
4101 0, &attrs);
4102 x_xrender_color_from_gc_background (s->f, s->gc, &xc, true);
4103 XRenderFillRectangle (FRAME_X_DISPLAY (s->f), PictOpSrc, pict,
4104 &xc, 0, 0, s->background_width, s->height);
4105 XRenderFreePicture (display, pict);
4106 }
4107 else
4108#endif
4109 {
4110 XGetGCValues (display, s->gc, GCForeground | GCBackground,
4111 &xgcv);
4112 XSetForeground (display, s->gc, xgcv.background);
4113 XFillRectangle (display, pixmap, s->gc,
4114 0, 0, s->background_width, s->height);
4115 XSetForeground (display, s->gc, xgcv.foreground);
4116 }
4084 } 4117 }
4085 } 4118 }
4086 else 4119 else