]>
Dogcows Code - chaz/openbox/blob - render/mask.c
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
* h
+ 7) / 8);
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
), m
->color
->gc
, m
->mask
->mask
);
41 XSetClipOrigin(RrDisplay(m
->mask
->inst
), m
->color
->gc
, x
, y
);
43 /* fill in the clipped region */
44 XFillRectangle(RrDisplay(m
->mask
->inst
), p
, m
->color
->gc
, x
, y
,
45 x
+ m
->mask
->width
, y
+ m
->mask
->height
);
47 /* unset the clip region */
48 XSetClipMask(RrDisplay(m
->mask
->inst
), m
->color
->gc
, None
);
49 XSetClipOrigin(RrDisplay(m
->mask
->inst
), m
->color
->gc
, 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
* src
->height
+ 7) / 8);
60 m
->mask
= XCreateBitmapFromData(RrDisplay(m
->inst
), RrRootWindow(m
->inst
),
61 m
->data
, m
->width
, m
->height
);
This page took 0.040834 seconds and 4 git commands to generate.