summaryrefslogtreecommitdiff
path: root/legacy/evas/src/lib/engines/common/evas_draw_main.c
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2007-04-04 09:55:40 +0000
committerCarsten Haitzler <raster@rasterman.com>2007-04-04 09:55:40 +0000
commit5ac7b84136b2e13b975aa65483d9ba42db7ab399 (patch)
tree30a135780e8ccb512ec9df0bd14832923929535a /legacy/evas/src/lib/engines/common/evas_draw_main.c
parent7827e2c598f0de8dbd215b02da2adbb17f31ab3b (diff)
pager urgent popup patch - good
evas clipouts less allocs patch - definite spedusp for when it's used heavily! SVN revision: 29331
Diffstat (limited to '')
-rw-r--r--legacy/evas/src/lib/engines/common/evas_draw_main.c383
1 files changed, 186 insertions, 197 deletions
diff --git a/legacy/evas/src/lib/engines/common/evas_draw_main.c b/legacy/evas/src/lib/engines/common/evas_draw_main.c
index e67ddd02b0..9a6e9141bd 100644
--- a/legacy/evas/src/lib/engines/common/evas_draw_main.c
+++ b/legacy/evas/src/lib/engines/common/evas_draw_main.c
@@ -1,5 +1,57 @@
1#include "evas_common.h" 1#include "evas_common.h"
2 2
3EAPI Cutout_Rects*
4evas_common_draw_context_cutouts_new()
5{
6 Cutout_Rects *rects;
7
8 rects = malloc(sizeof(Cutout_Rects));
9 rects->rects = NULL;
10 rects->active = 0;
11 rects->max = 0;
12
13 return rects;
14}
15
16EAPI void
17evas_common_draw_context_cutouts_free(Cutout_Rects* rects)
18{
19 rects->active = 0;
20}
21
22EAPI Cutout_Rect*
23evas_common_draw_context_cutouts_add(Cutout_Rects* rects,
24 int x, int y, int w, int h)
25{
26 Cutout_Rect* rect;
27
28 if (rects->max < rects->active + 1) {
29 rects->max += 8;
30 rects->rects = realloc(rects->rects, sizeof(Cutout_Rect) * rects->max);
31 }
32
33 rect = rects->rects + rects->active++;
34 rect->x = x;
35 rect->y = y;
36 rect->w = w;
37 rect->h = h;
38
39 return rect;
40}
41
42EAPI void
43evas_common_draw_context_cutouts_del(Cutout_Rects* rects,
44 int index)
45{
46 if (index >= 0 && index < rects->active)
47 {
48 Cutout_Rect* rect = rects->rects + index;
49
50 memmove(rect, rect + 1, sizeof (Cutout_Rect) * (rects->active - index - 1));
51 rects->active--;
52 }
53}
54
3void 55void
4evas_common_init(void) 56evas_common_init(void)
5{ 57{
@@ -43,10 +95,17 @@ evas_common_draw_context_new(void)
43EAPI void 95EAPI void
44evas_common_draw_context_free(RGBA_Draw_Context *dc) 96evas_common_draw_context_free(RGBA_Draw_Context *dc)
45{ 97{
98 evas_common_draw_context_apply_clean_cutouts(&dc->cutout);
46 free(dc); 99 free(dc);
47} 100}
48 101
49EAPI void 102EAPI void
103evas_common_draw_context_clear_cutouts(RGBA_Draw_Context *dc)
104{
105 evas_common_draw_context_apply_clean_cutouts(&dc->cutout);
106}
107
108EAPI void
50evas_common_draw_context_font_ext_set(RGBA_Draw_Context *dc, 109evas_common_draw_context_font_ext_set(RGBA_Draw_Context *dc,
51 void *data, 110 void *data,
52 void *(*gl_new) (void *data, RGBA_Font_Glyph *fg), 111 void *(*gl_new) (void *data, RGBA_Font_Glyph *fg),
@@ -115,113 +174,34 @@ evas_common_draw_context_unset_multiplier(RGBA_Draw_Context *dc)
115EAPI void 174EAPI void
116evas_common_draw_context_add_cutout(RGBA_Draw_Context *dc, int x, int y, int w, int h) 175evas_common_draw_context_add_cutout(RGBA_Draw_Context *dc, int x, int y, int w, int h)
117{ 176{
118 Cutout_Rect *r; 177 evas_common_draw_context_cutouts_add(&dc->cutout, x, y, w, h);
119
120 r = calloc(1, sizeof(Cutout_Rect));
121 r->x = x;
122 r->y = y;
123 r->w = w;
124 r->h = h;
125 dc->cutout.rects = evas_object_list_append(dc->cutout.rects, r);
126}
127
128EAPI void
129evas_common_draw_context_clear_cutouts(RGBA_Draw_Context *dc)
130{
131 evas_common_draw_context_apply_free_cutouts(dc->cutout.rects);
132 dc->cutout.rects = NULL;
133}
134
135EAPI Cutout_Rect *
136evas_common_draw_context_apply_cutouts(RGBA_Draw_Context *dc)
137{
138 Cutout_Rect *r, *rects;
139 Evas_Object_List *l;
140
141 if (!dc->clip.use) return NULL;
142 if ((dc->clip.w <= 0) || (dc->clip.h <= 0)) return NULL;
143 r = calloc(1, sizeof(Cutout_Rect));
144 r->x = dc->clip.x;
145 r->y = dc->clip.y;
146 r->w = dc->clip.w;
147 r->h = dc->clip.h;
148 rects = r;
149 for (l = (Evas_Object_List *)dc->cutout.rects; l; l = l->next)
150 {
151 r = (Cutout_Rect *)l;
152 rects = evas_common_draw_context_cutouts_split(rects, r);
153 }
154 return rects;
155}
156
157EAPI void
158evas_common_draw_context_apply_free_cutouts(Cutout_Rect *rects)
159{
160 while (rects)
161 {
162 Cutout_Rect *r;
163
164 r = rects;
165 rects = evas_object_list_remove(rects, rects);
166 free(r);
167 }
168}
169
170EAPI Cutout_Rect *
171evas_common_draw_context_cutouts_split(Cutout_Rect *in, Cutout_Rect *split)
172{
173 /* multiple rect in, multiple out */
174 Cutout_Rect *out;
175 Evas_Object_List *l;
176
177 out = NULL;
178 for (l = (Evas_Object_List *)in; l; l = l->next)
179 {
180 Cutout_Rect *r;
181
182 r = (Cutout_Rect *)l;
183 r = evas_common_draw_context_cutout_split(r, split);
184 while (r)
185 {
186 Cutout_Rect *r2;
187
188 r2 = r;
189 r = evas_object_list_remove(r, r);
190 out = evas_object_list_append(out, r2);
191 }
192 }
193 evas_common_draw_context_apply_free_cutouts(in);
194 return out;
195} 178}
196 179
197EAPI Cutout_Rect * 180int
198evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split) 181evas_common_draw_context_cutout_split(Cutout_Rects* res, int index, Cutout_Rect *split)
199{ 182{
200 /* 1 input rect, multiple out */ 183 /* 1 input rect, multiple out */
201 Cutout_Rect *out; 184 Cutout_Rect in = res->rects[index];
202 Cutout_Rect *r;
203 185
204 /* this is to save me a LOT of typing */ 186 /* this is to save me a LOT of typing */
205#define INX1 (in->x) 187#define INX1 (in.x)
206#define INX2 (in->x + in->w) 188#define INX2 (in.x + in.w)
207#define SPX1 (split->x) 189#define SPX1 (split->x)
208#define SPX2 (split->x + split->w) 190#define SPX2 (split->x + split->w)
209#define INY1 (in->y) 191#define INY1 (in.y)
210#define INY2 (in->y + in->h) 192#define INY2 (in.y + in.h)
211#define SPY1 (split->y) 193#define SPY1 (split->y)
212#define SPY2 (split->y + split->h) 194#define SPY2 (split->y + split->h)
213#define X1_IN (in->x < split->x) 195#define X1_IN (in.x < split->x)
214#define X2_IN ((in->x + in->w) > (split->x + split->w)) 196#define X2_IN ((in.x + in.w) > (split->x + split->w))
215#define Y1_IN (in->y < split->y) 197#define Y1_IN (in.y < split->y)
216#define Y2_IN ((in->y + in->h) > (split->y + split->h)) 198#define Y2_IN ((in.y + in.h) > (split->y + split->h))
217#define R_NEW(_r, _x, _y, _w, _h) {(_r) = calloc(1, sizeof(Cutout_Rect)); (_r)->x = (_x); (_r)->y = (_y); (_r)->w = (_w); (_r)->h = (_h);} 199#define R_NEW(_r, _x, _y, _w, _h) { evas_common_draw_context_cutouts_add(_r, _x, _y, _w, _h); }
218 out = NULL; 200 if (!RECTS_INTERSECT(in.x, in.y, in.w, in.h,
219 if (!RECTS_INTERSECT(in->x, in->y, in->w, in->h,
220 split->x, split->y, split->w, split->h)) 201 split->x, split->y, split->w, split->h))
221 { 202 {
222 R_NEW(r, in->x, in->y, in->w, in->h); 203 /* No colision => no clipping, don't touch it. */
223 out = evas_object_list_append(out, r); 204 return 1;
224 return out;
225 } 205 }
226 206
227 /* S = split (ie cut out rect) */ 207 /* S = split (ie cut out rect) */
@@ -237,15 +217,13 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split)
237 */ 217 */
238 if (X1_IN && X2_IN && Y1_IN && Y2_IN) 218 if (X1_IN && X2_IN && Y1_IN && Y2_IN)
239 { 219 {
240 R_NEW(r, in->x, in->y, in->w, SPY1 - in->y); 220 R_NEW(res, in.x, in.y, in.w, SPY1 - in.y);
241 out = evas_object_list_append(out, r); 221 R_NEW(res, in.x, SPY1, SPX1 - in.x, SPY2 - SPY1);
242 R_NEW(r, in->x, SPY1, SPX1 - in->x, SPY2 - SPY1); 222 R_NEW(res, SPX2, SPY1, INX2 - SPX2, SPY2 - SPY1);
243 out = evas_object_list_append(out, r); 223 /* out => (in.x, SPY2, in.w, INY2 - SPY2) */
244 R_NEW(r, SPX2, SPY1, INX2 - SPX2, SPY2 - SPY1); 224 res->rects[index].h = INY2 - SPY2;
245 out = evas_object_list_append(out, r); 225 res->rects[index].y = SPY2;
246 R_NEW(r, in->x, SPY2, in->w, INY2 - SPY2); 226 return 1;
247 out = evas_object_list_append(out, r);
248 return out;
249 } 227 }
250 /* SSSSSSS 228 /* SSSSSSS
251 * S+---+S 229 * S+---+S
@@ -257,7 +235,8 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split)
257 */ 235 */
258 if (!X1_IN && !X2_IN && !Y1_IN && !Y2_IN) 236 if (!X1_IN && !X2_IN && !Y1_IN && !Y2_IN)
259 { 237 {
260 return NULL; 238 evas_common_draw_context_cutouts_del(res, index);
239 return 0;
261 } 240 }
262 /* SSS 241 /* SSS
263 * S+---+ 242 * S+---+
@@ -269,9 +248,10 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split)
269 */ 248 */
270 if (!X1_IN && X2_IN && !Y1_IN && !Y2_IN) 249 if (!X1_IN && X2_IN && !Y1_IN && !Y2_IN)
271 { 250 {
272 R_NEW(r, SPX2, in->y, INX2 - SPX2, in->h); 251 /* in => (SPX2, in.y, INX2 - SPX2, in.h) */
273 out = evas_object_list_append(out, r); 252 res->rects[index].w = INX2 - SPX2;
274 return out; 253 res->rects[index].x = SPX2;
254 return 1;
275 } 255 }
276 /* S 256 /* S
277 * +---+ 257 * +---+
@@ -283,11 +263,11 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split)
283 */ 263 */
284 if (X1_IN && X2_IN && !Y1_IN && !Y2_IN) 264 if (X1_IN && X2_IN && !Y1_IN && !Y2_IN)
285 { 265 {
286 R_NEW(r, in->x, in->y, SPX1 - in->x, in->h); 266 R_NEW(res, in.x, in.y, SPX1 - in.x, in.h);
287 out = evas_object_list_append(out, r); 267 /* in => (SPX2, in.y, INX2 - SPX2, in.h) */
288 R_NEW(r, SPX2, in->y, INX2 - SPX2, in->h); 268 res->rects[index].w = INX2 - SPX2;
289 out = evas_object_list_append(out, r); 269 res->rects[index].x = SPX2;
290 return out; 270 return 1;
291 } 271 }
292 /* SSS 272 /* SSS
293 * +---+S 273 * +---+S
@@ -299,9 +279,9 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split)
299 */ 279 */
300 if (X1_IN && !X2_IN && !Y1_IN && !Y2_IN) 280 if (X1_IN && !X2_IN && !Y1_IN && !Y2_IN)
301 { 281 {
302 R_NEW(r, in->x, in->y, SPX1 - in->x, in->h); 282 /* in => (in.x, in.y, SPX1 - in.x, in.h) */
303 out = evas_object_list_append(out, r); 283 res->rects[index].w = SPX1 - in.x;
304 return out; 284 return 1;
305 } 285 }
306 /* SSSSSSS 286 /* SSSSSSS
307 * S+---+S 287 * S+---+S
@@ -313,9 +293,10 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split)
313 */ 293 */
314 if (!X1_IN && !X2_IN && !Y1_IN && Y2_IN) 294 if (!X1_IN && !X2_IN && !Y1_IN && Y2_IN)
315 { 295 {
316 R_NEW(r, in->x, SPY2, in->w, INY2 - SPY2); 296 /* in => (in.x, SPY2, in.w, INY2 - SPY2) */
317 out = evas_object_list_append(out, r); 297 res->rects[index].h = INY2 - SPY2;
318 return out; 298 res->rects[index].y = SPY2;
299 return 1;
319 } 300 }
320 /* 301 /*
321 * +---+ 302 * +---+
@@ -327,11 +308,10 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split)
327 */ 308 */
328 if (!X1_IN && !X2_IN && Y1_IN && Y2_IN) 309 if (!X1_IN && !X2_IN && Y1_IN && Y2_IN)
329 { 310 {
330 R_NEW(r, in->x, in->y, in->w, SPY1 - in->y); 311 R_NEW(res, in.x, SPY2, in.w, INY2 - SPY2);
331 out = evas_object_list_append(out, r); 312 /* in => (in.x, in.y, in.w, SPY1 - in.y) */
332 R_NEW(r, in->x, SPY2, in->w, INY2 - SPY2); 313 res->rects[index].h = SPY1 - in.y;
333 out = evas_object_list_append(out, r); 314 return 1;
334 return out;
335 } 315 }
336 /* 316 /*
337 * +---+ 317 * +---+
@@ -343,9 +323,9 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split)
343 */ 323 */
344 if (!X1_IN && !X2_IN && Y1_IN && !Y2_IN) 324 if (!X1_IN && !X2_IN && Y1_IN && !Y2_IN)
345 { 325 {
346 R_NEW(r, in->x, in->y, in->w, SPY1 - in->y); 326 /* in => (in.x, in.y, in.w, SPY1 - in.y) */
347 out = evas_object_list_append(out, r); 327 res->rects[index].h = SPY1 - in.y;
348 return out; 328 return 1;
349 } 329 }
350 /* SSS 330 /* SSS
351 * S+---+ 331 * S+---+
@@ -357,11 +337,11 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split)
357 */ 337 */
358 if (!X1_IN && X2_IN && !Y1_IN && Y2_IN) 338 if (!X1_IN && X2_IN && !Y1_IN && Y2_IN)
359 { 339 {
360 R_NEW(r, SPX2, in->y, INX2 - SPX2, SPY2 - in->y); 340 R_NEW(res, SPX2, in.y, INX2 - SPX2, SPY2 - in.y);
361 out = evas_object_list_append(out, r); 341 /* in => (in.x, SPY2, in.w, INY2 - SPY2) */
362 R_NEW(r, in->x, SPY2, in->w, INY2 - SPY2); 342 res->rects[index].h = INY2 - SPY2;
363 out = evas_object_list_append(out, r); 343 res->rects[index].y = SPY2;
364 return out; 344 return 1;
365 } 345 }
366 /* S 346 /* S
367 * +---+ 347 * +---+
@@ -373,13 +353,12 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split)
373 */ 353 */
374 if (X1_IN && X2_IN && !Y1_IN && Y2_IN) 354 if (X1_IN && X2_IN && !Y1_IN && Y2_IN)
375 { 355 {
376 R_NEW(r, in->x, in->y, SPX1 - in->x, SPY2 - in->y); 356 R_NEW(res, in.x, in.y, SPX1 - in.x, SPY2 - in.y);
377 out = evas_object_list_append(out, r); 357 R_NEW(res, SPX2, in.y, INX2 - SPX2, SPY2 - in.y);
378 R_NEW(r, SPX2, in->y, INX2 - SPX2, SPY2 - in->y); 358 /* in => (in.x, SPY2, in.w, INY2 - SPY2) */
379 out = evas_object_list_append(out, r); 359 res->rects[index].h = INY2 - SPY2;
380 R_NEW(r, in->x, SPY2, in->w, INY2 - SPY2); 360 res->rects[index].y = SPY2;
381 out = evas_object_list_append(out, r); 361 return 1;
382 return out;
383 } 362 }
384 /* SSS 363 /* SSS
385 * +---+S 364 * +---+S
@@ -391,11 +370,11 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split)
391 */ 370 */
392 if (X1_IN && !X2_IN && !Y1_IN && Y2_IN) 371 if (X1_IN && !X2_IN && !Y1_IN && Y2_IN)
393 { 372 {
394 R_NEW(r, in->x, in->y, SPX1 - in->x, SPY2 - in->y); 373 R_NEW(res, in.x, in.y, SPX1 - in.x, SPY2 - in.y);
395 out = evas_object_list_append(out, r); 374 /* in => (in.x, SPY2, in.w, INY2 - SPY2) */
396 R_NEW(r, in->x, SPY2, in->w, INY2 - SPY2); 375 res->rects[index].h = INY2 - SPY2;
397 out = evas_object_list_append(out, r); 376 res->rects[index].y = SPY2;
398 return out; 377 return 1;
399 } 378 }
400 /* 379 /*
401 * +---+ 380 * +---+
@@ -407,13 +386,11 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split)
407 */ 386 */
408 if (!X1_IN && X2_IN && Y1_IN && Y2_IN) 387 if (!X1_IN && X2_IN && Y1_IN && Y2_IN)
409 { 388 {
410 R_NEW(r, in->x, in->y, in->w, SPY1 - in->y); 389 R_NEW(res, in.x, SPY2, in.w, INY2 - SPY2);
411 out = evas_object_list_append(out, r); 390 R_NEW(res, SPX2, SPY1, INX2 - SPX2, SPY2 - SPY1);
412 R_NEW(r, SPX2, SPY1, INX2 - SPX2, SPY2 - SPY1); 391 /* in => (in.x, SPY2, in.w, INY2 - SPY2) */
413 out = evas_object_list_append(out, r); 392 res->rects[index].h = SPY1 - in.y;
414 R_NEW(r, in->x, SPY2, in->w, INY2 - SPY2); 393 return 1;
415 out = evas_object_list_append(out, r);
416 return out;
417 } 394 }
418 /* 395 /*
419 * +---+ 396 * +---+
@@ -425,13 +402,11 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split)
425 */ 402 */
426 if (X1_IN && !X2_IN && Y1_IN && Y2_IN) 403 if (X1_IN && !X2_IN && Y1_IN && Y2_IN)
427 { 404 {
428 R_NEW(r, in->x, in->y, in->w, SPY1 - in->y); 405 R_NEW(res, in.x, SPY2, in.w, INY2 - SPY2);
429 out = evas_object_list_append(out, r); 406 R_NEW(res, in.x, SPY1, SPX1 - in.x, SPY2 - SPY1);
430 R_NEW(r, in->x, SPY1, SPX1 - in->x, SPY2 - SPY1); 407 /* in => (in.x, in.y, in.w, SPY1 - in.y) */
431 out = evas_object_list_append(out, r); 408 res->rects[index].h = SPY1 - in.y;
432 R_NEW(r, in->x, SPY2, in->w, INY2 - SPY2); 409 return 1;
433 out = evas_object_list_append(out, r);
434 return out;
435 } 410 }
436 /* 411 /*
437 * +---+ 412 * +---+
@@ -443,11 +418,10 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split)
443 */ 418 */
444 if (!X1_IN && X2_IN && Y1_IN && !Y2_IN) 419 if (!X1_IN && X2_IN && Y1_IN && !Y2_IN)
445 { 420 {
446 R_NEW(r, in->x, in->y, in->w, SPY1 - in->y); 421 R_NEW(res, SPX2, SPY1, INX2 - SPX2, INY2 - SPY1);
447 out = evas_object_list_append(out, r); 422 /* in => (in.x, in.y, in.w, SPY1 - in.y) */
448 R_NEW(r, SPX2, SPY1, INX2 - SPX2, INY2 - SPY1); 423 res->rects[index].h = SPY1 - in.y;
449 out = evas_object_list_append(out, r); 424 return 1;
450 return out;
451 } 425 }
452 /* 426 /*
453 * +---+ 427 * +---+
@@ -459,13 +433,11 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split)
459 */ 433 */
460 if (X1_IN && X2_IN && Y1_IN && !Y2_IN) 434 if (X1_IN && X2_IN && Y1_IN && !Y2_IN)
461 { 435 {
462 R_NEW(r, in->x, in->y, in->w, SPY1 - in->y); 436 R_NEW(res, in.x, SPY1, SPX1 - in.x, INY2 - SPY1);
463 out = evas_object_list_append(out, r); 437 R_NEW(res, SPX2, SPY1, INX2 - SPX2, INY2 - SPY1);
464 R_NEW(r, in->x, SPY1, SPX1 - in->x, INY2 - SPY1); 438 /* in => (in.x, in.y, in.w, SPY1 - in.y) */
465 out = evas_object_list_append(out, r); 439 res->rects[index].h = SPY1 - in.y;
466 R_NEW(r, SPX2, SPY1, INX2 - SPX2, INY2 - SPY1); 440 return 1;
467 out = evas_object_list_append(out, r);
468 return out;
469 } 441 }
470 /* 442 /*
471 * +---+ 443 * +---+
@@ -477,13 +449,13 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split)
477 */ 449 */
478 if (X1_IN && !X2_IN && Y1_IN && !Y2_IN) 450 if (X1_IN && !X2_IN && Y1_IN && !Y2_IN)
479 { 451 {
480 R_NEW(r, in->x, in->y, in->w, SPY1 - in->y); 452 R_NEW(res, in.x, SPY1, SPX1 - in.x, INY2 - SPY1);
481 out = evas_object_list_append(out, r); 453 /* in => (in.x, in.y, in.w, SPY1 - in.y) */
482 R_NEW(r, in->x, SPY1, SPX1 - in->x, INY2 - SPY1); 454 res->rects[index].h = SPY1 - in.y;
483 out = evas_object_list_append(out, r); 455 return 1;
484 return out;
485 } 456 }
486 return NULL; 457 evas_common_draw_context_cutouts_del(res, index);
458 return 0;
487#undef INX1 459#undef INX1
488#undef INX2 460#undef INX2
489#undef SPX1 461#undef SPX1
@@ -499,32 +471,49 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split)
499#undef R_NEW 471#undef R_NEW
500} 472}
501 473
502EAPI Cutout_Rect * 474EAPI Cutout_Rects*
503evas_common_draw_context_cutout_merge(Cutout_Rect *in, Cutout_Rect *merge) 475evas_common_draw_context_apply_cutouts(RGBA_Draw_Context *dc)
504{ 476{
505 /* 1 input rect, multiple out */ 477 Cutout_Rects* res;
506 Cutout_Rect *out; 478 int i;
507 Cutout_Rect *r; 479 int j;
508 Evas_Object_List *l;
509 480
510 for (l = (Evas_Object_List *)in; l; l = l->next) 481 if (!dc->clip.use) return NULL;
511 { 482 if ((dc->clip.w <= 0) || (dc->clip.h <= 0)) return NULL;
512 r = (Cutout_Rect *)l;
513 483
514 merge = evas_common_draw_context_cutouts_split(merge, r); 484 res = evas_common_draw_context_cutouts_new();
515 if (!merge) return in; 485 evas_common_draw_context_cutouts_add(res, dc->clip.x, dc->clip.y, dc->clip.w, dc->clip.h);
516 }
517 r = merge;
518 out = in;
519 while (r)
520 {
521 Cutout_Rect *r2;
522 486
523 r2 = r; 487 for (i = 0; i < dc->cutout.active; ++i)
524 r = evas_object_list_remove(r, r); 488 {
525 out = evas_object_list_append(out, r2); 489 /* Don't loop on the element just added to the list as they are already correctly clipped. */
490 int active = res->active;
491
492 for (j = 0; j < active; )
493 {
494 if (evas_common_draw_context_cutout_split(res, j, dc->cutout.rects + i))
495 ++j;
496 else
497 active--;
498 }
526 } 499 }
527 return out; 500 return res;
501}
502
503EAPI void
504evas_common_draw_context_apply_clear_cutouts(Cutout_Rects* rects)
505{
506 evas_common_draw_context_apply_clean_cutouts(rects);
507 free(rects);
508}
509
510EAPI void
511evas_common_draw_context_apply_clean_cutouts(Cutout_Rects* rects)
512{
513 free(rects->rects);
514 rects->rects = NULL;
515 rects->active = 0;
516 rects->max = 0;
528} 517}
529 518
530EAPI void 519EAPI void