]>
Dogcows Code - chaz/openbox/blob - render/mask.c
2 #include "../kernel/openbox.h"
4 pixmap_mask
*pixmap_mask_new(int w
, int h
, char *data
)
6 pixmap_mask
*m
= g_new(pixmap_mask
, 1);
9 m
->mask
= XCreateBitmapFromData(ob_display
, ob_root
, data
, w
, h
);
13 void pixmap_mask_free(pixmap_mask
*m
)
15 XFreePixmap(ob_display
, m
->mask
);
19 void mask_draw(Pixmap p
, TextureMask
*m
, int width
, int height
)
22 if (m
->mask
== None
) return; // no mask given
24 // set the clip region
25 x
= (width
- m
->mask
->w
) / 2;
26 y
= (height
- m
->mask
->h
) / 2;
27 XSetClipMask(ob_display
, m
->color
->gc
, m
->mask
->mask
);
28 XSetClipOrigin(ob_display
, m
->color
->gc
, x
, y
);
30 // fill in the clipped region
31 XFillRectangle(ob_display
, p
, m
->color
->gc
, x
, y
,
32 x
+ m
->mask
->w
, y
+ m
->mask
->h
);
34 // unset the clip region
35 XSetClipMask(ob_display
, m
->color
->gc
, None
);
36 XSetClipOrigin(ob_display
, m
->color
->gc
, 0, 0);
This page took 0.033906 seconds and 4 git commands to generate.