5 RrPixmapMask *RrPixmapMaskNew(const RrInstance *inst,
6 gint w, gint h, const gchar *data)
8 RrPixmapMask *m = g_new(RrPixmapMask, 1);
12 /* round up to nearest byte */
13 m->data = g_memdup(data, (w + 7) / 8 * h);
14 m->mask = XCreateBitmapFromData(RrDisplay(inst), RrRootWindow(inst),
19 void RrPixmapMaskFree(RrPixmapMask *m)
22 XFreePixmap(RrDisplay(m->inst), m->mask);
28 void RrPixmapMaskDraw(Pixmap p, const RrTextureMask *m, const RrRect *area)
31 if (m->mask == None) return; /* no mask given */
33 /* set the clip region */
34 x = area->x + (area->width - m->mask->width) / 2;
35 y = area->y + (area->height - m->mask->height) / 2;
40 XSetClipMask(RrDisplay(m->mask->inst), RrColorGC(m->color), m->mask->mask);
41 XSetClipOrigin(RrDisplay(m->mask->inst), RrColorGC(m->color), x, y);
43 /* fill in the clipped region */
44 XFillRectangle(RrDisplay(m->mask->inst), p, RrColorGC(m->color), x, y,
45 x + m->mask->width, y + m->mask->height);
47 /* unset the clip region */
48 XSetClipMask(RrDisplay(m->mask->inst), RrColorGC(m->color), None);
49 XSetClipOrigin(RrDisplay(m->mask->inst), RrColorGC(m->color), 0, 0);
52 RrPixmapMask *RrPixmapMaskCopy(const RrPixmapMask *src)
54 RrPixmapMask *m = g_new(RrPixmapMask, 1);
56 m->width = src->width;
57 m->height = src->height;
58 /* round up to nearest byte */
59 m->data = g_memdup(src->data, (src->width + 7) / 8 * src->height);
60 m->mask = XCreateBitmapFromData(RrDisplay(m->inst), RrRootWindow(m->inst),
61 m->data, m->width, m->height);