++FRAME_DISPLAY_INFO (f)->bitmaps[id - 1].refcount;
}
+#ifdef HAVE_PGTK
+static cairo_pattern_t *
+image_create_pattern_from_pixbuf (struct frame *f, GdkPixbuf *pixbuf)
+{
+ GdkPixbuf *pb = gdk_pixbuf_add_alpha (pixbuf, TRUE, 255, 255, 255);
+ cairo_surface_t *surface = cairo_surface_create_similar_image (f->output_data.pgtk->cr_surface,
+ CAIRO_FORMAT_A1,
+ gdk_pixbuf_get_width (pb),
+ gdk_pixbuf_get_height (pb));
+
+ cairo_t *cr = cairo_create (surface);
+ gdk_cairo_set_source_pixbuf (cr, pb, 0, 0);
+ cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+ cairo_paint (cr);
+ cairo_destroy (cr);
+
+ cairo_pattern_t *pat = cairo_pattern_create_for_surface (surface);
+ cairo_pattern_set_extend (pat, CAIRO_EXTEND_REPEAT);
+
+ cairo_surface_destroy (surface);
+ g_object_unref (pb);
+
+ return pat;
+}
+#endif
+
/* Create a bitmap for frame F from a HEIGHT x WIDTH array of bits at BITS. */
ptrdiff_t
#endif
#ifdef HAVE_PGTK
- Emacs_Pixmap bitmap = image_pix_container_create_from_bitmap_data(f, bits,
- width,
- height,
- 0xffffffff,
- 0xff000000);
+ GdkPixbuf *pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
+ FALSE,
+ 8,
+ width,
+ height);
+ {
+ char *sp = bits;
+ int mask = 0x01;
+ unsigned char *buf = gdk_pixbuf_get_pixels (pixbuf);
+ int rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+ for (int y = 0; y < height; y++) {
+ unsigned char *dp = buf + rowstride * y;
+ for (int x = 0; x < width; x++) {
+ if (*sp & mask) {
+ *dp++ = 0xff;
+ *dp++ = 0xff;
+ *dp++ = 0xff;
+ } else {
+ *dp++ = 0x00;
+ *dp++ = 0x00;
+ *dp++ = 0x00;
+ }
+ if ((mask <<= 1) >= 0x100) {
+ mask = 0x01;
+ sp++;
+ }
+ }
+ if (mask != 0x01) {
+ mask = 0x01;
+ sp++;
+ }
+ }
+ }
#endif
id = image_allocate_bitmap_record (f);
#endif
#ifdef HAVE_PGTK
- dpyinfo->bitmaps[id - 1].img = bitmap;
+ dpyinfo->bitmaps[id - 1].img = pixbuf;
dpyinfo->bitmaps[id - 1].depth = 1;
+ dpyinfo->bitmaps[id - 1].pattern = image_create_pattern_from_pixbuf (f, pixbuf);
#endif
dpyinfo->bitmaps[id - 1].file = NULL;
//dpyinfo->bitmaps[id - 1].depth = 1;
dpyinfo->bitmaps[id - 1].height = gdk_pixbuf_get_width (bitmap);
dpyinfo->bitmaps[id - 1].width = gdk_pixbuf_get_height (bitmap);
+ dpyinfo->bitmaps[id - 1].pattern = image_create_pattern_from_pixbuf (f, bitmap);
return id;
#endif
#endif
#ifdef HAVE_PGTK
+ if (bm->pattern != NULL)
+ cairo_pattern_destroy (bm->pattern);
#endif
if (bm->file)
}
if (face->stipple != 0) {
- GdkPixbuf *pixbuf = FRAME_DISPLAY_INFO (f)->bitmaps[face->stipple - 1].img;
- GdkPixbuf *pb = gdk_pixbuf_add_alpha (pixbuf, TRUE, 255, 255, 255);
- cairo_surface_t *mask = cairo_surface_create_similar_image (FRAME_CR_SURFACE (f),
- CAIRO_FORMAT_A1,
- width,
- height);
+ cairo_pattern_t *mask = FRAME_DISPLAY_INFO (f)->bitmaps[face->stipple - 1].pattern;
- {
- cairo_t *cr = cairo_create (mask);
- gdk_cairo_set_source_pixbuf (cr, pb, 0, 0);
- cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
- cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
- cairo_paint (cr);
- cairo_destroy (cr);
- }
-
- {
- cairo_t *cr = cairo_create (surface);
- double r = ((face->foreground >> 16) & 0xff) / 255.0;
- double g = ((face->foreground >> 8) & 0xff) / 255.0;
- double b = ((face->foreground >> 0) & 0xff) / 255.0;
- cairo_set_source_rgb (cr, r, g, b);
- cairo_mask_surface (cr, mask, 0, 0);
- cairo_destroy (cr);
- }
-
- cairo_surface_destroy (mask);
- g_object_unref (pb);
+ cairo_t *cr = cairo_create (surface);
+ double r = ((face->foreground >> 16) & 0xff) / 255.0;
+ double g = ((face->foreground >> 8) & 0xff) / 255.0;
+ double b = ((face->foreground >> 0) & 0xff) / 255.0;
+ cairo_set_source_rgb (cr, r, g, b);
+ cairo_mask (cr, mask);
+ cairo_destroy (cr);
}
return surface;