diff options
author | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
commit | dd7595a3475407a7fa96a97393bae8c5220e8762 (patch) | |
tree | e341e911d7eb911a51684a7412ef7f7c7605d28e /libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_region.c | |
parent | Add the skeleton. (diff) | |
download | SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.zip SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.gz SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.bz2 SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.xz |
Add the base Enlightenment Foundation Libraries - eina, eet, evas, ecore, embryo, and edje.
Note that embryo wont be used, but I'm not sure yet if you can build edje without it.
Diffstat (limited to '')
-rw-r--r-- | libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_region.c | 159 |
1 files changed, 159 insertions, 0 deletions
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_region.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_region.c new file mode 100644 index 0000000..a221d8f --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_region.c | |||
@@ -0,0 +1,159 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | #include <pixman.h> | ||
3 | |||
4 | /* | ||
5 | * [ ] XPolygonRegion | ||
6 | * [ ] XShrinkRegion | ||
7 | * [ ] XClipBox | ||
8 | * [ ] XXorRegion | ||
9 | */ | ||
10 | |||
11 | EAPI Ecore_X_XRegion * | ||
12 | ecore_x_xregion_new() | ||
13 | { | ||
14 | pixman_region16_t *region; | ||
15 | |||
16 | region = (pixman_region16_t *)malloc(sizeof(pixman_region16_t)); | ||
17 | if (!region) return NULL; | ||
18 | |||
19 | pixman_region_init(region); | ||
20 | |||
21 | return (Ecore_X_XRegion *)region; | ||
22 | } | ||
23 | |||
24 | EAPI void | ||
25 | ecore_x_xregion_free(Ecore_X_XRegion *region) | ||
26 | { | ||
27 | if (!region) return; | ||
28 | |||
29 | pixman_region_fini(region); | ||
30 | free(region); | ||
31 | } | ||
32 | |||
33 | EAPI Eina_Bool | ||
34 | ecore_x_xregion_set(Ecore_X_XRegion *region, | ||
35 | Ecore_X_GC gc) | ||
36 | { | ||
37 | xcb_rectangle_t *rects; | ||
38 | pixman_box16_t *boxes; | ||
39 | int num = 0, i = 0; | ||
40 | |||
41 | CHECK_XCB_CONN; | ||
42 | |||
43 | if (!region) return EINA_FALSE; | ||
44 | |||
45 | boxes = pixman_region_rectangles((pixman_region16_t *)region, &num); | ||
46 | if ((!boxes) || (num == 0)) return EINA_FALSE; | ||
47 | |||
48 | rects = (xcb_rectangle_t *)malloc(sizeof(xcb_rectangle_t) * num); | ||
49 | if (!rects) return EINA_FALSE; | ||
50 | |||
51 | for (i = 0; i < num; i++) | ||
52 | { | ||
53 | rects[i].x = boxes[i].x1; | ||
54 | rects[i].y = boxes[i].y1; | ||
55 | rects[i].width = boxes[i].x2 - boxes[i].x1 + 1; | ||
56 | rects[i].height = boxes[i].y2 - boxes[i].y1 + 1; | ||
57 | } | ||
58 | |||
59 | xcb_set_clip_rectangles(_ecore_xcb_conn, XCB_CLIP_ORDERING_YX_BANDED, | ||
60 | gc, 0, 0, num, rects); | ||
61 | |||
62 | // ecore_x_flush(); | ||
63 | return EINA_TRUE; | ||
64 | } | ||
65 | |||
66 | EAPI void | ||
67 | ecore_x_xregion_translate(Ecore_X_XRegion *region, | ||
68 | int x, | ||
69 | int y) | ||
70 | { | ||
71 | if (!region) return; | ||
72 | |||
73 | pixman_region_translate((pixman_region16_t *)region, x, y); | ||
74 | } | ||
75 | |||
76 | EAPI Eina_Bool | ||
77 | ecore_x_xregion_intersect(Ecore_X_XRegion *dst, | ||
78 | Ecore_X_XRegion *r1, | ||
79 | Ecore_X_XRegion *r2) | ||
80 | { | ||
81 | return pixman_region_intersect((pixman_region16_t *)dst, | ||
82 | (pixman_region16_t *)r1, | ||
83 | (pixman_region16_t *)r2); | ||
84 | } | ||
85 | |||
86 | EAPI Eina_Bool | ||
87 | ecore_x_xregion_union(Ecore_X_XRegion *dst, | ||
88 | Ecore_X_XRegion *r1, | ||
89 | Ecore_X_XRegion *r2) | ||
90 | { | ||
91 | return pixman_region_union((pixman_region16_t *)dst, | ||
92 | (pixman_region16_t *)r1, | ||
93 | (pixman_region16_t *)r2); | ||
94 | } | ||
95 | |||
96 | EAPI Eina_Bool | ||
97 | ecore_x_xregion_union_rect(Ecore_X_XRegion *dst, | ||
98 | Ecore_X_XRegion *src, | ||
99 | Ecore_X_Rectangle *rect) | ||
100 | { | ||
101 | return pixman_region_union_rect((pixman_region16_t *)dst, | ||
102 | (pixman_region16_t *)src, | ||
103 | rect->x, rect->y, rect->width, rect->height); | ||
104 | } | ||
105 | |||
106 | EAPI Eina_Bool | ||
107 | ecore_x_xregion_subtract(Ecore_X_XRegion *dst, | ||
108 | Ecore_X_XRegion *rm, | ||
109 | Ecore_X_XRegion *rs) | ||
110 | { | ||
111 | return pixman_region_subtract((pixman_region16_t *)dst, | ||
112 | (pixman_region16_t *)rm, | ||
113 | (pixman_region16_t *)rs); | ||
114 | } | ||
115 | |||
116 | EAPI Eina_Bool | ||
117 | ecore_x_xregion_is_empty(Ecore_X_XRegion *region) | ||
118 | { | ||
119 | if (!region) return EINA_TRUE; | ||
120 | |||
121 | return !pixman_region_not_empty((pixman_region16_t *)region); | ||
122 | } | ||
123 | |||
124 | EAPI Eina_Bool | ||
125 | ecore_x_xregion_is_equal(Ecore_X_XRegion *r1, | ||
126 | Ecore_X_XRegion *r2) | ||
127 | { | ||
128 | if ((!r1) || (!r2)) return EINA_FALSE; | ||
129 | |||
130 | return pixman_region_equal((pixman_region16_t *)r1, | ||
131 | (pixman_region16_t *)r2); | ||
132 | } | ||
133 | |||
134 | EAPI Eina_Bool | ||
135 | ecore_x_xregion_point_contain(Ecore_X_XRegion *region, | ||
136 | int x, | ||
137 | int y) | ||
138 | { | ||
139 | if (!region) return EINA_FALSE; | ||
140 | |||
141 | return pixman_region_contains_point((pixman_region16_t *)region, x, y, NULL); | ||
142 | } | ||
143 | |||
144 | EAPI Eina_Bool | ||
145 | ecore_x_xregion_rect_contain(Ecore_X_XRegion *region, | ||
146 | Ecore_X_Rectangle *rect) | ||
147 | { | ||
148 | pixman_box16_t box; | ||
149 | |||
150 | if ((!region) || (!rect)) return EINA_FALSE; | ||
151 | |||
152 | box.x1 = rect->x; | ||
153 | box.y1 = rect->y; | ||
154 | box.x2 = rect->x + rect->width - 1; | ||
155 | box.y2 = rect->y + rect->height - 1; | ||
156 | |||
157 | return pixman_region_contains_rectangle((pixman_region16_t *)region, &box); | ||
158 | } | ||
159 | |||