aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/image.c48
-rw-r--r--src/xterm.c33
-rw-r--r--src/xterm.h4
3 files changed, 81 insertions, 4 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
296cairo_pattern_t *
297x_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 ();
diff --git a/src/xterm.c b/src/xterm.c
index 03458cb03f6..e9551475f7d 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -698,12 +698,39 @@ static void
698x_fill_rectangle (struct frame *f, GC gc, int x, int y, int width, int height) 698x_fill_rectangle (struct frame *f, GC gc, int x, int y, int width, int height)
699{ 699{
700#ifdef USE_CAIRO 700#ifdef USE_CAIRO
701 Display *dpy = FRAME_X_DISPLAY (f);
701 cairo_t *cr; 702 cairo_t *cr;
703 XGCValues xgcv;
702 704
703 cr = x_begin_cr_clip (f, gc); 705 cr = x_begin_cr_clip (f, gc);
704 x_set_cr_source_with_gc_foreground (f, gc); 706 XGetGCValues (dpy, gc, GCFillStyle | GCStipple, &xgcv);
705 cairo_rectangle (cr, x, y, width, height); 707 if (xgcv.fill_style == FillSolid
706 cairo_fill (cr); 708 /* Invalid resource ID (one or more of the three most
709 significant bits set to 1) is obtained if the GCStipple
710 component has never been explicitly set. It should be
711 regarded as Pixmap of unspecified size filled with ones. */
712 || (xgcv.stipple & ((Pixmap) 7 << (sizeof (Pixmap) * CHAR_BIT - 3))))
713 {
714 x_set_cr_source_with_gc_foreground (f, gc);
715 cairo_rectangle (cr, x, y, width, height);
716 cairo_fill (cr);
717 }
718 else
719 {
720 eassert (xgcv.fill_style == FillOpaqueStippled);
721 eassert (xgcv.stipple != None);
722 x_set_cr_source_with_gc_background (f, gc);
723 cairo_rectangle (cr, x, y, width, height);
724 cairo_fill_preserve (cr);
725
726 cairo_pattern_t *pattern = x_bitmap_stipple (f, xgcv.stipple);
727 if (pattern)
728 {
729 x_set_cr_source_with_gc_foreground (f, gc);
730 cairo_clip (cr);
731 cairo_mask (cr, pattern);
732 }
733 }
707 x_end_cr_clip (f); 734 x_end_cr_clip (f);
708#else 735#else
709 XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_DRAWABLE (f), 736 XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_DRAWABLE (f),
diff --git a/src/xterm.h b/src/xterm.h
index ce1443c381c..2bd2c0105f6 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -130,7 +130,7 @@ struct xim_inst_t
130struct x_bitmap_record 130struct x_bitmap_record
131{ 131{
132#ifdef USE_CAIRO 132#ifdef USE_CAIRO
133 void *img; 133 cairo_pattern_t *stipple;
134#endif 134#endif
135 Pixmap pixmap; 135 Pixmap pixmap;
136 bool have_mask; 136 bool have_mask;
@@ -151,6 +151,8 @@ struct x_gc_ext_data
151 /* Clipping rectangles. */ 151 /* Clipping rectangles. */
152 XRectangle clip_rects[MAX_CLIP_RECTS]; 152 XRectangle clip_rects[MAX_CLIP_RECTS];
153}; 153};
154
155extern cairo_pattern_t *x_bitmap_stipple (struct frame *, Pixmap);
154#endif 156#endif
155 157
156 158