aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c55
1 files changed, 35 insertions, 20 deletions
diff --git a/src/xterm.c b/src/xterm.c
index f349e99d51f..33eb0f3b5e3 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -495,7 +495,6 @@ x_cr_draw_image (struct frame *f, GC gc, cairo_surface_t *image,
495 cairo_rectangle (cr, dest_x, dest_y, width, height); 495 cairo_rectangle (cr, dest_x, dest_y, width, height);
496 cairo_fill_preserve (cr); 496 cairo_fill_preserve (cr);
497 } 497 }
498 cairo_clip (cr);
499 format = cairo_image_surface_get_format (image); 498 format = cairo_image_surface_get_format (image);
500 if (format != CAIRO_FORMAT_A8 && format != CAIRO_FORMAT_A1) 499 if (format != CAIRO_FORMAT_A8 && format != CAIRO_FORMAT_A1)
501 { 500 {
@@ -505,6 +504,7 @@ x_cr_draw_image (struct frame *f, GC gc, cairo_surface_t *image,
505 else 504 else
506 { 505 {
507 x_set_cr_source_with_gc_foreground (f, gc); 506 x_set_cr_source_with_gc_foreground (f, gc);
507 cairo_clip (cr);
508 cairo_mask_surface (cr, image, dest_x - src_x, dest_y - src_y); 508 cairo_mask_surface (cr, image, dest_x - src_x, dest_y - src_y);
509 } 509 }
510 x_end_cr_clip (f); 510 x_end_cr_clip (f);
@@ -1511,7 +1511,9 @@ static void x_setup_relief_colors (struct glyph_string *);
1511static void x_draw_image_glyph_string (struct glyph_string *); 1511static void x_draw_image_glyph_string (struct glyph_string *);
1512static void x_draw_image_relief (struct glyph_string *); 1512static void x_draw_image_relief (struct glyph_string *);
1513static void x_draw_image_foreground (struct glyph_string *); 1513static void x_draw_image_foreground (struct glyph_string *);
1514#ifndef USE_CAIRO
1514static void x_draw_image_foreground_1 (struct glyph_string *, Pixmap); 1515static void x_draw_image_foreground_1 (struct glyph_string *, Pixmap);
1516#endif
1515static void x_clear_glyph_string_rect (struct glyph_string *, int, 1517static void x_clear_glyph_string_rect (struct glyph_string *, int,
1516 int, int, int); 1518 int, int, int);
1517static void x_draw_relief_rect (struct frame *, int, int, int, int, 1519static void x_draw_relief_rect (struct frame *, int, int, int, int,
@@ -3035,6 +3037,30 @@ x_draw_image_foreground (struct glyph_string *s)
3035 if (s->slice.y == 0) 3037 if (s->slice.y == 0)
3036 y += s->img->vmargin; 3038 y += s->img->vmargin;
3037 3039
3040#ifdef USE_CAIRO
3041 if (s->img->cr_data)
3042 {
3043 x_set_glyph_string_clipping (s);
3044 x_cr_draw_image (s->f, s->gc, s->img->cr_data, s->slice.x, s->slice.y,
3045 s->slice.width, s->slice.height, x, y, true);
3046 if (!s->img->mask)
3047 {
3048 /* When the image has a mask, we can expect that at
3049 least part of a mouse highlight or a block cursor will
3050 be visible. If the image doesn't have a mask, make
3051 a block cursor visible by drawing a rectangle around
3052 the image. I believe it's looking better if we do
3053 nothing here for mouse-face. */
3054 if (s->hl == DRAW_CURSOR)
3055 {
3056 int relief = eabs (s->img->relief);
3057 x_draw_rectangle (s->f, s->gc, x - relief, y - relief,
3058 s->slice.width + relief*2 - 1,
3059 s->slice.height + relief*2 - 1);
3060 }
3061 }
3062 }
3063#else /* ! USE_CAIRO */
3038 if (s->img->pixmap) 3064 if (s->img->pixmap)
3039 { 3065 {
3040 if (s->img->mask) 3066 if (s->img->mask)
@@ -3095,6 +3121,7 @@ x_draw_image_foreground (struct glyph_string *s)
3095 } 3121 }
3096 } 3122 }
3097 } 3123 }
3124#endif /* ! USE_CAIRO */
3098 else 3125 else
3099 /* Draw a rectangle if image could not be loaded. */ 3126 /* Draw a rectangle if image could not be loaded. */
3100 x_draw_rectangle (s->f, s->gc, x, y, 3127 x_draw_rectangle (s->f, s->gc, x, y,
@@ -3177,6 +3204,7 @@ x_draw_image_relief (struct glyph_string *s)
3177} 3204}
3178 3205
3179 3206
3207#ifndef USE_CAIRO
3180/* Draw the foreground of image glyph string S to PIXMAP. */ 3208/* Draw the foreground of image glyph string S to PIXMAP. */
3181 3209
3182static void 3210static void
@@ -3249,6 +3277,7 @@ x_draw_image_foreground_1 (struct glyph_string *s, Pixmap pixmap)
3249 x_draw_rectangle (s->f, s->gc, x, y, 3277 x_draw_rectangle (s->f, s->gc, x, y,
3250 s->slice.width - 1, s->slice.height - 1); 3278 s->slice.width - 1, s->slice.height - 1);
3251} 3279}
3280#endif /* ! USE_CAIRO */
3252 3281
3253 3282
3254/* Draw part of the background of glyph string S. X, Y, W, and H 3283/* Draw part of the background of glyph string S. X, Y, W, and H
@@ -3308,6 +3337,7 @@ x_draw_image_glyph_string (struct glyph_string *s)
3308 || s->img->pixmap == 0 3337 || s->img->pixmap == 0
3309 || s->width != s->background_width) 3338 || s->width != s->background_width)
3310 { 3339 {
3340#ifndef USE_CAIRO
3311 if (s->img->mask) 3341 if (s->img->mask)
3312 { 3342 {
3313 /* Create a pixmap as large as the glyph string. Fill it 3343 /* Create a pixmap as large as the glyph string. Fill it
@@ -3348,6 +3378,7 @@ x_draw_image_glyph_string (struct glyph_string *s)
3348 } 3378 }
3349 } 3379 }
3350 else 3380 else
3381#endif /* ! USE_CAIRO */
3351 { 3382 {
3352 int x = s->x; 3383 int x = s->x;
3353 int y = s->y; 3384 int y = s->y;
@@ -3370,25 +3401,8 @@ x_draw_image_glyph_string (struct glyph_string *s)
3370 } 3401 }
3371 3402
3372 /* Draw the foreground. */ 3403 /* Draw the foreground. */
3373#ifdef USE_CAIRO 3404#ifndef USE_CAIRO
3374 if (s->img->cr_data) 3405 if (pixmap != None)
3375 {
3376 cairo_t *cr = x_begin_cr_clip (s->f, s->gc);
3377
3378 int x = s->x + s->img->hmargin;
3379 int y = s->y + s->img->vmargin;
3380 int width = s->background_width;
3381
3382 cairo_set_source_surface (cr, s->img->cr_data,
3383 x - s->slice.x,
3384 y - s->slice.y);
3385 cairo_rectangle (cr, x, y, width, height);
3386 cairo_fill (cr);
3387 x_end_cr_clip (s->f);
3388 }
3389 else
3390#endif
3391 if (pixmap != None)
3392 { 3406 {
3393 x_draw_image_foreground_1 (s, pixmap); 3407 x_draw_image_foreground_1 (s, pixmap);
3394 x_set_glyph_string_clipping (s); 3408 x_set_glyph_string_clipping (s);
@@ -3397,6 +3411,7 @@ x_draw_image_glyph_string (struct glyph_string *s)
3397 XFreePixmap (s->display, pixmap); 3411 XFreePixmap (s->display, pixmap);
3398 } 3412 }
3399 else 3413 else
3414#endif /* ! USE_CAIRO */
3400 x_draw_image_foreground (s); 3415 x_draw_image_foreground (s);
3401 3416
3402 /* If we must draw a relief around the image, do it. */ 3417 /* If we must draw a relief around the image, do it. */