diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/evas/src/lib/engines/common/evas_draw_main.c | 691 |
1 files changed, 0 insertions, 691 deletions
diff --git a/libraries/evas/src/lib/engines/common/evas_draw_main.c b/libraries/evas/src/lib/engines/common/evas_draw_main.c deleted file mode 100644 index d08e788..0000000 --- a/libraries/evas/src/lib/engines/common/evas_draw_main.c +++ /dev/null | |||
@@ -1,691 +0,0 @@ | |||
1 | #include "evas_common.h" | ||
2 | #include "evas_convert_main.h" | ||
3 | #include "evas_private.h" | ||
4 | |||
5 | EAPI Cutout_Rects* | ||
6 | evas_common_draw_context_cutouts_new(void) | ||
7 | { | ||
8 | Cutout_Rects *rects; | ||
9 | |||
10 | rects = calloc(1, sizeof(Cutout_Rects)); | ||
11 | return rects; | ||
12 | } | ||
13 | |||
14 | EAPI void | ||
15 | evas_common_draw_context_cutouts_free(Cutout_Rects* rects) | ||
16 | { | ||
17 | rects->active = 0; | ||
18 | } | ||
19 | |||
20 | EAPI void | ||
21 | evas_common_draw_context_cutouts_del(Cutout_Rects* rects, int idx) | ||
22 | { | ||
23 | if ((idx >= 0) && (idx < rects->active)) | ||
24 | { | ||
25 | Cutout_Rect *rect; | ||
26 | |||
27 | rect = rects->rects + idx; | ||
28 | memmove(rect, rect + 1, | ||
29 | sizeof(Cutout_Rect) * (rects->active - idx - 1)); | ||
30 | rects->active--; | ||
31 | } | ||
32 | } | ||
33 | |||
34 | void | ||
35 | evas_common_init(void) | ||
36 | { | ||
37 | evas_common_cpu_init(); | ||
38 | |||
39 | evas_common_blend_init(); | ||
40 | evas_common_image_init(); | ||
41 | evas_common_convert_init(); | ||
42 | evas_common_scale_init(); | ||
43 | evas_common_rectangle_init(); | ||
44 | evas_common_polygon_init(); | ||
45 | evas_common_line_init(); | ||
46 | evas_common_font_init(); | ||
47 | evas_common_draw_init(); | ||
48 | evas_common_tilebuf_init(); | ||
49 | } | ||
50 | |||
51 | void | ||
52 | evas_common_shutdown(void) | ||
53 | { | ||
54 | evas_font_dir_cache_free(); | ||
55 | evas_common_image_cache_free(); | ||
56 | } | ||
57 | |||
58 | EAPI void | ||
59 | evas_common_draw_init(void) | ||
60 | { | ||
61 | } | ||
62 | |||
63 | EAPI RGBA_Draw_Context * | ||
64 | evas_common_draw_context_new(void) | ||
65 | { | ||
66 | RGBA_Draw_Context *dc; | ||
67 | |||
68 | dc = calloc(1, sizeof(RGBA_Draw_Context)); | ||
69 | dc->sli.h = 1; | ||
70 | return dc; | ||
71 | } | ||
72 | |||
73 | EAPI void | ||
74 | evas_common_draw_context_free(RGBA_Draw_Context *dc) | ||
75 | { | ||
76 | if (!dc) return; | ||
77 | |||
78 | #ifdef HAVE_PIXMAN | ||
79 | if (dc->col.pixman_color_image) | ||
80 | { | ||
81 | pixman_image_unref(dc->col.pixman_color_image); | ||
82 | dc->col.pixman_color_image = NULL; | ||
83 | } | ||
84 | #endif | ||
85 | |||
86 | evas_common_draw_context_apply_clean_cutouts(&dc->cutout); | ||
87 | free(dc); | ||
88 | } | ||
89 | |||
90 | EAPI void | ||
91 | evas_common_draw_context_clear_cutouts(RGBA_Draw_Context *dc) | ||
92 | { | ||
93 | evas_common_draw_context_apply_clean_cutouts(&dc->cutout); | ||
94 | } | ||
95 | |||
96 | EAPI void | ||
97 | evas_common_draw_context_font_ext_set(RGBA_Draw_Context *dc, | ||
98 | void *data, | ||
99 | void *(*gl_new) (void *data, RGBA_Font_Glyph *fg), | ||
100 | void (*gl_free) (void *ext_dat), | ||
101 | void (*gl_draw) (void *data, void *dest, void *context, RGBA_Font_Glyph *fg, int x, int y)) | ||
102 | { | ||
103 | dc->font_ext.data = data; | ||
104 | dc->font_ext.func.gl_new = gl_new; | ||
105 | dc->font_ext.func.gl_free = gl_free; | ||
106 | dc->font_ext.func.gl_draw = gl_draw; | ||
107 | } | ||
108 | |||
109 | EAPI void | ||
110 | evas_common_draw_context_clip_clip(RGBA_Draw_Context *dc, int x, int y, int w, int h) | ||
111 | { | ||
112 | if (dc->clip.use) | ||
113 | { | ||
114 | RECTS_CLIP_TO_RECT(dc->clip.x, dc->clip.y, dc->clip.w, dc->clip.h, | ||
115 | x, y, w, h); | ||
116 | } | ||
117 | else | ||
118 | evas_common_draw_context_set_clip(dc, x, y, w, h); | ||
119 | } | ||
120 | |||
121 | EAPI void | ||
122 | evas_common_draw_context_set_clip(RGBA_Draw_Context *dc, int x, int y, int w, int h) | ||
123 | { | ||
124 | dc->clip.use = 1; | ||
125 | dc->clip.x = x; | ||
126 | dc->clip.y = y; | ||
127 | dc->clip.w = w; | ||
128 | dc->clip.h = h; | ||
129 | } | ||
130 | |||
131 | EAPI void | ||
132 | evas_common_draw_context_unset_clip(RGBA_Draw_Context *dc) | ||
133 | { | ||
134 | dc->clip.use = 0; | ||
135 | } | ||
136 | |||
137 | EAPI void | ||
138 | evas_common_draw_context_set_color(RGBA_Draw_Context *dc, int r, int g, int b, int a) | ||
139 | { | ||
140 | R_VAL(&(dc->col.col)) = (DATA8)r; | ||
141 | G_VAL(&(dc->col.col)) = (DATA8)g; | ||
142 | B_VAL(&(dc->col.col)) = (DATA8)b; | ||
143 | A_VAL(&(dc->col.col)) = (DATA8)a; | ||
144 | #ifdef HAVE_PIXMAN | ||
145 | if (dc && dc->col.pixman_color_image) | ||
146 | pixman_image_unref(dc->col.pixman_color_image); | ||
147 | |||
148 | pixman_color_t pixman_color; | ||
149 | |||
150 | pixman_color.alpha = (dc->col.col & 0xff000000) >> 16; | ||
151 | pixman_color.red = (dc->col.col & 0x00ff0000) >> 8; | ||
152 | pixman_color.green = (dc->col.col & 0x0000ff00); | ||
153 | pixman_color.blue = (dc->col.col & 0x000000ff) << 8; | ||
154 | |||
155 | dc->col.pixman_color_image = pixman_image_create_solid_fill(&pixman_color); | ||
156 | #endif | ||
157 | |||
158 | } | ||
159 | |||
160 | EAPI void | ||
161 | evas_common_draw_context_set_multiplier(RGBA_Draw_Context *dc, int r, int g, int b, int a) | ||
162 | { | ||
163 | dc->mul.use = 1; | ||
164 | R_VAL(&(dc->mul.col)) = (DATA8)r; | ||
165 | G_VAL(&(dc->mul.col)) = (DATA8)g; | ||
166 | B_VAL(&(dc->mul.col)) = (DATA8)b; | ||
167 | A_VAL(&(dc->mul.col)) = (DATA8)a; | ||
168 | } | ||
169 | |||
170 | EAPI void | ||
171 | evas_common_draw_context_unset_multiplier(RGBA_Draw_Context *dc) | ||
172 | { | ||
173 | dc->mul.use = 0; | ||
174 | } | ||
175 | |||
176 | EAPI void | ||
177 | evas_common_draw_context_set_mask(RGBA_Draw_Context *dc, RGBA_Image *mask, int x, int y, int w, int h) | ||
178 | { | ||
179 | dc->mask.mask = mask; | ||
180 | dc->mask.x = x; | ||
181 | dc->mask.y = y; | ||
182 | dc->mask.w = w; | ||
183 | dc->mask.h = h; | ||
184 | |||
185 | #ifdef HAVE_PIXMAN | ||
186 | if (mask->pixman.im) | ||
187 | pixman_image_unref(mask->pixman.im); | ||
188 | |||
189 | if (mask->cache_entry.flags.alpha) | ||
190 | { | ||
191 | mask->pixman.im = pixman_image_create_bits(PIXMAN_a8r8g8b8, w, h, | ||
192 | (uint32_t *)mask->mask.mask, | ||
193 | w * 4); | ||
194 | } | ||
195 | else | ||
196 | { | ||
197 | mask->pixman.im = pixman_image_create_bits(PIXMAN_x8r8g8b8, w, h, | ||
198 | (uint32_t *)mask->mask.mask, | ||
199 | w * 4); | ||
200 | } | ||
201 | #endif | ||
202 | |||
203 | } | ||
204 | |||
205 | EAPI void | ||
206 | evas_common_draw_context_unset_mask(RGBA_Draw_Context *dc) | ||
207 | { | ||
208 | dc->mask.mask = NULL; | ||
209 | |||
210 | #ifdef HAVE_PIXMAN | ||
211 | RGBA_Image *mask; | ||
212 | mask = (RGBA_Image *)dc->mask.mask; | ||
213 | |||
214 | if (mask && mask->pixman.im) | ||
215 | { | ||
216 | pixman_image_unref(mask->pixman.im); | ||
217 | mask->pixman.im = NULL; | ||
218 | } | ||
219 | #endif | ||
220 | } | ||
221 | |||
222 | |||
223 | |||
224 | |||
225 | |||
226 | EAPI void | ||
227 | evas_common_draw_context_add_cutout(RGBA_Draw_Context *dc, int x, int y, int w, int h) | ||
228 | { | ||
229 | // if (dc->cutout.rects > 512) return; | ||
230 | if (dc->clip.use) | ||
231 | { | ||
232 | #if 1 // this is a bit faster | ||
233 | int xa1, xa2, xb1, xb2; | ||
234 | |||
235 | xa1 = x; | ||
236 | xa2 = xa1 + w - 1; | ||
237 | xb1 = dc->clip.x; | ||
238 | if (xa2 < xb1) return; | ||
239 | xb2 = xb1 + dc->clip.w - 1; | ||
240 | if (xa1 >= xb2) return; | ||
241 | if (xa2 > xb2) xa2 = xb2; | ||
242 | if (xb1 > xa1) xa1 = xb1; | ||
243 | x = xa1; | ||
244 | w = xa2 - xa1 + 1; | ||
245 | |||
246 | xa1 = y; | ||
247 | xa2 = xa1 + h - 1; | ||
248 | xb1 = dc->clip.y; | ||
249 | if (xa2 < xb1) return; | ||
250 | xb2 = xb1 + dc->clip.h - 1; | ||
251 | if (xa1 >= xb2) return; | ||
252 | if (xa2 > xb2) xa2 = xb2; | ||
253 | if (xb1 > xa1) xa1 = xb1; | ||
254 | y = xa1; | ||
255 | h = xa2 - xa1 + 1; | ||
256 | #else | ||
257 | RECTS_CLIP_TO_RECT(x, y, w, h, | ||
258 | dc->clip.x, dc->clip.y, dc->clip.w, dc->clip.h); | ||
259 | #endif | ||
260 | if ((w < 1) || (h < 1)) return; | ||
261 | } | ||
262 | evas_common_draw_context_cutouts_add(&dc->cutout, x, y, w, h); | ||
263 | } | ||
264 | |||
265 | int | ||
266 | evas_common_draw_context_cutout_split(Cutout_Rects* res, int idx, Cutout_Rect *split) | ||
267 | { | ||
268 | /* 1 input rect, multiple out */ | ||
269 | Cutout_Rect in = res->rects[idx]; | ||
270 | |||
271 | /* this is to save me a LOT of typing */ | ||
272 | #define INX1 (in.x) | ||
273 | #define INX2 (in.x + in.w) | ||
274 | #define SPX1 (split->x) | ||
275 | #define SPX2 (split->x + split->w) | ||
276 | #define INY1 (in.y) | ||
277 | #define INY2 (in.y + in.h) | ||
278 | #define SPY1 (split->y) | ||
279 | #define SPY2 (split->y + split->h) | ||
280 | #define X1_IN (in.x < split->x) | ||
281 | #define X2_IN ((in.x + in.w) > (split->x + split->w)) | ||
282 | #define Y1_IN (in.y < split->y) | ||
283 | #define Y2_IN ((in.y + in.h) > (split->y + split->h)) | ||
284 | #define R_NEW(_r, _x, _y, _w, _h) { evas_common_draw_context_cutouts_add(_r, _x, _y, _w, _h); } | ||
285 | if (!RECTS_INTERSECT(in.x, in.y, in.w, in.h, | ||
286 | split->x, split->y, split->w, split->h)) | ||
287 | { | ||
288 | /* No colision => no clipping, don't touch it. */ | ||
289 | return 1; | ||
290 | } | ||
291 | |||
292 | /* S = split (ie cut out rect) */ | ||
293 | /* +--+ = in (rect to be cut) */ | ||
294 | |||
295 | /* | ||
296 | * +---+ | ||
297 | * | | | ||
298 | * | S | | ||
299 | * | | | ||
300 | * +---+ | ||
301 | * | ||
302 | */ | ||
303 | if (X1_IN && X2_IN && Y1_IN && Y2_IN) | ||
304 | { | ||
305 | R_NEW(res, in.x, in.y, in.w, SPY1 - in.y); | ||
306 | R_NEW(res, in.x, SPY1, SPX1 - in.x, SPY2 - SPY1); | ||
307 | R_NEW(res, SPX2, SPY1, INX2 - SPX2, SPY2 - SPY1); | ||
308 | /* out => (in.x, SPY2, in.w, INY2 - SPY2) */ | ||
309 | res->rects[idx].h = INY2 - SPY2; | ||
310 | res->rects[idx].y = SPY2; | ||
311 | return 1; | ||
312 | } | ||
313 | /* SSSSSSS | ||
314 | * S+---+S | ||
315 | * S|SSS|S | ||
316 | * S|SSS|S | ||
317 | * S|SSS|S | ||
318 | * S+---+S | ||
319 | * SSSSSSS | ||
320 | */ | ||
321 | if (!X1_IN && !X2_IN && !Y1_IN && !Y2_IN) | ||
322 | { | ||
323 | evas_common_draw_context_cutouts_del(res, idx); | ||
324 | return 0; | ||
325 | } | ||
326 | /* SSS | ||
327 | * S+---+ | ||
328 | * S|S | | ||
329 | * S|S | | ||
330 | * S|S | | ||
331 | * S+---+ | ||
332 | * SSS | ||
333 | */ | ||
334 | if (!X1_IN && X2_IN && !Y1_IN && !Y2_IN) | ||
335 | { | ||
336 | /* in => (SPX2, in.y, INX2 - SPX2, in.h) */ | ||
337 | res->rects[idx].w = INX2 - SPX2; | ||
338 | res->rects[idx].x = SPX2; | ||
339 | return 1; | ||
340 | } | ||
341 | /* S | ||
342 | * +---+ | ||
343 | * | S | | ||
344 | * | S | | ||
345 | * | S | | ||
346 | * +---+ | ||
347 | * S | ||
348 | */ | ||
349 | if (X1_IN && X2_IN && !Y1_IN && !Y2_IN) | ||
350 | { | ||
351 | R_NEW(res, in.x, in.y, SPX1 - in.x, in.h); | ||
352 | /* in => (SPX2, in.y, INX2 - SPX2, in.h) */ | ||
353 | res->rects[idx].w = INX2 - SPX2; | ||
354 | res->rects[idx].x = SPX2; | ||
355 | return 1; | ||
356 | } | ||
357 | /* SSS | ||
358 | * +---+S | ||
359 | * | S|S | ||
360 | * | S|S | ||
361 | * | S|S | ||
362 | * +---+S | ||
363 | * SSS | ||
364 | */ | ||
365 | if (X1_IN && !X2_IN && !Y1_IN && !Y2_IN) | ||
366 | { | ||
367 | /* in => (in.x, in.y, SPX1 - in.x, in.h) */ | ||
368 | res->rects[idx].w = SPX1 - in.x; | ||
369 | return 1; | ||
370 | } | ||
371 | /* SSSSSSS | ||
372 | * S+---+S | ||
373 | * S|SSS|S | ||
374 | * | | | ||
375 | * | | | ||
376 | * +---+ | ||
377 | * | ||
378 | */ | ||
379 | if (!X1_IN && !X2_IN && !Y1_IN && Y2_IN) | ||
380 | { | ||
381 | /* in => (in.x, SPY2, in.w, INY2 - SPY2) */ | ||
382 | res->rects[idx].h = INY2 - SPY2; | ||
383 | res->rects[idx].y = SPY2; | ||
384 | return 1; | ||
385 | } | ||
386 | /* | ||
387 | * +---+ | ||
388 | * | | | ||
389 | * S|SSS|S | ||
390 | * | | | ||
391 | * +---+ | ||
392 | * | ||
393 | */ | ||
394 | if (!X1_IN && !X2_IN && Y1_IN && Y2_IN) | ||
395 | { | ||
396 | R_NEW(res, in.x, SPY2, in.w, INY2 - SPY2); | ||
397 | /* in => (in.x, in.y, in.w, SPY1 - in.y) */ | ||
398 | res->rects[idx].h = SPY1 - in.y; | ||
399 | return 1; | ||
400 | } | ||
401 | /* | ||
402 | * +---+ | ||
403 | * | | | ||
404 | * | | | ||
405 | * S|SSS|S | ||
406 | * S+---+S | ||
407 | * SSSSSSS | ||
408 | */ | ||
409 | if (!X1_IN && !X2_IN && Y1_IN && !Y2_IN) | ||
410 | { | ||
411 | /* in => (in.x, in.y, in.w, SPY1 - in.y) */ | ||
412 | res->rects[idx].h = SPY1 - in.y; | ||
413 | return 1; | ||
414 | } | ||
415 | /* SSS | ||
416 | * S+---+ | ||
417 | * S|S | | ||
418 | * | | | ||
419 | * | | | ||
420 | * +---+ | ||
421 | * | ||
422 | */ | ||
423 | if (!X1_IN && X2_IN && !Y1_IN && Y2_IN) | ||
424 | { | ||
425 | R_NEW(res, SPX2, in.y, INX2 - SPX2, SPY2 - in.y); | ||
426 | /* in => (in.x, SPY2, in.w, INY2 - SPY2) */ | ||
427 | res->rects[idx].h = INY2 - SPY2; | ||
428 | res->rects[idx].y = SPY2; | ||
429 | return 1; | ||
430 | } | ||
431 | /* S | ||
432 | * +---+ | ||
433 | * | S | | ||
434 | * | | | ||
435 | * | | | ||
436 | * +---+ | ||
437 | * | ||
438 | */ | ||
439 | if (X1_IN && X2_IN && !Y1_IN && Y2_IN) | ||
440 | { | ||
441 | R_NEW(res, in.x, in.y, SPX1 - in.x, SPY2 - in.y); | ||
442 | R_NEW(res, SPX2, in.y, INX2 - SPX2, SPY2 - in.y); | ||
443 | /* in => (in.x, SPY2, in.w, INY2 - SPY2) */ | ||
444 | res->rects[idx].h = INY2 - SPY2; | ||
445 | res->rects[idx].y = SPY2; | ||
446 | return 1; | ||
447 | } | ||
448 | /* SSS | ||
449 | * +---+S | ||
450 | * | S|S | ||
451 | * | | | ||
452 | * | | | ||
453 | * +---+ | ||
454 | * | ||
455 | */ | ||
456 | if (X1_IN && !X2_IN && !Y1_IN && Y2_IN) | ||
457 | { | ||
458 | R_NEW(res, in.x, in.y, SPX1 - in.x, SPY2 - in.y); | ||
459 | /* in => (in.x, SPY2, in.w, INY2 - SPY2) */ | ||
460 | res->rects[idx].h = INY2 - SPY2; | ||
461 | res->rects[idx].y = SPY2; | ||
462 | return 1; | ||
463 | } | ||
464 | /* | ||
465 | * +---+ | ||
466 | * | | | ||
467 | * S|S | | ||
468 | * | | | ||
469 | * +---+ | ||
470 | * | ||
471 | */ | ||
472 | if (!X1_IN && X2_IN && Y1_IN && Y2_IN) | ||
473 | { | ||
474 | R_NEW(res, in.x, SPY2, in.w, INY2 - SPY2); | ||
475 | R_NEW(res, SPX2, SPY1, INX2 - SPX2, SPY2 - SPY1); | ||
476 | /* in => (in.x, SPY2, in.w, INY2 - SPY2) */ | ||
477 | res->rects[idx].h = SPY1 - in.y; | ||
478 | return 1; | ||
479 | } | ||
480 | /* | ||
481 | * +---+ | ||
482 | * | | | ||
483 | * | S|S | ||
484 | * | | | ||
485 | * +---+ | ||
486 | * | ||
487 | */ | ||
488 | if (X1_IN && !X2_IN && Y1_IN && Y2_IN) | ||
489 | { | ||
490 | R_NEW(res, in.x, SPY2, in.w, INY2 - SPY2); | ||
491 | R_NEW(res, in.x, SPY1, SPX1 - in.x, SPY2 - SPY1); | ||
492 | /* in => (in.x, in.y, in.w, SPY1 - in.y) */ | ||
493 | res->rects[idx].h = SPY1 - in.y; | ||
494 | return 1; | ||
495 | } | ||
496 | /* | ||
497 | * +---+ | ||
498 | * | | | ||
499 | * | | | ||
500 | * S|S | | ||
501 | * S+---+ | ||
502 | * SSS | ||
503 | */ | ||
504 | if (!X1_IN && X2_IN && Y1_IN && !Y2_IN) | ||
505 | { | ||
506 | R_NEW(res, SPX2, SPY1, INX2 - SPX2, INY2 - SPY1); | ||
507 | /* in => (in.x, in.y, in.w, SPY1 - in.y) */ | ||
508 | res->rects[idx].h = SPY1 - in.y; | ||
509 | return 1; | ||
510 | } | ||
511 | /* | ||
512 | * +---+ | ||
513 | * | | | ||
514 | * | | | ||
515 | * | S | | ||
516 | * +---+ | ||
517 | * S | ||
518 | */ | ||
519 | if (X1_IN && X2_IN && Y1_IN && !Y2_IN) | ||
520 | { | ||
521 | R_NEW(res, in.x, SPY1, SPX1 - in.x, INY2 - SPY1); | ||
522 | R_NEW(res, SPX2, SPY1, INX2 - SPX2, INY2 - SPY1); | ||
523 | /* in => (in.x, in.y, in.w, SPY1 - in.y) */ | ||
524 | res->rects[idx].h = SPY1 - in.y; | ||
525 | return 1; | ||
526 | } | ||
527 | /* | ||
528 | * +---+ | ||
529 | * | | | ||
530 | * | | | ||
531 | * | S|S | ||
532 | * +---+S | ||
533 | * SSS | ||
534 | */ | ||
535 | if (X1_IN && !X2_IN && Y1_IN && !Y2_IN) | ||
536 | { | ||
537 | R_NEW(res, in.x, SPY1, SPX1 - in.x, INY2 - SPY1); | ||
538 | /* in => (in.x, in.y, in.w, SPY1 - in.y) */ | ||
539 | res->rects[idx].h = SPY1 - in.y; | ||
540 | return 1; | ||
541 | } | ||
542 | evas_common_draw_context_cutouts_del(res, idx); | ||
543 | return 0; | ||
544 | #undef INX1 | ||
545 | #undef INX2 | ||
546 | #undef SPX1 | ||
547 | #undef SPX2 | ||
548 | #undef INY1 | ||
549 | #undef INY2 | ||
550 | #undef SPY1 | ||
551 | #undef SPY2 | ||
552 | #undef X1_IN | ||
553 | #undef X2_IN | ||
554 | #undef Y1_IN | ||
555 | #undef Y2_IN | ||
556 | #undef R_NEW | ||
557 | } | ||
558 | |||
559 | EAPI Cutout_Rects* | ||
560 | evas_common_draw_context_apply_cutouts(RGBA_Draw_Context *dc) | ||
561 | { | ||
562 | Cutout_Rects* res, *res2; | ||
563 | int i; | ||
564 | int j; | ||
565 | |||
566 | if (!dc->clip.use) return NULL; | ||
567 | if ((dc->clip.w <= 0) || (dc->clip.h <= 0)) return NULL; | ||
568 | |||
569 | |||
570 | res = evas_common_draw_context_cutouts_new(); | ||
571 | evas_common_draw_context_cutouts_add(res, dc->clip.x, dc->clip.y, dc->clip.w, dc->clip.h); | ||
572 | |||
573 | for (i = 0; i < dc->cutout.active; ++i) | ||
574 | { | ||
575 | /* Don't loop on the element just added to the list as they are already correctly clipped. */ | ||
576 | int active = res->active; | ||
577 | |||
578 | for (j = 0; j < active; ) | ||
579 | { | ||
580 | if (evas_common_draw_context_cutout_split(res, j, dc->cutout.rects + i)) | ||
581 | ++j; | ||
582 | else | ||
583 | active--; | ||
584 | } | ||
585 | } | ||
586 | /* merge rects */ | ||
587 | #define RI res->rects[i] | ||
588 | #define RJ res->rects[j] | ||
589 | if (res->active > 1) | ||
590 | { | ||
591 | int found = 1; | ||
592 | |||
593 | while (found) | ||
594 | { | ||
595 | found = 0; | ||
596 | for (i = 0; i < res->active; i++) | ||
597 | { | ||
598 | for (j = i + 1; j < res->active; j++) | ||
599 | { | ||
600 | /* skip empty rects we are removing */ | ||
601 | if (RJ.w == 0) continue; | ||
602 | /* check if its same width, immediately above or below */ | ||
603 | if ((RJ.w == RI.w) && (RJ.x == RI.x)) | ||
604 | { | ||
605 | if ((RJ.y + RJ.h) == RI.y) /* above */ | ||
606 | { | ||
607 | RI.y = RJ.y; | ||
608 | RI.h += RJ.h; | ||
609 | RJ.w = 0; | ||
610 | found = 1; | ||
611 | } | ||
612 | else if ((RI.y + RI.h) == RJ.y) /* below */ | ||
613 | { | ||
614 | RI.h += RJ.h; | ||
615 | RJ.w = 0; | ||
616 | found = 1; | ||
617 | } | ||
618 | } | ||
619 | /* check if its same height, immediately left or right */ | ||
620 | else if ((RJ.h == RI.h) && (RJ.y == RI.y)) | ||
621 | { | ||
622 | if ((RJ.x + RJ.w) == RI.x) /* left */ | ||
623 | { | ||
624 | RI.x = RJ.x; | ||
625 | RI.w += RJ.w; | ||
626 | RJ.w = 0; | ||
627 | found = 1; | ||
628 | } | ||
629 | else if ((RI.x + RI.w) == RJ.x) /* right */ | ||
630 | { | ||
631 | RI.w += RJ.w; | ||
632 | RJ.w = 0; | ||
633 | found = 1; | ||
634 | } | ||
635 | } | ||
636 | } | ||
637 | } | ||
638 | } | ||
639 | res2 = evas_common_draw_context_cutouts_new(); | ||
640 | for (i = 0; i < res->active; i++) | ||
641 | { | ||
642 | if (RI.w == 0) continue; | ||
643 | evas_common_draw_context_cutouts_add(res2, RI.x, RI.y, RI.w, RI.h); | ||
644 | } | ||
645 | free(res->rects); | ||
646 | free(res); | ||
647 | return res2; | ||
648 | } | ||
649 | return res; | ||
650 | } | ||
651 | |||
652 | EAPI void | ||
653 | evas_common_draw_context_apply_clear_cutouts(Cutout_Rects* rects) | ||
654 | { | ||
655 | evas_common_draw_context_apply_clean_cutouts(rects); | ||
656 | free(rects); | ||
657 | } | ||
658 | |||
659 | EAPI void | ||
660 | evas_common_draw_context_apply_clean_cutouts(Cutout_Rects* rects) | ||
661 | { | ||
662 | free(rects->rects); | ||
663 | rects->rects = NULL; | ||
664 | rects->active = 0; | ||
665 | rects->max = 0; | ||
666 | } | ||
667 | |||
668 | EAPI void | ||
669 | evas_common_draw_context_set_anti_alias(RGBA_Draw_Context *dc , unsigned char aa) | ||
670 | { | ||
671 | dc->anti_alias = !!aa; | ||
672 | } | ||
673 | |||
674 | EAPI void | ||
675 | evas_common_draw_context_set_color_interpolation(RGBA_Draw_Context *dc, int color_space) | ||
676 | { | ||
677 | dc->interpolation.color_space = color_space; | ||
678 | } | ||
679 | |||
680 | EAPI void | ||
681 | evas_common_draw_context_set_render_op(RGBA_Draw_Context *dc , int op) | ||
682 | { | ||
683 | dc->render_op = op; | ||
684 | } | ||
685 | |||
686 | EAPI void | ||
687 | evas_common_draw_context_set_sli(RGBA_Draw_Context *dc, int y, int h) | ||
688 | { | ||
689 | dc->sli.y = y; | ||
690 | dc->sli.h = h; | ||
691 | } | ||