diff options
author | Po Lu <luangruo@yahoo.com> | 2022-01-24 12:44:55 +0800 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2022-01-24 12:44:55 +0800 |
commit | 45208755d13f23f92edcab4d6959e0fd9423843b (patch) | |
tree | 95bdca80a788eeedd491e2ae54941ba2af3a7644 /src/xterm.h | |
parent | 3a7b158ffd8d468eb92de1de6418b3831f10142b (diff) | |
download | emacs-45208755d13f23f92edcab4d6959e0fd9423843b.tar.gz |
Add some code for transparent frame backgrounds without Cairo
* src/image.c (svg_load_image): Fix build without native image
transforms.
* src/xfns.c (set_up_x_back_buffer):
(tear_down_x_back_buffer): Free XR picture if present.
* src/xftfont.c (xftfont_get_xft_draw): Fix formatting issue.
* src/xterm.c (x_xr_ensure_picture): New function.
(FRAME_CR_CONTEXT, FRAME_CR_CONTEXT):
(FRAME_CR_SURFACE_DESIRED_WIDTH)
(FRAME_CR_SURFACE_DESIRED_HEIGHT): Move to separate USE_CAIRO
block so the ext data code can be used on builds with XRender as
well.
(x_xr_apply_ext_clip):
(x_xr_reset_ext_clip): New functions.
(x_set_clip_rectangles):
(x_reset_clip_rectangles): Set ext data on XRender as well.
(x_term_init): Look for a picture format appropriate for our
purposes.
(x_clear_area): Use XRenderFillRectangle to draw backgrounds if
available.
(x_xrender_color_from_gc_foreground):
(x_xrender_color_from_gc_background): New functions.
* src/xterm.h (FRAME_X_PICTURE):
(FRAME_X_PICTURE_FORMAT)
(FRAME_CHECK_XR_VERSION): New macros.
(struct x_gc_ext_data): Define on XRender as well.
(struct x_display_info): Define ext_codes when using XRender and
add new field `pict_format'.
(struct x_output): New field `picture'.
Diffstat (limited to 'src/xterm.h')
-rw-r--r-- | src/xterm.h | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/src/xterm.h b/src/xterm.h index a4ad57eddaa..33887be52b0 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -54,6 +54,10 @@ typedef Widget xt_or_gtk_widget; #define GTK_CHECK_VERSION(i, j, k) false #endif +#ifdef HAVE_XRENDER +#include <X11/extensions/Xrender.h> +#endif + #ifdef USE_GTK /* Some definitions to reduce conditionals. */ typedef GtkWidget *xt_or_gtk_widget; @@ -148,7 +152,7 @@ struct x_bitmap_record int height, width, depth; }; -#ifdef USE_CAIRO +#if defined USE_CAIRO || defined HAVE_XRENDER struct x_gc_ext_data { #define MAX_CLIP_RECTS 2 @@ -158,7 +162,9 @@ struct x_gc_ext_data /* Clipping rectangles. */ XRectangle clip_rects[MAX_CLIP_RECTS]; }; +#endif +#ifdef USE_CAIRO extern cairo_pattern_t *x_bitmap_stipple (struct frame *, Pixmap); #endif @@ -239,6 +245,11 @@ struct x_display_info /* The Visual being used for this display. */ Visual *visual; +#ifdef HAVE_XRENDER + /* The picture format for this display. */ + XRenderPictFormat *pict_format; +#endif + /* The colormap being used. */ Colormap cmap; @@ -509,7 +520,7 @@ struct x_display_info int xrandr_minor_version; #endif -#ifdef USE_CAIRO +#if defined USE_CAIRO || defined HAVE_XRENDER XExtCodes *ext_codes; #endif @@ -616,6 +627,13 @@ struct x_output window's back buffer. */ Drawable draw_desc; +#ifdef HAVE_XRENDER + /* The Xrender picture that corresponds to this drawable. None + means no picture format was found, or the Xrender extension is + not present. */ + Picture picture; +#endif + /* Flag that indicates whether we've modified the back buffer and need to publish our modifications to the front buffer at a convenient time. */ @@ -933,6 +951,17 @@ extern void x_mark_frame_dirty (struct frame *f); /* This is the Visual which frame F is on. */ #define FRAME_X_VISUAL(f) FRAME_DISPLAY_INFO (f)->visual +#ifdef HAVE_XRENDER +#define FRAME_X_PICTURE_FORMAT(f) FRAME_DISPLAY_INFO (f)->pict_format +#define FRAME_X_PICTURE(f) ((f)->output_data.x->picture) +#define FRAME_CHECK_XR_VERSION(f, major, minor) \ + (FRAME_DISPLAY_INFO (f)->xrender_supported_p \ + && ((FRAME_DISPLAY_INFO (f)->xrender_major == (major) \ + && FRAME_DISPLAY_INFO (f)->xrender_minor >= (minor)) \ + || (FRAME_DISPLAY_INFO (f)->xrender_major > (major)))) +#endif + + /* This is the Colormap which frame F uses. */ #define FRAME_X_COLORMAP(f) FRAME_DISPLAY_INFO (f)->cmap @@ -1212,6 +1241,11 @@ extern void x_cr_draw_frame (cairo_t *, struct frame *); extern Lisp_Object x_cr_export_frames (Lisp_Object, cairo_surface_type_t); #endif +#ifdef HAVE_XRENDER +extern void x_xrender_color_from_gc_foreground (struct frame *, GC, XRenderColor *); +extern void x_xrender_color_from_gc_background (struct frame *, GC, XRenderColor *); +#endif + INLINE int x_display_pixel_height (struct x_display_info *dpyinfo) { |