summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-10-01 20:44:48 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-10-01 20:57:39 +0900
commit32514b72717f555870ad09efd6d58972b0fbd90f (patch)
treec8166731c0516bfac76009fa4aa5651af59dd1f0
parente383e3096d22d4be63373e8a0e48aa9662748a58 (diff)
evas - clean up tiler code a lot and remove old commented out stuff
-rw-r--r--src/lib/evas/common/evas_tiler.c641
1 files changed, 76 insertions, 565 deletions
diff --git a/src/lib/evas/common/evas_tiler.c b/src/lib/evas/common/evas_tiler.c
index 9147db38c6..b9f982a10d 100644
--- a/src/lib/evas/common/evas_tiler.c
+++ b/src/lib/evas/common/evas_tiler.c
@@ -1,5 +1,7 @@
1#include "evas_common_private.h" 1#include "evas_common_private.h"
2#ifdef EVAS_RECT_SPLIT 2
3#define FUZZ 32
4#define MAXREG 24
3 5
4static inline void rect_list_node_pool_set_max(int max); 6static inline void rect_list_node_pool_set_max(int max);
5static inline void rect_list_node_pool_flush(void); 7static inline void rect_list_node_pool_flush(void);
@@ -18,10 +20,6 @@ static inline void rect_list_add_split_strict(list_t *rects, list_node_t *node);
18static inline list_node_t *rect_list_add_split_fuzzy(list_t *rects, list_node_t *node, int accepted_error); 20static inline list_node_t *rect_list_add_split_fuzzy(list_t *rects, list_node_t *node, int accepted_error);
19static inline void rect_list_merge_rects(list_t *rects, list_t *to_merge, int accepted_error); 21static inline void rect_list_merge_rects(list_t *rects, list_t *to_merge, int accepted_error);
20static inline void rect_list_add_split_fuzzy_and_merge(list_t *rects, list_node_t *node, int split_accepted_error, int merge_accepted_error); 22static inline void rect_list_add_split_fuzzy_and_merge(list_t *rects, list_node_t *node, int split_accepted_error, int merge_accepted_error);
21static inline void rect_print(const rect_t r);
22#if 0
23static inline void rect_list_print(const list_t rects);
24#endif
25 23
26static const list_node_t list_node_zeroed = { NULL }; 24static const list_node_t list_node_zeroed = { NULL };
27static const list_t list_zeroed = { NULL, NULL }; 25static const list_t list_zeroed = { NULL, NULL };
@@ -43,12 +41,9 @@ rect_list_node_pool_set_max(int max)
43 diff = list_node_pool.len - max; 41 diff = list_node_pool.len - max;
44 for (; diff > 0 && list_node_pool.node; diff--) 42 for (; diff > 0 && list_node_pool.node; diff--)
45 { 43 {
46 list_node_t *node; 44 list_node_t *node = list_node_pool.node;
47
48 node = list_node_pool.node;
49 list_node_pool.node = node->next; 45 list_node_pool.node = node->next;
50 list_node_pool.len--; 46 list_node_pool.len--;
51
52 free(node); 47 free(node);
53 } 48 }
54 49
@@ -60,12 +55,9 @@ rect_list_node_pool_flush(void)
60{ 55{
61 while (list_node_pool.node) 56 while (list_node_pool.node)
62 { 57 {
63 list_node_t *node; 58 list_node_t *node = list_node_pool.node;
64
65 node = list_node_pool.node;
66 list_node_pool.node = node->next; 59 list_node_pool.node = node->next;
67 list_node_pool.len--; 60 list_node_pool.len--;
68
69 free(node); 61 free(node);
70 } 62 }
71} 63}
@@ -75,12 +67,9 @@ rect_list_node_pool_get(void)
75{ 67{
76 if (list_node_pool.node) 68 if (list_node_pool.node)
77 { 69 {
78 list_node_t *node; 70 list_node_t *node = list_node_pool.node;
79
80 node = list_node_pool.node;
81 list_node_pool.node = node->next; 71 list_node_pool.node = node->next;
82 list_node_pool.len--; 72 list_node_pool.len--;
83
84 return node; 73 return node;
85 } 74 }
86 else return (list_node_t *)malloc(sizeof(rect_node_t)); 75 else return (list_node_t *)malloc(sizeof(rect_node_t));
@@ -102,53 +91,15 @@ static inline void
102rect_init(rect_t *r, int x, int y, int w, int h) 91rect_init(rect_t *r, int x, int y, int w, int h)
103{ 92{
104 r->area = w * h; 93 r->area = w * h;
105
106 r->left = x; 94 r->left = x;
107 r->top = y; 95 r->top = y;
108
109 r->right = x + w; 96 r->right = x + w;
110 r->bottom = y + h; 97 r->bottom = y + h;
111
112 r->width = w; 98 r->width = w;
113 r->height = h; 99 r->height = h;
114} 100}
115 101
116static inline void 102static inline void
117rect_print(const rect_t r)
118{
119 INF("<rect(%d, %d, %d, %d)>", r.left, r.top, r.width, r.height);
120}
121
122#if 0
123static inline void
124rect_list_print(const list_t rects)
125{
126 list_node_t *node;
127 int len;
128
129 len = 0;
130 for (node = rects.head; node; node = node->next) len++;
131
132 putchar('[');
133 for (node = rects.head; node; node = node->next)
134 {
135 rect_print(((rect_node_t *)node)->rect);
136 if (node->next)
137 {
138 putchar(',');
139 if (len < 4) putchar(' ');
140 else
141 {
142 putchar('\n');
143 putchar(' ');
144 }
145 }
146 }
147 putchar(']');
148}
149#endif
150
151static inline void
152rect_list_append_node(list_t *rects, list_node_t *node) 103rect_list_append_node(list_t *rects, list_node_t *node)
153{ 104{
154 if (rects->tail) 105 if (rects->tail)
@@ -166,12 +117,9 @@ rect_list_append_node(list_t *rects, list_node_t *node)
166static inline void 117static inline void
167rect_list_append(list_t *rects, const rect_t r) 118rect_list_append(list_t *rects, const rect_t r)
168{ 119{
169 rect_node_t *rect_node; 120 rect_node_t *rect_node = (rect_node_t *)rect_list_node_pool_get();
170
171 rect_node = (rect_node_t *)rect_list_node_pool_get();
172 rect_node->rect = r; 121 rect_node->rect = r;
173 rect_node->_lst = list_node_zeroed; 122 rect_node->_lst = list_node_zeroed;
174
175 rect_list_append_node(rects, (list_node_t *)rect_node); 123 rect_list_append_node(rects, (list_node_t *)rect_node);
176} 124}
177 125
@@ -179,7 +127,6 @@ static inline void
179rect_list_append_xywh(list_t *rects, int x, int y, int w, int h) 127rect_list_append_xywh(list_t *rects, int x, int y, int w, int h)
180{ 128{
181 rect_t r; 129 rect_t r;
182
183 rect_init(&r, x, y, w, h); 130 rect_init(&r, x, y, w, h);
184 rect_list_append(rects, r); 131 rect_list_append(rects, r);
185} 132}
@@ -187,9 +134,7 @@ rect_list_append_xywh(list_t *rects, int x, int y, int w, int h)
187static inline void 134static inline void
188rect_list_concat(list_t *rects, list_t *other) 135rect_list_concat(list_t *rects, list_t *other)
189{ 136{
190 if (!other->head) 137 if (!other->head) return;
191 return;
192
193 if (rects->tail) 138 if (rects->tail)
194 { 139 {
195 rects->tail->next = other->head; 140 rects->tail->next = other->head;
@@ -206,9 +151,9 @@ rect_list_concat(list_t *rects, list_t *other)
206static inline list_node_t * 151static inline list_node_t *
207rect_list_unlink_next(list_t *rects, list_node_t *parent_node) 152rect_list_unlink_next(list_t *rects, list_node_t *parent_node)
208{ 153{
209 list_node_t *node; 154 list_node_t *node;
210 155
211 if (parent_node) 156 if (parent_node)
212 { 157 {
213 node = parent_node->next; 158 node = parent_node->next;
214 parent_node->next = node->next; 159 parent_node->next = node->next;
@@ -218,7 +163,6 @@ rect_list_unlink_next(list_t *rects, list_node_t *parent_node)
218 node = rects->head; 163 node = rects->head;
219 rects->head = node->next; 164 rects->head = node->next;
220 } 165 }
221
222 if (rects->tail == node) rects->tail = parent_node; 166 if (rects->tail == node) rects->tail = parent_node;
223 *node = list_node_zeroed; 167 *node = list_node_zeroed;
224 return node; 168 return node;
@@ -227,22 +171,18 @@ rect_list_unlink_next(list_t *rects, list_node_t *parent_node)
227static inline void 171static inline void
228rect_list_del_next(list_t *rects, list_node_t *parent_node) 172rect_list_del_next(list_t *rects, list_node_t *parent_node)
229{ 173{
230 list_node_t *node; 174 list_node_t *node = rect_list_unlink_next(rects, parent_node);
231
232 node = rect_list_unlink_next(rects, parent_node);
233 rect_list_node_pool_put(node); 175 rect_list_node_pool_put(node);
234} 176}
235 177
236static inline void 178static inline void
237rect_list_clear(list_t *rects) 179rect_list_clear(list_t *rects)
238{ 180{
239 list_node_t *node; 181 list_node_t *node = rects->head;
240
241 node = rects->head;
242 while (node) 182 while (node)
243 { 183 {
244 list_node_t *aux; 184 list_node_t *aux;
245 185
246 aux = node->next; 186 aux = node->next;
247 rect_list_node_pool_put(node); 187 rect_list_node_pool_put(node);
248 node = aux; 188 node = aux;
@@ -257,18 +197,14 @@ _calc_intra_rect_area(const rect_t a, const rect_t b, int *width, int *height)
257 197
258 if (a.left < b.left) max_left = b.left; 198 if (a.left < b.left) max_left = b.left;
259 else max_left = a.left; 199 else max_left = a.left;
260
261 if (a.right < b.right) min_right = a.right; 200 if (a.right < b.right) min_right = a.right;
262 else min_right = b.right; 201 else min_right = b.right;
263
264 *width = min_right - max_left; 202 *width = min_right - max_left;
265 203
266 if (a.top < b.top) max_top = b.top; 204 if (a.top < b.top) max_top = b.top;
267 else max_top = a.top; 205 else max_top = a.top;
268
269 if (a.bottom < b.bottom) min_bottom = a.bottom; 206 if (a.bottom < b.bottom) min_bottom = a.bottom;
270 else min_bottom = b.bottom; 207 else min_bottom = b.bottom;
271
272 *height = min_bottom - max_top; 208 *height = min_bottom - max_top;
273} 209}
274 210
@@ -281,7 +217,6 @@ _split_strict(list_t *dirty, const rect_t current, rect_t r)
281 h_2 = r.bottom - current.bottom; 217 h_2 = r.bottom - current.bottom;
282 w_1 = current.left - r.left; 218 w_1 = current.left - r.left;
283 w_2 = r.right - current.right; 219 w_2 = r.right - current.right;
284
285 if (h_1 > 0) 220 if (h_1 > 0)
286 { 221 {
287 /* .--.r (b) .---.r2 222 /* .--.r (b) .---.r2
@@ -295,7 +230,6 @@ _split_strict(list_t *dirty, const rect_t current, rect_t r)
295 r.height -= h_1; 230 r.height -= h_1;
296 r.top = current.top; 231 r.top = current.top;
297 } 232 }
298
299 if (h_2 > 0) 233 if (h_2 > 0)
300 { 234 {
301 /* .-------.cur (a) 235 /* .-------.cur (a)
@@ -308,7 +242,6 @@ _split_strict(list_t *dirty, const rect_t current, rect_t r)
308 rect_list_append_xywh(dirty, r.left, current.bottom, r.width, h_2); 242 rect_list_append_xywh(dirty, r.left, current.bottom, r.width, h_2);
309 r.height -= h_2; 243 r.height -= h_2;
310 } 244 }
311
312 if (w_1 > 0) 245 if (w_1 > 0)
313 { 246 {
314 /* (b) r .----.cur (a) 247 /* (b) r .----.cur (a)
@@ -322,7 +255,6 @@ _split_strict(list_t *dirty, const rect_t current, rect_t r)
322 /* r.width -= w_1; */ 255 /* r.width -= w_1; */
323 /* r.left = current.left; */ 256 /* r.left = current.left; */
324 } 257 }
325
326 if (w_2 > 0) 258 if (w_2 > 0)
327 { 259 {
328 /* .----.cur (a) 260 /* .----.cur (a)
@@ -343,16 +275,14 @@ rect_list_del_split_strict(list_t *rects, const rect_t del_r)
343{ 275{
344 list_t modified = list_zeroed; 276 list_t modified = list_zeroed;
345 list_node_t *cur_node, *prev_node; 277 list_node_t *cur_node, *prev_node;
278 int intra_width, intra_height;
279 rect_t current;
346 280
347 prev_node = NULL; 281 prev_node = NULL;
348 cur_node = rects->head; 282 cur_node = rects->head;
349 while (cur_node) 283 while (cur_node)
350 { 284 {
351 int intra_width, intra_height;
352 rect_t current;
353
354 current = ((rect_node_t*)cur_node)->rect; 285 current = ((rect_node_t*)cur_node)->rect;
355
356 _calc_intra_rect_area(del_r, current, &intra_width, &intra_height); 286 _calc_intra_rect_area(del_r, current, &intra_width, &intra_height);
357 if ((intra_width <= 0) || (intra_height <= 0)) 287 if ((intra_width <= 0) || (intra_height <= 0))
358 { 288 {
@@ -402,9 +332,7 @@ rect_list_add_split_strict(list_t *rects, list_node_t *node)
402 rect_list_append_node(rects, node); 332 rect_list_append_node(rects, node);
403 return; 333 return;
404 } 334 }
405
406 rect_list_append_node(&dirty, node); 335 rect_list_append_node(&dirty, node);
407
408 cur_node = rects->head; 336 cur_node = rects->head;
409 while (dirty.head) 337 while (dirty.head)
410 { 338 {
@@ -415,9 +343,7 @@ rect_list_add_split_strict(list_t *rects, list_node_t *node)
415 rect_list_concat(rects, &dirty); 343 rect_list_concat(rects, &dirty);
416 break; 344 break;
417 } 345 }
418
419 current = ((rect_node_t*)cur_node)->rect; 346 current = ((rect_node_t*)cur_node)->rect;
420
421 while (dirty.head) 347 while (dirty.head)
422 { 348 {
423 int intra_width, intra_height; 349 int intra_width, intra_height;
@@ -453,7 +379,6 @@ rect_list_add_split_strict(list_t *rects, list_node_t *node)
453 } 379 }
454 dirty = new_dirty; 380 dirty = new_dirty;
455 new_dirty = list_zeroed; 381 new_dirty = list_zeroed;
456
457 cur_node = cur_node->next; 382 cur_node = cur_node->next;
458 } 383 }
459} 384}
@@ -462,10 +387,10 @@ static inline void
462_calc_intra_outer_rect_area(const rect_t a, const rect_t b, 387_calc_intra_outer_rect_area(const rect_t a, const rect_t b,
463 rect_t *intra, rect_t *outer) 388 rect_t *intra, rect_t *outer)
464{ 389{
465 int min_left, max_left, min_right, max_right; 390 int min_left, max_left, min_right, max_right;
466 int min_top, max_top, min_bottom, max_bottom; 391 int min_top, max_top, min_bottom, max_bottom;
467 392
468 if (a.left < b.left) 393 if (a.left < b.left)
469 { 394 {
470 max_left = b.left; 395 max_left = b.left;
471 min_left = a.left; 396 min_left = a.left;
@@ -475,7 +400,6 @@ _calc_intra_outer_rect_area(const rect_t a, const rect_t b,
475 max_left = a.left; 400 max_left = a.left;
476 min_left = b.left; 401 min_left = b.left;
477 } 402 }
478
479 if (a.right < b.right) 403 if (a.right < b.right)
480 { 404 {
481 min_right = a.right; 405 min_right = a.right;
@@ -486,15 +410,12 @@ _calc_intra_outer_rect_area(const rect_t a, const rect_t b,
486 min_right = b.right; 410 min_right = b.right;
487 max_right = a.right; 411 max_right = a.right;
488 } 412 }
489
490 intra->left = max_left; 413 intra->left = max_left;
491 intra->right = min_right; 414 intra->right = min_right;
492 intra->width = min_right - max_left; 415 intra->width = min_right - max_left;
493
494 outer->left = min_left; 416 outer->left = min_left;
495 outer->right = max_right; 417 outer->right = max_right;
496 outer->width = max_right - min_left; 418 outer->width = max_right - min_left;
497
498 if (a.top < b.top) 419 if (a.top < b.top)
499 { 420 {
500 max_top = b.top; 421 max_top = b.top;
@@ -505,7 +426,6 @@ _calc_intra_outer_rect_area(const rect_t a, const rect_t b,
505 max_top = a.top; 426 max_top = a.top;
506 min_top = b.top; 427 min_top = b.top;
507 } 428 }
508
509 if (a.bottom < b.bottom) 429 if (a.bottom < b.bottom)
510 { 430 {
511 min_bottom = a.bottom; 431 min_bottom = a.bottom;
@@ -516,7 +436,6 @@ _calc_intra_outer_rect_area(const rect_t a, const rect_t b,
516 min_bottom = b.bottom; 436 min_bottom = b.bottom;
517 max_bottom = a.bottom; 437 max_bottom = a.bottom;
518 } 438 }
519
520 intra->top = max_top; 439 intra->top = max_top;
521 intra->bottom = min_bottom; 440 intra->bottom = min_bottom;
522 intra->height = min_bottom - max_top; 441 intra->height = min_bottom - max_top;
@@ -524,7 +443,6 @@ _calc_intra_outer_rect_area(const rect_t a, const rect_t b,
524 intra->area = intra->width * intra->height; 443 intra->area = intra->width * intra->height;
525 else 444 else
526 intra->area = 0; 445 intra->area = 0;
527
528 outer->top = min_top; 446 outer->top = min_top;
529 outer->bottom = max_bottom; 447 outer->bottom = max_bottom;
530 outer->height = max_bottom - min_top; 448 outer->height = max_bottom - min_top;
@@ -534,8 +452,8 @@ _calc_intra_outer_rect_area(const rect_t a, const rect_t b,
534enum 452enum
535{ 453{
536 SPLIT_FUZZY_ACTION_NONE, 454 SPLIT_FUZZY_ACTION_NONE,
537 SPLIT_FUZZY_ACTION_SPLIT, 455 SPLIT_FUZZY_ACTION_SPLIT,
538 SPLIT_FUZZY_ACTION_MERGE 456 SPLIT_FUZZY_ACTION_MERGE
539}; 457};
540 458
541static inline int 459static inline int
@@ -549,7 +467,6 @@ _split_fuzzy(list_t *dirty, const rect_t a, rect_t *b)
549 w_2 = b->right - a.right; 467 w_2 = b->right - a.right;
550 468
551 action = SPLIT_FUZZY_ACTION_NONE; 469 action = SPLIT_FUZZY_ACTION_NONE;
552
553 if (h_1 > 0) 470 if (h_1 > 0)
554 { 471 {
555 /* .--.r (b) .---.r2 472 /* .--.r (b) .---.r2
@@ -564,7 +481,6 @@ _split_fuzzy(list_t *dirty, const rect_t a, rect_t *b)
564 b->top = a.top; 481 b->top = a.top;
565 action = SPLIT_FUZZY_ACTION_SPLIT; 482 action = SPLIT_FUZZY_ACTION_SPLIT;
566 } 483 }
567
568 if (h_2 > 0) 484 if (h_2 > 0)
569 { 485 {
570 /* .-------.cur (a) 486 /* .-------.cur (a)
@@ -578,10 +494,8 @@ _split_fuzzy(list_t *dirty, const rect_t a, rect_t *b)
578 b->height -= h_2; 494 b->height -= h_2;
579 action = SPLIT_FUZZY_ACTION_SPLIT; 495 action = SPLIT_FUZZY_ACTION_SPLIT;
580 } 496 }
581
582 if (((w_1 > 0) || (w_2 > 0)) && (a.height == b->height)) 497 if (((w_1 > 0) || (w_2 > 0)) && (a.height == b->height))
583 return SPLIT_FUZZY_ACTION_MERGE; 498 return SPLIT_FUZZY_ACTION_MERGE;
584
585 if (w_1 > 0) 499 if (w_1 > 0)
586 { 500 {
587 /* (b) r .----.cur (a) 501 /* (b) r .----.cur (a)
@@ -596,7 +510,6 @@ _split_fuzzy(list_t *dirty, const rect_t a, rect_t *b)
596 /* b->left = a.left; */ 510 /* b->left = a.left; */
597 action = SPLIT_FUZZY_ACTION_SPLIT; 511 action = SPLIT_FUZZY_ACTION_SPLIT;
598 } 512 }
599
600 if (w_2 > 0) 513 if (w_2 > 0)
601 { 514 {
602 /* .----.cur (a) 515 /* .----.cur (a)
@@ -611,7 +524,6 @@ _split_fuzzy(list_t *dirty, const rect_t a, rect_t *b)
611 /* b->width -= w_2; */ 524 /* b->width -= w_2; */
612 action = SPLIT_FUZZY_ACTION_SPLIT; 525 action = SPLIT_FUZZY_ACTION_SPLIT;
613 } 526 }
614
615 return action; 527 return action;
616} 528}
617 529
@@ -619,16 +531,13 @@ static inline list_node_t *
619rect_list_add_split_fuzzy(list_t *rects, list_node_t *node, int accepted_error) 531rect_list_add_split_fuzzy(list_t *rects, list_node_t *node, int accepted_error)
620{ 532{
621 list_t dirty = list_zeroed; 533 list_t dirty = list_zeroed;
622 list_node_t *old_last; 534 list_node_t *old_last = rects->tail;
623
624 old_last = rects->tail;
625 535
626 if (!rects->head) 536 if (!rects->head)
627 { 537 {
628 rect_list_append_node(rects, node); 538 rect_list_append_node(rects, node);
629 return old_last; 539 return old_last;
630 } 540 }
631
632 rect_list_append_node(&dirty, node); 541 rect_list_append_node(&dirty, node);
633 while (dirty.head) 542 while (dirty.head)
634 { 543 {
@@ -638,7 +547,6 @@ rect_list_add_split_fuzzy(list_t *rects, list_node_t *node, int accepted_error)
638 547
639 d_node = rect_list_unlink_next(&dirty, NULL); 548 d_node = rect_list_unlink_next(&dirty, NULL);
640 r = ((rect_node_t *)d_node)->rect; 549 r = ((rect_node_t *)d_node)->rect;
641
642 prev_cur_node = NULL; 550 prev_cur_node = NULL;
643 cur_node = rects->head; 551 cur_node = rects->head;
644 keep_dirty = 1; 552 keep_dirty = 1;
@@ -648,10 +556,8 @@ rect_list_add_split_fuzzy(list_t *rects, list_node_t *node, int accepted_error)
648 rect_t current, intra, outer; 556 rect_t current, intra, outer;
649 557
650 current = ((rect_node_t *)cur_node)->rect; 558 current = ((rect_node_t *)cur_node)->rect;
651
652 _calc_intra_outer_rect_area(r, current, &intra, &outer); 559 _calc_intra_outer_rect_area(r, current, &intra, &outer);
653 area = current.area + r.area - intra.area; 560 area = current.area + r.area - intra.area;
654
655 if ((intra.width == r.width) && (intra.height == r.height)) 561 if ((intra.width == r.width) && (intra.height == r.height))
656 { 562 {
657 /* .-------.cur 563 /* .-------.cur
@@ -734,25 +640,20 @@ rect_list_add_split_fuzzy(list_t *rects, list_node_t *node, int accepted_error)
734 } 640 }
735 else if (action == SPLIT_FUZZY_ACTION_NONE) 641 else if (action == SPLIT_FUZZY_ACTION_NONE)
736 { 642 {
737 /* 643 /* this rect check was totally useless,
738 * this rect check was totally useless, 644 * should never happen */
739 * should never happen
740 */
741 /* prev_cur_node = cur_node; */ 645 /* prev_cur_node = cur_node; */
742 /* cur_node = cur_node->next; */ 646 /* cur_node = cur_node->next; */
743 WRN("Should not get here!"); 647 WRN("Should not get here!");
744 abort(); 648 abort();
745 } 649 }
746
747 keep_dirty = 0; 650 keep_dirty = 0;
748 break; 651 break;
749 } 652 }
750 } 653 }
751
752 if (UNLIKELY(keep_dirty)) rect_list_append_node(rects, d_node); 654 if (UNLIKELY(keep_dirty)) rect_list_append_node(rects, d_node);
753 else rect_list_node_pool_put(d_node); 655 else rect_list_node_pool_put(d_node);
754 } 656 }
755
756 return old_last; 657 return old_last;
757} 658}
758 659
@@ -764,24 +665,18 @@ _calc_outer_rect_area(const rect_t a, const rect_t b, rect_t *outer)
764 665
765 if (a.left < b.left) min_left = a.left; 666 if (a.left < b.left) min_left = a.left;
766 else min_left = b.left; 667 else min_left = b.left;
767
768 if (a.right < b.right) max_right = b.right; 668 if (a.right < b.right) max_right = b.right;
769 else max_right = a.right; 669 else max_right = a.right;
770
771 outer->left = min_left; 670 outer->left = min_left;
772 outer->right = max_right; 671 outer->right = max_right;
773 outer->width = max_right - min_left; 672 outer->width = max_right - min_left;
774
775 if (a.top < b.top) min_top = a.top; 673 if (a.top < b.top) min_top = a.top;
776 else min_top = b.top; 674 else min_top = b.top;
777
778 if (a.bottom < b.bottom) max_bottom = b.bottom; 675 if (a.bottom < b.bottom) max_bottom = b.bottom;
779 else max_bottom = a.bottom; 676 else max_bottom = a.bottom;
780
781 outer->top = min_top; 677 outer->top = min_top;
782 outer->bottom = max_bottom; 678 outer->bottom = max_bottom;
783 outer->height = max_bottom - min_top; 679 outer->height = max_bottom - min_top;
784
785 outer->area = outer->width * outer->height; 680 outer->area = outer->width * outer->height;
786} 681}
787 682
@@ -795,7 +690,6 @@ rect_list_merge_rects(list_t *rects, list_t *to_merge, int accepted_error)
795 int merged; 690 int merged;
796 691
797 r1 = ((rect_node_t *)to_merge->head)->rect; 692 r1 = ((rect_node_t *)to_merge->head)->rect;
798
799 merged = 0; 693 merged = 0;
800 parent_node = NULL; 694 parent_node = NULL;
801 node = rects->head; 695 node = rects->head;
@@ -805,15 +699,12 @@ rect_list_merge_rects(list_t *rects, list_t *to_merge, int accepted_error)
805 int area; 699 int area;
806 700
807 r2 = ((rect_node_t *)node)->rect; 701 r2 = ((rect_node_t *)node)->rect;
808
809 _calc_outer_rect_area(r1, r2, &outer); 702 _calc_outer_rect_area(r1, r2, &outer);
810 area = r1.area + r2.area; /* intra area is taken as 0 */ 703 area = r1.area + r2.area; /* intra area is taken as 0 */
811 if (outer.area - area <= accepted_error) 704 if (outer.area - area <= accepted_error)
812 { 705 {
813 /* 706 /* remove both r1 and r2, create r3
814 * remove both r1 and r2, create r3 707 * actually r3 uses r2 instance, saves memory */
815 * actually r3 uses r2 instance, saves memory
816 */
817 rect_node_t *n; 708 rect_node_t *n;
818 709
819 n = (rect_node_t *)rect_list_unlink_next(rects, parent_node); 710 n = (rect_node_t *)rect_list_unlink_next(rects, parent_node);
@@ -822,11 +713,9 @@ rect_list_merge_rects(list_t *rects, list_t *to_merge, int accepted_error)
822 merged = 1; 713 merged = 1;
823 break; 714 break;
824 } 715 }
825
826 parent_node = node; 716 parent_node = node;
827 node = node->next; 717 node = node->next;
828 } 718 }
829
830 if (!merged) 719 if (!merged)
831 { 720 {
832 list_node_t *n; 721 list_node_t *n;
@@ -850,32 +739,28 @@ rect_list_add_split_fuzzy_and_merge(list_t *rects,
850 if (n && n->next) 739 if (n && n->next)
851 { 740 {
852 list_t to_merge; 741 list_t to_merge;
853
854 /* split list into 2 segments, already merged and to merge */ 742 /* split list into 2 segments, already merged and to merge */
855 to_merge.head = n->next; 743 to_merge.head = n->next;
856 to_merge.tail = rects->tail; 744 to_merge.tail = rects->tail;
857 rects->tail = n; 745 rects->tail = n;
858 n->next = NULL; 746 n->next = NULL;
859
860 rect_list_merge_rects(rects, &to_merge, merge_accepted_error); 747 rect_list_merge_rects(rects, &to_merge, merge_accepted_error);
861 } 748 }
862} 749}
863#endif /* EVAS_RECT_SPLIT */ 750
864 751static inline int
865#define TILE(tb, x, y) ((tb)->tiles.tiles[((y) * (tb)->tiles.w) + (x)]) 752_add_redraw(list_t *rects, int x, int y, int w, int h)
866 753{
867#ifdef RECTUPDATE 754 rect_node_t *rn;
868#elif defined(EVAS_RECT_SPLIT) 755 rn = (rect_node_t *)rect_list_node_pool_get();
869#else 756 rn->_lst = list_node_zeroed;
870/* 757 rect_init(&rn->rect, x, y, w, h);
871static int tilebuf_x_intersect(Tilebuf *tb, int x, int w, int *x1, int *x2, int *x1_fill, int *x2_fill); 758 rect_list_add_split_fuzzy_and_merge(rects, (list_node_t *)rn,
872static int tilebuf_y_intersect(Tilebuf *tb, int y, int h, int *y1, int *y2, int *y1_fill, int *y2_fill); 759 FUZZ * FUZZ, FUZZ * FUZZ);
873static int tilebuf_intersect(int tsize, int tlen, int tnum, int x, int w, int *x1, int *x2, int *x1_fill, int *x2_fill); 760 return 1;
874 */ 761}
875#endif 762
876/* 763/////////////////////////////////////////////////////////////////
877static void tilebuf_setup(Tilebuf *tb);
878 */
879 764
880EAPI void 765EAPI void
881evas_common_tilebuf_init(void) 766evas_common_tilebuf_init(void)
@@ -889,30 +774,18 @@ evas_common_tilebuf_new(int w, int h)
889 774
890 tb = calloc(1, sizeof(Tilebuf)); 775 tb = calloc(1, sizeof(Tilebuf));
891 if (!tb) return NULL; 776 if (!tb) return NULL;
892
893 tb->tile_size.w = 8; 777 tb->tile_size.w = 8;
894 tb->tile_size.h = 8; 778 tb->tile_size.h = 8;
895 tb->outbuf_w = w; 779 tb->outbuf_w = w;
896 tb->outbuf_h = h; 780 tb->outbuf_h = h;
897
898 return tb; 781 return tb;
899} 782}
900 783
901EAPI void 784EAPI void
902evas_common_tilebuf_free(Tilebuf *tb) 785evas_common_tilebuf_free(Tilebuf *tb)
903{ 786{
904#ifdef RECTUPDATE
905/*
906 evas_common_regionbuf_free(tb->rb);
907 */
908#elif defined(EVAS_RECT_SPLIT)
909 rect_list_clear(&tb->rects); 787 rect_list_clear(&tb->rects);
910 rect_list_node_pool_flush(); 788 rect_list_node_pool_flush();
911#else
912/*
913 if (tb->tiles.tiles) free(tb->tiles.tiles);
914 */
915#endif
916 free(tb); 789 free(tb);
917} 790}
918 791
@@ -921,9 +794,6 @@ evas_common_tilebuf_set_tile_size(Tilebuf *tb, int tw, int th)
921{ 794{
922 tb->tile_size.w = tw; 795 tb->tile_size.w = tw;
923 tb->tile_size.h = th; 796 tb->tile_size.h = th;
924/*
925 tilebuf_setup(tb);
926 */
927} 797}
928 798
929EAPI void 799EAPI void
@@ -939,47 +809,9 @@ evas_common_tilebuf_tile_strict_set(Tilebuf *tb, Eina_Bool strict)
939 tb->strict_tiles = strict; 809 tb->strict_tiles = strict;
940} 810}
941 811
942#ifdef EVAS_RECT_SPLIT
943static inline int
944_add_redraw(list_t *rects, int x, int y, int w, int h)
945{
946 rect_node_t *rn;
947/* we dont need to do this fuzz stuff - it actually creates overdraw bugs
948 * when evas shouldnt draw at all.
949 x >>= 1;
950 y >>= 1;
951 w += 2;
952 w >>= 1;
953 h += 2;
954 h >>= 1;
955 */
956 rn = (rect_node_t *)rect_list_node_pool_get();
957 rn->_lst = list_node_zeroed;
958 rect_init(&rn->rect, x, y, w, h);
959 //INF("ACCOUNTING: add_redraw: %4d,%4d %3dx%3d", x, y, w, h);
960 //testing on my core2 duo desktop - fuzz of 32 or 48 is best.
961#define FUZZ 32
962 rect_list_add_split_fuzzy_and_merge(rects, (list_node_t *)rn,
963 FUZZ * FUZZ, FUZZ * FUZZ);
964 return 1;
965}
966#endif
967
968EAPI int 812EAPI int
969evas_common_tilebuf_add_redraw(Tilebuf *tb, int x, int y, int w, int h) 813evas_common_tilebuf_add_redraw(Tilebuf *tb, int x, int y, int w, int h)
970{ 814{
971#ifdef RECTUPDATE
972/*
973 int i;
974
975 if ((w <= 0) || (h <= 0)) return 0;
976 RECTS_CLIP_TO_RECT(x, y, w, h, 0, 0, tb->outbuf_w, tb->outbuf_h);
977 if ((w <= 0) || (h <= 0)) return 0;
978 for (i = 0; i < h; i++)
979 evas_common_regionbuf_span_add(tb->rb, x, x + w - 1, y + i);
980 return 1;
981 */
982#elif defined(EVAS_RECT_SPLIT)
983 if ((w <= 0) || (h <= 0)) return 0; 815 if ((w <= 0) || (h <= 0)) return 0;
984 RECTS_CLIP_TO_RECT(x, y, w, h, 0, 0, tb->outbuf_w, tb->outbuf_h); 816 RECTS_CLIP_TO_RECT(x, y, w, h, 0, 0, tb->outbuf_w, tb->outbuf_h);
985 if ((w <= 0) || (h <= 0)) return 0; 817 if ((w <= 0) || (h <= 0)) return 0;
@@ -990,77 +822,17 @@ evas_common_tilebuf_add_redraw(Tilebuf *tb, int x, int y, int w, int h)
990 tb->prev_add.w = w; tb->prev_add.h = h; 822 tb->prev_add.w = w; tb->prev_add.h = h;
991 tb->prev_del.w = 0; tb->prev_del.h = 0; 823 tb->prev_del.w = 0; tb->prev_del.h = 0;
992 return _add_redraw(&tb->rects, x, y, w, h); 824 return _add_redraw(&tb->rects, x, y, w, h);
993#else
994/*
995 int tx1, tx2, ty1, ty2, tfx1, tfx2, tfy1, tfy2, xx, yy;
996 int num;
997
998 if ((w <= 0) || (h <= 0)) return 0;
999 RECTS_CLIP_TO_RECT(x, y, w, h, 0, 0, tb->outbuf_w, tb->outbuf_h);
1000 if ((w <= 0) || (h <= 0)) return 0;
1001 num = 0;
1002 // wipes out any motion vectors in tiles it touches into redraws
1003 if (tilebuf_x_intersect(tb, x, w, &tx1, &tx2, &tfx1, &tfx2) &&
1004 tilebuf_y_intersect(tb, y, h, &ty1, &ty2, &tfy1, &tfy2))
1005 {
1006 Tilebuf_Tile *tbt;
1007 int delta_x;
1008 int delta_y;
1009
1010 tbt = &(TILE(tb, tx1, ty1));
1011 delta_x = tx2 - tx1 + 1;
1012 delta_y = ty2 - ty1 + 1;
1013 for (yy = delta_y; yy > 0; yy--)
1014 {
1015 Tilebuf_Tile *tbti;
1016
1017 tbti = tbt;
1018 for (xx = delta_x; xx > 0; xx--)
1019 {
1020 tbti->redraw = 1;
1021 tbti++;
1022 }
1023 tbt += tb->tiles.w;
1024 }
1025 num = (tx2 - tx1 + 1) * (ty2 - ty1 + 1);
1026 }
1027 return num;
1028 */
1029#endif
1030} 825}
1031 826
1032EAPI int 827EAPI int
1033evas_common_tilebuf_del_redraw(Tilebuf *tb, int x, int y, int w, int h) 828evas_common_tilebuf_del_redraw(Tilebuf *tb, int x, int y, int w, int h)
1034{ 829{
1035#ifdef RECTUPDATE
1036/*
1037 int i;
1038
1039 for (i = 0; i < h; i++)
1040 evas_common_regionbuf_span_del(tb->rb, x, x + w - 1, y + i);
1041 */
1042#elif defined(EVAS_RECT_SPLIT)
1043 rect_t r; 830 rect_t r;
1044 831
1045 if (!tb->rects.head) return 0; 832 if (!tb->rects.head) return 0;
1046 if ((w <= 0) || (h <= 0)) return 0; 833 if ((w <= 0) || (h <= 0)) return 0;
1047 RECTS_CLIP_TO_RECT(x, y, w, h, 0, 0, tb->outbuf_w, tb->outbuf_h); 834 RECTS_CLIP_TO_RECT(x, y, w, h, 0, 0, tb->outbuf_w, tb->outbuf_h);
1048 if ((w <= 0) || (h <= 0)) return 0; 835 if ((w <= 0) || (h <= 0)) return 0;
1049
1050/* we dont need to do this fuzz stuff - it actually creates overdraw bugs
1051 * when evas shouldnt draw at all.
1052 x += 1;
1053 y += 1;
1054 x >>= 1;
1055 y >>= 1;
1056 w -= 1;
1057 w >>= 1;
1058 h -= 1;
1059 h >>= 1;
1060
1061 if ((w <= 0) || (h <= 0)) return 0;
1062 */
1063
1064 // optimize a common case -> deleting the exact same rect 2x in a row 836 // optimize a common case -> deleting the exact same rect 2x in a row
1065 if ((tb->prev_del.x == x) && (tb->prev_del.y == y) && 837 if ((tb->prev_del.x == x) && (tb->prev_del.y == y) &&
1066 (tb->prev_del.w == w) && (tb->prev_del.h == h)) return 1; 838 (tb->prev_del.w == w) && (tb->prev_del.h == h)) return 1;
@@ -1068,113 +840,33 @@ evas_common_tilebuf_del_redraw(Tilebuf *tb, int x, int y, int w, int h)
1068 tb->prev_del.w = w; tb->prev_del.h = h; 840 tb->prev_del.w = w; tb->prev_del.h = h;
1069 tb->prev_add.w = 0; tb->prev_add.h = 0; 841 tb->prev_add.w = 0; tb->prev_add.h = 0;
1070 rect_init(&r, x, y, w, h); 842 rect_init(&r, x, y, w, h);
1071
1072 rect_list_del_split_strict(&tb->rects, r); 843 rect_list_del_split_strict(&tb->rects, r);
1073 tb->need_merge = 1; 844 tb->need_merge = 1;
1074 return 0; 845 return 0;
1075#else
1076/*
1077 int tx1, tx2, ty1, ty2, tfx1, tfx2, tfy1, tfy2, xx, yy;
1078 int num;
1079
1080 num = 0;
1081 // wipes out any motion vectors in tiles it touches into redraws
1082 if (tilebuf_x_intersect(tb, x, w, &tx1, &tx2, &tfx1, &tfx2) &&
1083 tilebuf_y_intersect(tb, y, h, &ty1, &ty2, &tfy1, &tfy2))
1084 {
1085 Tilebuf_Tile *tbt;
1086 int delta_y;
1087 int delta_x;
1088
1089 if (!tfx1) tx1++;
1090 if (!tfx2) tx2--;
1091 if (!tfy1) ty1++;
1092 if (!tfy2) ty2--;
1093
1094 tbt = &(TILE(tb, tx1, ty1));
1095 delta_x = tx2 - tx1 + 1;
1096 delta_y = ty2 - ty1 + 1;
1097 for (yy = delta_y; yy > 0; yy--)
1098 {
1099 Tilebuf_Tile *tbti;
1100
1101 tbti = tbt;
1102 for (xx = delta_x; xx > 0; xx--)
1103 {
1104 tbti->redraw = 0;
1105 tbti++;
1106 }
1107 tbt += tb->tiles.w;
1108 }
1109 num = (tx2 - tx1 + 1) * (ty2 - ty1 + 1);
1110 }
1111 return num;
1112 */
1113#endif
1114} 846}
1115 847
1116EAPI int 848EAPI int
1117evas_common_tilebuf_add_motion_vector(Tilebuf *tb EINA_UNUSED, int x EINA_UNUSED, int y EINA_UNUSED, int w EINA_UNUSED, int h EINA_UNUSED, int dx EINA_UNUSED, int dy EINA_UNUSED, int alpha EINA_UNUSED) 849evas_common_tilebuf_add_motion_vector(Tilebuf *tb EINA_UNUSED, int x EINA_UNUSED, int y EINA_UNUSED, int w EINA_UNUSED, int h EINA_UNUSED, int dx EINA_UNUSED, int dy EINA_UNUSED, int alpha EINA_UNUSED)
1118{ 850{
1119#ifdef EVAS_RECT_SPLIT
1120/* motion vector handling never has been used -> disable it
1121 list_t lr = list_zeroed;
1122 int num;
1123
1124 num = _add_redraw(&lr, x, y, w, h);
1125 num += _add_redraw(&lr, x + dx, y + dy, w, h);
1126 while (lr.head)
1127 {
1128 list_node_t *node = rect_list_unlink_next(&lr, NULL);
1129 rect_list_add_split_fuzzy_and_merge(&tb->rects, node,
1130 FUZZ * FUZZ, FUZZ * FUZZ);
1131 }
1132 return num;
1133 */
1134 return 0; 851 return 0;
1135#else
1136/*
1137 int num;
1138
1139 num = evas_common_tilebuf_add_redraw(tb, x, y, w, h);
1140 num += evas_common_tilebuf_add_redraw(tb, x + dx, y + dy, w, h);
1141 return num;
1142 */
1143#endif
1144} 852}
1145 853
1146EAPI void 854EAPI void
1147evas_common_tilebuf_clear(Tilebuf *tb) 855evas_common_tilebuf_clear(Tilebuf *tb)
1148{ 856{
1149#ifdef RECTUPDATE
1150/*
1151 evas_common_regionbuf_clear(tb->rb);
1152 */
1153#elif defined(EVAS_RECT_SPLIT)
1154 tb->prev_add.x = tb->prev_add.y = tb->prev_add.w = tb->prev_add.h = 0; 857 tb->prev_add.x = tb->prev_add.y = tb->prev_add.w = tb->prev_add.h = 0;
1155 tb->prev_del.x = tb->prev_del.y = tb->prev_del.w = tb->prev_del.h = 0; 858 tb->prev_del.x = tb->prev_del.y = tb->prev_del.w = tb->prev_del.h = 0;
1156 rect_list_clear(&tb->rects); 859 rect_list_clear(&tb->rects);
1157 tb->need_merge = 0; 860 tb->need_merge = 0;
1158#else
1159/*
1160 if (!tb->tiles.tiles) return;
1161 memset(tb->tiles.tiles, 0, tb->tiles.w * tb->tiles.h * sizeof(Tilebuf_Tile));
1162 */
1163#endif
1164} 861}
1165 862
1166EAPI Tilebuf_Rect * 863EAPI Tilebuf_Rect *
1167evas_common_tilebuf_get_render_rects(Tilebuf *tb) 864evas_common_tilebuf_get_render_rects(Tilebuf *tb)
1168{ 865{
1169#ifdef RECTUPDATE
1170/*
1171 return evas_common_regionbuf_rects_get(tb->rb);
1172 */
1173#elif defined(EVAS_RECT_SPLIT)
1174 list_node_t *n; 866 list_node_t *n;
1175 list_t to_merge; 867 list_t to_merge;
1176 Tilebuf_Rect *rects = NULL; 868 Tilebuf_Rect *rects = NULL, *rbuf, *r;
1177 int bx1 = 0, bx2 = 0, by1 = 0, by2 = 0, num = 0; 869 int bx1 = 0, bx2 = 0, by1 = 0, by2 = 0, num = 0, x1, x2, y1, y2, i;
1178 870
1179 if (tb->need_merge) 871 if (tb->need_merge)
1180 { 872 {
@@ -1189,8 +881,6 @@ evas_common_tilebuf_get_render_rects(Tilebuf *tb)
1189 to_merge = list_zeroed; 881 to_merge = list_zeroed;
1190 for (n = tb->rects.head; n; n = n->next) 882 for (n = tb->rects.head; n; n = n->next)
1191 { 883 {
1192 int x1, x2, y1, y2;
1193
1194 x1 = ((rect_node_t *)n)->rect.left; 884 x1 = ((rect_node_t *)n)->rect.left;
1195 x2 = x1 + ((rect_node_t *)n)->rect.width; 885 x2 = x1 + ((rect_node_t *)n)->rect.width;
1196 y1 = ((rect_node_t *)n)->rect.top; 886 y1 = ((rect_node_t *)n)->rect.top;
@@ -1207,6 +897,7 @@ evas_common_tilebuf_get_render_rects(Tilebuf *tb)
1207 n = tb->rects.head; 897 n = tb->rects.head;
1208 if (n) 898 if (n)
1209 { 899 {
900 num = 1;
1210 bx1 = ((rect_node_t *)n)->rect.left; 901 bx1 = ((rect_node_t *)n)->rect.left;
1211 bx2 = bx1 + ((rect_node_t *)n)->rect.width; 902 bx2 = bx1 + ((rect_node_t *)n)->rect.width;
1212 by1 = ((rect_node_t *)n)->rect.top; 903 by1 = ((rect_node_t *)n)->rect.top;
@@ -1214,9 +905,6 @@ evas_common_tilebuf_get_render_rects(Tilebuf *tb)
1214 n = n->next; 905 n = n->next;
1215 for (; n; n = n->next) 906 for (; n; n = n->next)
1216 { 907 {
1217
1218 int x1, x2, y1, y2;
1219
1220 x1 = ((rect_node_t *)n)->rect.left; 908 x1 = ((rect_node_t *)n)->rect.left;
1221 if (x1 < bx1) bx1 = x1; 909 if (x1 < bx1) bx1 = x1;
1222 x2 = x1 + ((rect_node_t *)n)->rect.width; 910 x2 = x1 + ((rect_node_t *)n)->rect.width;
@@ -1229,237 +917,60 @@ evas_common_tilebuf_get_render_rects(Tilebuf *tb)
1229 num++; 917 num++;
1230 } 918 }
1231 } 919 }
1232#define MAXREG 24 920 else
1233 /* magic number - but if we have > MAXREG regions to update, take bounding box */ 921 return NULL;
922
923 /* magic number - if we have > MAXREG regions to update, take bounding */
1234 if (num > MAXREG) 924 if (num > MAXREG)
1235 { 925 {
1236 Tilebuf_Rect *r;
1237
1238 r = malloc(sizeof(Tilebuf_Rect)); 926 r = malloc(sizeof(Tilebuf_Rect));
1239 r->x = bx1; 927 if (r)
1240 r->y = by1; 928 {
1241 r->w = bx2 - bx1; 929 EINA_INLIST_GET(r)->next = NULL;
1242 r->h = by2 - by1; 930 EINA_INLIST_GET(r)->prev = NULL;
1243 931 EINA_INLIST_GET(r)->last = NULL;
1244 rects = (Tilebuf_Rect *)eina_inlist_append(EINA_INLIST_GET(rects), EINA_INLIST_GET(r)); 932 r->x = bx1;
933 r->y = by1;
934 r->w = bx2 - bx1;
935 r->h = by2 - by1;
936 rects = (Tilebuf_Rect *)
937 eina_inlist_append(EINA_INLIST_GET(rects),
938 EINA_INLIST_GET(r));
939 }
1245 return rects; 940 return rects;
1246 } 941 }
1247 942
1248 for (n = tb->rects.head; n; n = n->next) 943 rbuf = malloc(sizeof(Tilebuf_Rect) * num);
944 if (!rbuf) return NULL;
945
946 for (i = 0, n = tb->rects.head; n; n = n->next)
1249 { 947 {
1250 rect_t cur; 948 rect_t cur;
1251 949
1252 cur = ((rect_node_t *)n)->rect; 950 cur = ((rect_node_t *)n)->rect;
1253/* disable fuzz - created bugs.
1254 cur.left <<= 1;
1255 cur.top <<= 1;
1256 cur.width <<= 1;
1257 cur.height <<= 1;
1258 */
1259 RECTS_CLIP_TO_RECT(cur.left, cur.top, cur.width, cur.height, 951 RECTS_CLIP_TO_RECT(cur.left, cur.top, cur.width, cur.height,
1260 0, 0, tb->outbuf_w, tb->outbuf_h); 952 0, 0, tb->outbuf_w, tb->outbuf_h);
1261 if ((cur.width > 0) && (cur.height > 0)) 953 if ((cur.width > 0) && (cur.height > 0))
1262 { 954 {
1263 Tilebuf_Rect *r; 955 r = &(rbuf[i]);
1264 956 EINA_INLIST_GET(r)->next = NULL;
1265 r = malloc(sizeof(Tilebuf_Rect)); 957 EINA_INLIST_GET(r)->prev = NULL;
958 EINA_INLIST_GET(r)->last = NULL;
1266 r->x = cur.left; 959 r->x = cur.left;
1267 r->y = cur.top; 960 r->y = cur.top;
1268 r->w = cur.width; 961 r->w = cur.width;
1269 r->h = cur.height; 962 r->h = cur.height;
1270 963 rects = (Tilebuf_Rect *)
1271 rects = (Tilebuf_Rect *)eina_inlist_append(EINA_INLIST_GET(rects), EINA_INLIST_GET(r)); 964 eina_inlist_append(EINA_INLIST_GET(rects),
965 EINA_INLIST_GET(r));
966 i++;
1272 } 967 }
1273 } 968 }
1274 return rects; 969 return rects;
1275
1276#else
1277/*
1278 Tilebuf_Rect *rects = NULL;
1279 Tilebuf_Tile *tbt;
1280 int x, y;
1281
1282 tbt = &(TILE(tb, 0, 0));
1283 for (y = 0; y < tb->tiles.h; y++)
1284 {
1285 for (x = 0; x < tb->tiles.w; x++, tbt++)
1286 {
1287 if (tbt->redraw)
1288 {
1289 Tilebuf_Tile *tbti;
1290 int can_expand_x = 1, can_expand_y = 1;
1291 Tilebuf_Rect *r = NULL;
1292 int xx = 0, yy = 0;
1293 r = malloc(sizeof(Tilebuf_Rect));
1294 r->_list_data.next = NULL;
1295 r->_list_data.prev = NULL;
1296 r->_list_data.last = NULL;
1297
1298 // amalgamate tiles
1299#if 1
1300 tbti = tbt;
1301 while (can_expand_x)
1302 {
1303 tbti++;
1304 xx++;
1305 if ((x + xx) >= tb->tiles.w)
1306 can_expand_x = 0;
1307 else if (!(tbti->redraw))
1308 can_expand_x = 0;
1309 if (can_expand_x)
1310 tbti->redraw = 0;
1311 }
1312 tbti = tbt;
1313 while (can_expand_y)
1314 {
1315 int i;
1316
1317 tbti += tb->tiles.w;
1318 yy++;
1319 if ((y + yy) >= tb->tiles.h)
1320 can_expand_y = 0;
1321 if (can_expand_y)
1322 {
1323 Tilebuf_Tile *tbtj;
1324
1325 tbtj = tbti;
1326 for (i = x; i < x + xx; i++, tbtj++)
1327 {
1328 if (!(tbtj->redraw))
1329 {
1330 can_expand_y = 0;
1331 break;
1332 }
1333 }
1334 }
1335 if (can_expand_y)
1336 {
1337 Tilebuf_Tile *tbtj;
1338
1339 tbtj = tbti;
1340 for (i = x; i < x + xx; i++, tbtj++)
1341 tbtj->redraw = 0;
1342 }
1343 }
1344 tbt->redraw = 0;
1345#else
1346 xx = 1;
1347 yy = 1;
1348#endif
1349 r->x = x * tb->tile_size.w;
1350 r->y = y * tb->tile_size.h;
1351 r->w = (xx) * tb->tile_size.w;
1352 r->h = (yy) * tb->tile_size.h;
1353 rects = eina_inlist_append(rects, r);
1354 x = x + (xx - 1);
1355 tbt += xx - 1;
1356 }
1357 }
1358 }
1359 return rects;
1360 */
1361#endif
1362} 970}
1363 971
1364EAPI void 972EAPI void
1365evas_common_tilebuf_free_render_rects(Tilebuf_Rect *rects) 973evas_common_tilebuf_free_render_rects(Tilebuf_Rect *rects)
1366{ 974{
1367 while (rects) 975 free(rects);
1368 {
1369 Tilebuf_Rect *r;
1370
1371 r = rects;
1372 rects = (Tilebuf_Rect *)eina_inlist_remove(EINA_INLIST_GET(rects), EINA_INLIST_GET(r));
1373 free(r);
1374 }
1375}
1376
1377/* need a way of getting rectangles to: blit, re-render */
1378
1379
1380
1381
1382
1383/* internal usage */
1384/*
1385static void
1386tilebuf_setup(Tilebuf *tb)
1387{
1388 if ((tb->outbuf_w <= 0) || (tb->outbuf_h <= 0)) return;
1389#ifdef RECTUPDATE
1390 tb->rb = evas_common_regionbuf_new(tb->outbuf_w, tb->outbuf_h);
1391#elif defined(EVAS_RECT_SPLIT)
1392 tb->rects = list_zeroed;
1393#else
1394 if (tb->tiles.tiles) free(tb->tiles.tiles);
1395 tb->tiles.tiles = NULL;
1396
1397 tb->tiles.w = (tb->outbuf_w + (tb->tile_size.w - 1)) / tb->tile_size.w;
1398 tb->tiles.h = (tb->outbuf_h + (tb->tile_size.h - 1)) / tb->tile_size.h;
1399
1400 tb->tiles.tiles = malloc(tb->tiles.w * tb->tiles.h * sizeof(Tilebuf_Tile));
1401
1402 if (!tb->tiles.tiles)
1403 {
1404 tb->tiles.w = 0;
1405 tb->tiles.h = 0;
1406 return;
1407 }
1408 memset(tb->tiles.tiles, 0, tb->tiles.w * tb->tiles.h * sizeof(Tilebuf_Tile));
1409#endif
1410}
1411*/
1412
1413#ifdef RECTUPDATE
1414#elif defined(EVAS_RECT_SPLIT)
1415#else
1416/*
1417static int
1418tilebuf_x_intersect(Tilebuf *tb, int x, int w, int *x1, int *x2, int *x1_fill, int *x2_fill)
1419{
1420 return tilebuf_intersect(tb->tile_size.w, tb->outbuf_w, tb->tiles.w,
1421 x, w, x1, x2, x1_fill, x2_fill);
1422}
1423
1424static int
1425tilebuf_y_intersect(Tilebuf *tb, int y, int h, int *y1, int *y2, int *y1_fill, int *y2_fill)
1426{
1427 return tilebuf_intersect(tb->tile_size.h, tb->outbuf_h, tb->tiles.h,
1428 y, h, y1, y2, y1_fill, y2_fill);
1429}
1430
1431static int
1432tilebuf_intersect(int tsize, int tlen, int tnum, int x, int w, int *x1, int *x2, int *x1_fill, int *x2_fill)
1433{
1434 int p1, p2;
1435
1436 // initial clip out of region
1437 if ((x + w) <= 0) return 0;
1438 if (x >= tlen) return 0;
1439
1440 // adjust x & w so it all fits in region
1441 if (x < 0)
1442 {
1443 w += x;
1444 x = 0;
1445 }
1446 if (w < 0) return 0;
1447 if ((x + w) > tlen) w = tlen - x;
1448
1449 // now figure if the first edge is fully filling its tile
1450 p1 = (x) / tsize;
1451 if ((p1 * tsize) == (x)) *x1_fill = 1;
1452 else *x1_fill = 0;
1453 *x1 = p1;
1454
1455 // now figure if the last edge is fully filling its tile
1456 p2 = (x + w - 1) / tsize;
1457 if (((p2 + 1) * tsize) == (x + w)) *x2_fill = 1;
1458 else *x2_fill = 0;
1459 *x2 = p2;
1460
1461 return 1;
1462 tnum = 0;
1463} 976}
1464*/
1465#endif