aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu2019-03-26 18:58:35 +0900
committerYAMAMOTO Mitsuharu2019-03-26 18:58:35 +0900
commitae68fad033261eb63e3d2221c946f9b03b5464ac (patch)
tree31de3d43f383849ef6127feb8ef8bb68f121096d /src
parent9a6cba2bd397414c68217f4f5a9ea2888293ae1c (diff)
downloademacs-ae68fad033261eb63e3d2221c946f9b03b5464ac.tar.gz
emacs-ae68fad033261eb63e3d2221c946f9b03b5464ac.zip
Use cairo image surface instead of pattern for fringe bitmap
* src/xterm.c (fringe_bmp, x_cr_define_fringe_bitmap) (x_cr_destroy_fringe_bitmap, x_cr_draw_image) [USE_CAIRO]: Change type of fringe bitmap.
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/src/xterm.c b/src/xterm.c
index e3034772a46..f349e99d51f 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -426,7 +426,7 @@ x_set_cr_source_with_gc_background (struct frame *f, GC gc)
426/* Fringe bitmaps. */ 426/* Fringe bitmaps. */
427 427
428static int max_fringe_bmp = 0; 428static int max_fringe_bmp = 0;
429static cairo_pattern_t **fringe_bmp = 0; 429static cairo_surface_t **fringe_bmp = 0;
430 430
431static void 431static void
432x_cr_define_fringe_bitmap (int which, unsigned short *bits, int h, int wd) 432x_cr_define_fringe_bitmap (int which, unsigned short *bits, int h, int wd)
@@ -434,13 +434,12 @@ x_cr_define_fringe_bitmap (int which, unsigned short *bits, int h, int wd)
434 int i, stride; 434 int i, stride;
435 cairo_surface_t *surface; 435 cairo_surface_t *surface;
436 unsigned char *data; 436 unsigned char *data;
437 cairo_pattern_t *pattern;
438 437
439 if (which >= max_fringe_bmp) 438 if (which >= max_fringe_bmp)
440 { 439 {
441 i = max_fringe_bmp; 440 i = max_fringe_bmp;
442 max_fringe_bmp = which + 20; 441 max_fringe_bmp = which + 20;
443 fringe_bmp = (cairo_pattern_t **) xrealloc (fringe_bmp, max_fringe_bmp * sizeof (cairo_pattern_t *)); 442 fringe_bmp = xrealloc (fringe_bmp, max_fringe_bmp * sizeof (*fringe_bmp));
444 while (i < max_fringe_bmp) 443 while (i < max_fringe_bmp)
445 fringe_bmp[i++] = 0; 444 fringe_bmp[i++] = 0;
446 } 445 }
@@ -458,12 +457,10 @@ x_cr_define_fringe_bitmap (int which, unsigned short *bits, int h, int wd)
458 } 457 }
459 458
460 cairo_surface_mark_dirty (surface); 459 cairo_surface_mark_dirty (surface);
461 pattern = cairo_pattern_create_for_surface (surface);
462 cairo_surface_destroy (surface);
463 460
464 unblock_input (); 461 unblock_input ();
465 462
466 fringe_bmp[which] = pattern; 463 fringe_bmp[which] = surface;
467} 464}
468 465
469static void 466static void
@@ -475,20 +472,18 @@ x_cr_destroy_fringe_bitmap (int which)
475 if (fringe_bmp[which]) 472 if (fringe_bmp[which])
476 { 473 {
477 block_input (); 474 block_input ();
478 cairo_pattern_destroy (fringe_bmp[which]); 475 cairo_surface_destroy (fringe_bmp[which]);
479 unblock_input (); 476 unblock_input ();
480 } 477 }
481 fringe_bmp[which] = 0; 478 fringe_bmp[which] = 0;
482} 479}
483 480
484static void 481static void
485x_cr_draw_image (struct frame *f, GC gc, cairo_pattern_t *image, 482x_cr_draw_image (struct frame *f, GC gc, cairo_surface_t *image,
486 int src_x, int src_y, int width, int height, 483 int src_x, int src_y, int width, int height,
487 int dest_x, int dest_y, bool overlay_p) 484 int dest_x, int dest_y, bool overlay_p)
488{ 485{
489 cairo_t *cr; 486 cairo_t *cr;
490 cairo_matrix_t matrix;
491 cairo_surface_t *surface;
492 cairo_format_t format; 487 cairo_format_t format;
493 488
494 cr = x_begin_cr_clip (f, gc); 489 cr = x_begin_cr_clip (f, gc);
@@ -501,19 +496,16 @@ x_cr_draw_image (struct frame *f, GC gc, cairo_pattern_t *image,
501 cairo_fill_preserve (cr); 496 cairo_fill_preserve (cr);
502 } 497 }
503 cairo_clip (cr); 498 cairo_clip (cr);
504 cairo_matrix_init_translate (&matrix, src_x - dest_x, src_y - dest_y); 499 format = cairo_image_surface_get_format (image);
505 cairo_pattern_set_matrix (image, &matrix);
506 cairo_pattern_get_surface (image, &surface);
507 format = cairo_image_surface_get_format (surface);
508 if (format != CAIRO_FORMAT_A8 && format != CAIRO_FORMAT_A1) 500 if (format != CAIRO_FORMAT_A8 && format != CAIRO_FORMAT_A1)
509 { 501 {
510 cairo_set_source (cr, image); 502 cairo_set_source_surface (cr, image, dest_x - src_x, dest_y - src_y);
511 cairo_fill (cr); 503 cairo_fill (cr);
512 } 504 }
513 else 505 else
514 { 506 {
515 x_set_cr_source_with_gc_foreground (f, gc); 507 x_set_cr_source_with_gc_foreground (f, gc);
516 cairo_mask (cr, image); 508 cairo_mask_surface (cr, image, dest_x - src_x, dest_y - src_y);
517 } 509 }
518 x_end_cr_clip (f); 510 x_end_cr_clip (f);
519} 511}