diff options
| author | YAMAMOTO Mitsuharu | 2019-05-30 17:16:41 +0900 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2019-05-30 17:16:41 +0900 |
| commit | cc71a82fc705a73fa3ef6cda3ec6bee1cb654d7e (patch) | |
| tree | 7ce649f9d1bcf8fe087e38b3488c9c0a6e14a7ba /src/image.c | |
| parent | ceca1740ea2c9bc98da8c11765b78c696b27c79e (diff) | |
| download | emacs-cc71a82fc705a73fa3ef6cda3ec6bee1cb654d7e.tar.gz emacs-cc71a82fc705a73fa3ef6cda3ec6bee1cb654d7e.zip | |
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) | |||
| 291 | { | 291 | { |
| 292 | return FRAME_DISPLAY_INFO (f)->bitmaps[id - 1].width; | 292 | return FRAME_DISPLAY_INFO (f)->bitmaps[id - 1].width; |
| 293 | } | 293 | } |
| 294 | |||
| 295 | #ifdef USE_CAIRO | ||
| 296 | cairo_pattern_t * | ||
| 297 | x_bitmap_stipple (struct frame *f, Pixmap pixmap) | ||
| 298 | { | ||
| 299 | Display_Info *dpyinfo = FRAME_DISPLAY_INFO (f); | ||
| 300 | |||
| 301 | for (ptrdiff_t i = 0; i < dpyinfo->bitmaps_last; i++) | ||
| 302 | { | ||
| 303 | struct x_bitmap_record *bm = dpyinfo->bitmaps + i; | ||
| 304 | |||
| 305 | if (bm->refcount && bm->pixmap == pixmap && bm->depth == 1) | ||
| 306 | { | ||
| 307 | if (bm->stipple == NULL) | ||
| 308 | { | ||
| 309 | cairo_surface_t *surface | ||
| 310 | = cairo_xlib_surface_create_for_bitmap (FRAME_X_DISPLAY (f), | ||
| 311 | pixmap, | ||
| 312 | FRAME_X_SCREEN (f), | ||
| 313 | bm->width, bm->height); | ||
| 314 | cairo_pattern_t *pattern | ||
| 315 | = cairo_pattern_create_for_surface (surface); | ||
| 316 | cairo_surface_destroy (surface); | ||
| 317 | cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT); | ||
| 318 | bm->stipple = pattern; | ||
| 319 | } | ||
| 320 | |||
| 321 | return bm->stipple; | ||
| 322 | } | ||
| 323 | } | ||
| 324 | |||
| 325 | return NULL; | ||
| 326 | } | ||
| 327 | |||
| 328 | #endif /* USE_CAIRO */ | ||
| 294 | #endif | 329 | #endif |
| 295 | 330 | ||
| 296 | #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) | 331 | #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) |
| @@ -389,6 +424,9 @@ image_create_bitmap_from_data (struct frame *f, char *bits, | |||
| 389 | dpyinfo->bitmaps[id - 1].pixmap = bitmap; | 424 | dpyinfo->bitmaps[id - 1].pixmap = bitmap; |
| 390 | dpyinfo->bitmaps[id - 1].have_mask = false; | 425 | dpyinfo->bitmaps[id - 1].have_mask = false; |
| 391 | dpyinfo->bitmaps[id - 1].depth = 1; | 426 | dpyinfo->bitmaps[id - 1].depth = 1; |
| 427 | #ifdef USE_CAIRO | ||
| 428 | dpyinfo->bitmaps[id - 1].stipple = NULL; | ||
| 429 | #endif /* USE_CAIRO */ | ||
| 392 | #endif /* HAVE_X_WINDOWS */ | 430 | #endif /* HAVE_X_WINDOWS */ |
| 393 | 431 | ||
| 394 | #ifdef HAVE_NTGUI | 432 | #ifdef HAVE_NTGUI |
| @@ -470,6 +508,9 @@ image_create_bitmap_from_file (struct frame *f, Lisp_Object file) | |||
| 470 | dpyinfo->bitmaps[id - 1].depth = 1; | 508 | dpyinfo->bitmaps[id - 1].depth = 1; |
| 471 | dpyinfo->bitmaps[id - 1].height = height; | 509 | dpyinfo->bitmaps[id - 1].height = height; |
| 472 | dpyinfo->bitmaps[id - 1].width = width; | 510 | dpyinfo->bitmaps[id - 1].width = width; |
| 511 | #ifdef USE_CAIRO | ||
| 512 | dpyinfo->bitmaps[id - 1].stipple = NULL; | ||
| 513 | #endif /* USE_CAIRO */ | ||
| 473 | 514 | ||
| 474 | return id; | 515 | return id; |
| 475 | #endif /* HAVE_X_WINDOWS */ | 516 | #endif /* HAVE_X_WINDOWS */ |
| @@ -484,6 +525,10 @@ free_bitmap_record (Display_Info *dpyinfo, Bitmap_Record *bm) | |||
| 484 | XFreePixmap (dpyinfo->display, bm->pixmap); | 525 | XFreePixmap (dpyinfo->display, bm->pixmap); |
| 485 | if (bm->have_mask) | 526 | if (bm->have_mask) |
| 486 | XFreePixmap (dpyinfo->display, bm->mask); | 527 | XFreePixmap (dpyinfo->display, bm->mask); |
| 528 | #ifdef USE_CAIRO | ||
| 529 | if (bm->stipple) | ||
| 530 | cairo_pattern_destroy (bm->stipple); | ||
| 531 | #endif /* USE_CAIRO */ | ||
| 487 | #endif /* HAVE_X_WINDOWS */ | 532 | #endif /* HAVE_X_WINDOWS */ |
| 488 | 533 | ||
| 489 | #ifdef HAVE_NTGUI | 534 | #ifdef HAVE_NTGUI |
| @@ -3843,6 +3888,9 @@ x_create_bitmap_from_xpm_data (struct frame *f, const char **bits) | |||
| 3843 | dpyinfo->bitmaps[id - 1].width = attrs.width; | 3888 | dpyinfo->bitmaps[id - 1].width = attrs.width; |
| 3844 | dpyinfo->bitmaps[id - 1].depth = attrs.depth; | 3889 | dpyinfo->bitmaps[id - 1].depth = attrs.depth; |
| 3845 | dpyinfo->bitmaps[id - 1].refcount = 1; | 3890 | dpyinfo->bitmaps[id - 1].refcount = 1; |
| 3891 | #ifdef USE_CAIRO | ||
| 3892 | dpyinfo->bitmaps[id - 1].stipple = NULL; | ||
| 3893 | #endif /* USE_CAIRO */ | ||
| 3846 | 3894 | ||
| 3847 | #ifdef ALLOC_XPM_COLORS | 3895 | #ifdef ALLOC_XPM_COLORS |
| 3848 | xpm_free_color_cache (); | 3896 | xpm_free_color_cache (); |