diff options
| author | YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | 2019-05-30 17:16:41 +0900 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | 2019-05-30 17:16:41 +0900 |
| commit | cc71a82fc705a73fa3ef6cda3ec6bee1cb654d7e (patch) | |
| tree | 7ce649f9d1bcf8fe087e38b3488c9c0a6e14a7ba /src/image.c | |
| parent | ceca1740ea2c9bc98da8c11765b78c696b27c79e (diff) | |
Add stipple support on cairo
* src/xterm.h (struct x_bitmap_record) [USE_CAIRO]: Remove unused member img.
Add member stipple.
(x_bitmap_stipple) [USE_CAIRO]: Add extern.
* src/image.c (x_bitmap_stipple) [HAVE_X_WINDOWS && USE_CAIRO]: New function.
(image_create_bitmap_from_data, image_create_bitmap_from_file)
(x_create_bitmap_from_xpm_data) [HAVE_X_WINDOWS && USE_CAIRO]: Initialize
stipple member of struct x_bitmap_record.
(free_bitmap_record) [HAVE_X_WINDOWS && USE_CAIRO]: Destroy stipple member.
* src/xterm.c (x_fill_rectangle) [USE_CAIRO]: Inspect gc and draw stipple if
necessary. Use x_bitmap_stipple.
Diffstat (limited to 'src/image.c')
| -rw-r--r-- | src/image.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/image.c b/src/image.c index c5d97e05743..a2e4aa98bf9 100644 --- a/src/image.c +++ b/src/image.c @@ -291,6 +291,41 @@ x_bitmap_width (struct frame *f, ptrdiff_t id) { return FRAME_DISPLAY_INFO (f)->bitmaps[id - 1].width; } + +#ifdef USE_CAIRO +cairo_pattern_t * +x_bitmap_stipple (struct frame *f, Pixmap pixmap) +{ + Display_Info *dpyinfo = FRAME_DISPLAY_INFO (f); + + for (ptrdiff_t i = 0; i < dpyinfo->bitmaps_last; i++) + { + struct x_bitmap_record *bm = dpyinfo->bitmaps + i; + + if (bm->refcount && bm->pixmap == pixmap && bm->depth == 1) + { + if (bm->stipple == NULL) + { + cairo_surface_t *surface + = cairo_xlib_surface_create_for_bitmap (FRAME_X_DISPLAY (f), + pixmap, + FRAME_X_SCREEN (f), + bm->width, bm->height); + cairo_pattern_t *pattern + = cairo_pattern_create_for_surface (surface); + cairo_surface_destroy (surface); + cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT); + bm->stipple = pattern; + } + + return bm->stipple; + } + } + + return NULL; +} + +#endif /* USE_CAIRO */ #endif #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) @@ -389,6 +424,9 @@ image_create_bitmap_from_data (struct frame *f, char *bits, dpyinfo->bitmaps[id - 1].pixmap = bitmap; dpyinfo->bitmaps[id - 1].have_mask = false; dpyinfo->bitmaps[id - 1].depth = 1; +#ifdef USE_CAIRO + dpyinfo->bitmaps[id - 1].stipple = NULL; +#endif /* USE_CAIRO */ #endif /* HAVE_X_WINDOWS */ #ifdef HAVE_NTGUI @@ -470,6 +508,9 @@ image_create_bitmap_from_file (struct frame *f, Lisp_Object file) dpyinfo->bitmaps[id - 1].depth = 1; dpyinfo->bitmaps[id - 1].height = height; dpyinfo->bitmaps[id - 1].width = width; +#ifdef USE_CAIRO + dpyinfo->bitmaps[id - 1].stipple = NULL; +#endif /* USE_CAIRO */ return id; #endif /* HAVE_X_WINDOWS */ @@ -484,6 +525,10 @@ free_bitmap_record (Display_Info *dpyinfo, Bitmap_Record *bm) XFreePixmap (dpyinfo->display, bm->pixmap); if (bm->have_mask) XFreePixmap (dpyinfo->display, bm->mask); +#ifdef USE_CAIRO + if (bm->stipple) + cairo_pattern_destroy (bm->stipple); +#endif /* USE_CAIRO */ #endif /* HAVE_X_WINDOWS */ #ifdef HAVE_NTGUI @@ -3843,6 +3888,9 @@ x_create_bitmap_from_xpm_data (struct frame *f, const char **bits) dpyinfo->bitmaps[id - 1].width = attrs.width; dpyinfo->bitmaps[id - 1].depth = attrs.depth; dpyinfo->bitmaps[id - 1].refcount = 1; +#ifdef USE_CAIRO + dpyinfo->bitmaps[id - 1].stipple = NULL; +#endif /* USE_CAIRO */ #ifdef ALLOC_XPM_COLORS xpm_free_color_cache (); |
