Commit c89900eb authored by YAMAMOTO Mitsuharu's avatar YAMAMOTO Mitsuharu

Rework cairo image support to improve consistency (Bug#35871)

* src/dispextern.h (Emacs_Pix_Container) [USE_CAIRO]: New struct.  Also used
as aliases of Emacs_Pixmap and Emacs_Pix_Context.
(x_kill_gs_process) [USE_CAIRO]: #ifdef out extern.
(RGB_PIXEL_COLOR) [USE_CAIRO]: Define as unsigned long.

* src/image.c: Include stdint.h.  On cairo, remove existing image support
code, use non-X11-specific code for XBM/XPM, and remove POSTSCRIPT support.
(PUT_PIXEL): New macro.  Use it instead of XPutPixel when not specific to X11.
(image_create_pix_container, image_pix_container_put_pixel)
(image_pix_context_get_pixel, image_pix_container_create_from_bitmap_data)
(cr_create_cr_surface_from_image) [USE_CAIRO]: New functions.
(image_create_x_image_and_pixmap_1, image_destroy_x_image)
(image_check_image_size): Extract X11-specific code from here ...
(x_create_x_image_and_pixmap, x_destroy_x_image)
(x_check_image_size) [HAVE_X_WINDOWS]: ... to here.
(x_create_bitmap_mask) [HAVE_X_WINDOWS]: Use them.  Inline specialized version
of four_corners_best.
(prepare_image_for_display, image_clear_image_1, image_destroy_x_image)
(gui_put_x_image, image_put_x_image, image_get_x_image, image_unget_x_image)
(Create_Pixmap_From_Bitmap_Data, lookup_rgb_color)
(image_to_emacs_colors) [USE_CAIRO]: Add cairo support.
(image_background, png_load_body) [USE_CAIRO]: Use image_alloc_image_color for
(image_sync_to_pixmaps) [USE_CAIRO]: #ifdef out function.
(Create_Pixmap_From_Bitmap_Data) [HAVE_X_WINDOWS]: Move image_check_image_size
call from here ...
(xbm_load_image): ... to here.
(image_build_heuristic_mask, pbm_load, gif_load) [USE_CAIRO]: Use
lookup_rgb_color for argument of PUT_PIXEL.
(image_pixmap_draw_cross) [HAVE_X_WINDOWS || USE_CAIRO]: New function.
(image_disable_image) [HAVE_X_WINDOWS || USE_CAIRO]: Use it.
(CrossForeground) [!HAVE_NTGUI && !HAVE_NS]: New macro.
(image_disable_image) [!HAVE_NTGUI && !HAVE_NS]: Use it.

* src/xterm.c (handle_one_xevent) <ClientMessage> [USE_CAIRO]: #ifdef out
x_kill_gs_process call.
(x_free_pixmap) [USE_CAIRO]: Free Emacs_Pix_Container and data it contains.
parent 09dce0fd
Pipeline #1826 failed with stage
in 50 minutes and 52 seconds
......@@ -38,7 +38,9 @@ along with GNU Emacs. If not, see <>. */
typedef XColor Emacs_Color;
typedef Cursor Emacs_Cursor;
#define No_Cursor (None)
#ifndef USE_CAIRO
typedef Pixmap Emacs_Pixmap;
typedef XRectangle Emacs_Rectangle;
typedef XGCValues Emacs_GC;
#else /* !HAVE_X_WINDOWS */
......@@ -92,11 +94,26 @@ xstrcasecmp (char const *a, char const *b)
#include <X11/Xresource.h> /* for XrmDatabase */
typedef struct x_display_info Display_Info;
#ifndef USE_CAIRO
typedef XImage *Emacs_Pix_Container;
typedef XImage *Emacs_Pix_Context;
#endif /* !USE_CAIRO */
#define NativeRectangle XRectangle
#ifdef USE_CAIRO
/* Mininal version of XImage. */
typedef struct
int width, height; /* size of image */
char *data; /* pointer to image data */
int bytes_per_line; /* accelarator to next line */
int bits_per_pixel; /* bits per pixel (ZPixmap) */
} *Emacs_Pix_Container;
typedef Emacs_Pix_Container Emacs_Pixmap;
typedef Emacs_Pix_Container Emacs_Pix_Context;
#include "w32gui.h"
typedef struct w32_display_info Display_Info;
......@@ -3396,7 +3413,9 @@ extern void image_destroy_bitmap (struct frame *, ptrdiff_t);
extern void image_destroy_all_bitmaps (Display_Info *);
extern void x_create_bitmap_mask (struct frame *, ptrdiff_t);
#ifndef USE_CAIRO
extern void x_kill_gs_process (Pixmap, struct frame *);
#endif /* !USE_CAIRO */
extern Lisp_Object image_find_image_file (Lisp_Object);
......@@ -3408,7 +3427,7 @@ bool valid_image_p (Lisp_Object);
void prepare_image_for_display (struct frame *, struct image *);
ptrdiff_t lookup_image (struct frame *, Lisp_Object);
#if defined (HAVE_X_WINDOWS) || defined (HAVE_NS)
#if defined HAVE_X_WINDOWS || defined USE_CAIRO || defined HAVE_NS
#define RGB_PIXEL_COLOR unsigned long
This diff is collapsed.
......@@ -7794,12 +7794,14 @@ handle_one_xevent (struct x_display_info *dpyinfo,
reply with "Next" if we received "Page", but we
currently never do because we are interested in
images, only, which should have 1 page. */
Pixmap pixmap = (Pixmap) event->[1];
f = x_window_to_frame (dpyinfo, event->xclient.window);
if (!f)
goto OTHER;
#ifndef USE_CAIRO
Pixmap pixmap = (Pixmap) event->[1];
x_kill_gs_process (pixmap, f);
expose_frame (f, 0, 0, 0, 0);
#endif /* !USE_CAIRO */
goto done;
......@@ -12154,7 +12156,15 @@ x_check_font (struct frame *f, struct font *font)
static void
x_free_pixmap (struct frame *f, Emacs_Pixmap pixmap)
#ifdef USE_CAIRO
if (pixmap)
xfree (pixmap->data);
xfree (pixmap);
XFreePixmap (FRAME_X_DISPLAY (f), pixmap);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment