aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-01-30 16:02:58 +0800
committerPo Lu2022-01-30 16:02:58 +0800
commit988d3d79bac0343dd2b1b89d1b15470edbb5e6ac (patch)
tree409e2712157f77a87e07c75957b4087b10f001f5 /src
parent26a9acc86ae4e646b17570f009dcdf566f75c3de (diff)
downloademacs-988d3d79bac0343dd2b1b89d1b15470edbb5e6ac.tar.gz
emacs-988d3d79bac0343dd2b1b89d1b15470edbb5e6ac.zip
Use XRender to composite fringe bitmaps
This will allow us to apply transforms such as scaling in the future. * src/xterm.c (x_draw_fringe_bitmap): Composite fringe bitmaps with XRender if available.
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c57
1 files changed, 50 insertions, 7 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 0ecebfb4205..e41319e95ec 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -1976,9 +1976,15 @@ x_draw_fringe_bitmap (struct window *w, struct glyph_row *row, struct draw_fring
1976 { 1976 {
1977 Drawable drawable = FRAME_X_DRAWABLE (f); 1977 Drawable drawable = FRAME_X_DRAWABLE (f);
1978 char *bits; 1978 char *bits;
1979 Pixmap pixmap, clipmask = (Pixmap) 0; 1979 Pixmap pixmap, clipmask = None;
1980 int depth = FRAME_DISPLAY_INFO (f)->n_planes; 1980 int depth = FRAME_DISPLAY_INFO (f)->n_planes;
1981 XGCValues gcv; 1981 XGCValues gcv;
1982#ifdef HAVE_XRENDER
1983 Picture picture = None;
1984 XRenderPictureAttributes attrs;
1985
1986 memset (&attrs, 0, sizeof attrs);
1987#endif
1982 1988
1983 if (p->wd > 8) 1989 if (p->wd > 8)
1984 bits = (char *) (p->bits + p->dh); 1990 bits = (char *) (p->bits + p->dh);
@@ -1994,20 +2000,57 @@ x_draw_fringe_bitmap (struct window *w, struct glyph_row *row, struct draw_fring
1994 : face->foreground), 2000 : face->foreground),
1995 face->background, depth); 2001 face->background, depth);
1996 2002
2003#ifdef HAVE_XRENDER
2004 if (FRAME_X_PICTURE_FORMAT (f)
2005 && (x_xr_ensure_picture (f), FRAME_X_PICTURE (f)))
2006 picture = XRenderCreatePicture (display, pixmap,
2007 FRAME_X_PICTURE_FORMAT (f),
2008 0, &attrs);
2009#endif
2010
1997 if (p->overlay_p) 2011 if (p->overlay_p)
1998 { 2012 {
1999 clipmask = XCreatePixmapFromBitmapData (display, 2013 clipmask = XCreatePixmapFromBitmapData (display,
2000 FRAME_DISPLAY_INFO (f)->root_window, 2014 FRAME_DISPLAY_INFO (f)->root_window,
2001 bits, p->wd, p->h, 2015 bits, p->wd, p->h,
2002 1, 0, 1); 2016 1, 0, 1);
2003 gcv.clip_mask = clipmask; 2017
2004 gcv.clip_x_origin = p->x; 2018#ifdef HAVE_XRENDER
2005 gcv.clip_y_origin = p->y; 2019 if (picture != None)
2006 XChangeGC (display, gc, GCClipMask | GCClipXOrigin | GCClipYOrigin, &gcv); 2020 {
2021 attrs.clip_mask = clipmask;
2022 attrs.clip_x_origin = p->x;
2023 attrs.clip_y_origin = p->y;
2024
2025 XRenderChangePicture (display, FRAME_X_PICTURE (f),
2026 CPClipMask | CPClipXOrigin | CPClipYOrigin,
2027 &attrs);
2028 }
2029 else
2030#endif
2031 {
2032 gcv.clip_mask = clipmask;
2033 gcv.clip_x_origin = p->x;
2034 gcv.clip_y_origin = p->y;
2035 XChangeGC (display, gc, GCClipMask | GCClipXOrigin | GCClipYOrigin, &gcv);
2036 }
2007 } 2037 }
2008 2038
2009 XCopyArea (display, pixmap, drawable, gc, 0, 0, 2039#ifdef HAVE_XRENDER
2010 p->wd, p->h, p->x, p->y); 2040 if (picture != None)
2041 {
2042 x_xr_apply_ext_clip (f, gc);
2043 XRenderComposite (display, PictOpSrc, picture,
2044 None, FRAME_X_PICTURE (f),
2045 0, 0, 0, 0, p->x, p->y, p->wd, p->h);
2046 x_xr_reset_ext_clip (f);
2047
2048 XRenderFreePicture (display, picture);
2049 }
2050 else
2051#endif
2052 XCopyArea (display, pixmap, drawable, gc, 0, 0,
2053 p->wd, p->h, p->x, p->y);
2011 XFreePixmap (display, pixmap); 2054 XFreePixmap (display, pixmap);
2012 2055
2013 if (p->overlay_p) 2056 if (p->overlay_p)