summaryrefslogtreecommitdiff
path: root/legacy/evas/src/lib/engines
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2005-02-05 02:30:13 +0000
committerCarsten Haitzler <raster@rasterman.com>2005-02-05 02:30:13 +0000
commite79e53e35b01b0197880c317f3c5c223773be6d4 (patch)
treea1283b726ab66ca81dc451b6f1470a05f81dab31 /legacy/evas/src/lib/engines
parent871a93a8d1b554af5e16b7b7e075309fa734db99 (diff)
i worked on a regionbuf set of code (exact rectangles). i THINK it has some
bugs... but its disabled right now and it didnt speed anything up :( but it's there for perusal and later work anyway... SVN revision: 13193
Diffstat (limited to '')
-rw-r--r--legacy/evas/src/lib/engines/buffer/evas_engine.c2
-rw-r--r--legacy/evas/src/lib/engines/common/Makefile.am1
-rw-r--r--legacy/evas/src/lib/engines/common/evas_draw_main.c41
-rw-r--r--legacy/evas/src/lib/engines/common/evas_regionbuf.c355
-rw-r--r--legacy/evas/src/lib/engines/common/evas_tiler.c37
5 files changed, 435 insertions, 1 deletions
diff --git a/legacy/evas/src/lib/engines/buffer/evas_engine.c b/legacy/evas/src/lib/engines/buffer/evas_engine.c
index 4970701370..7db37e8441 100644
--- a/legacy/evas/src/lib/engines/buffer/evas_engine.c
+++ b/legacy/evas/src/lib/engines/buffer/evas_engine.c
@@ -284,7 +284,7 @@ evas_engine_buffer_output_setup(int w,
284 } 284 }
285 re->tb = evas_common_tilebuf_new(w, h); 285 re->tb = evas_common_tilebuf_new(w, h);
286 /* in preliminary tests 16x16 gave highest framerates */ 286 /* in preliminary tests 16x16 gave highest framerates */
287 evas_common_tilebuf_set_tile_size(re->tb, 16, 16); 287 evas_common_tilebuf_set_tile_size(re->tb, 16, 16);
288 return re; 288 return re;
289} 289}
290 290
diff --git a/legacy/evas/src/lib/engines/common/Makefile.am b/legacy/evas/src/lib/engines/common/Makefile.am
index 1bb596b202..ce38c3a4e5 100644
--- a/legacy/evas/src/lib/engines/common/Makefile.am
+++ b/legacy/evas/src/lib/engines/common/Makefile.am
@@ -46,6 +46,7 @@ evas_scale_main.c \
46evas_scale_sample.c \ 46evas_scale_sample.c \
47evas_scale_smooth.c \ 47evas_scale_smooth.c \
48evas_tiler.c \ 48evas_tiler.c \
49evas_regionbuf.c \
49evas_blend_ops.h 50evas_blend_ops.h
50 51
51EXTRA_DIST = \ 52EXTRA_DIST = \
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 2161954a0e..2470e04027 100644
--- a/legacy/evas/src/lib/engines/common/evas_draw_main.c
+++ b/legacy/evas/src/lib/engines/common/evas_draw_main.c
@@ -496,6 +496,47 @@ evas_common_draw_context_cutout_split(Cutout_Rect *in, Cutout_Rect *split)
496 return out; 496 return out;
497 } 497 }
498 return NULL; 498 return NULL;
499#undef INX1
500#undef INX2
501#undef SPX1
502#undef SPX2
503#undef INY1
504#undef INY2
505#undef SPY1
506#undef SPY2
507#undef X1_IN
508#undef X2_IN
509#undef Y1_IN
510#undef Y2_IN
511#undef R_NEW
512}
513
514Cutout_Rect *
515evas_common_draw_context_cutout_merge(Cutout_Rect *in, Cutout_Rect *merge)
516{
517 /* 1 input rect, multiple out */
518 Cutout_Rect *out;
519 Cutout_Rect *r;
520 Evas_Object_List *l;
521
522 for (l = (Evas_Object_List *)in; l; l = l->next)
523 {
524 r = (Cutout_Rect *)l;
525
526 merge = evas_common_draw_context_cutouts_split(merge, r);
527 if (!merge) return in;
528 }
529 r = merge;
530 out = in;
531 while (r)
532 {
533 Cutout_Rect *r2;
534
535 r2 = r;
536 r = evas_object_list_remove(r, r);
537 out = evas_object_list_append(out, r2);
538 }
539 return out;
499} 540}
500 541
501Gfx_Func_Blend_Src_Dst 542Gfx_Func_Blend_Src_Dst
diff --git a/legacy/evas/src/lib/engines/common/evas_regionbuf.c b/legacy/evas/src/lib/engines/common/evas_regionbuf.c
new file mode 100644
index 0000000000..5fb38f57bb
--- /dev/null
+++ b/legacy/evas/src/lib/engines/common/evas_regionbuf.c
@@ -0,0 +1,355 @@
1#include "evas_common.h"
2
3Regionbuf *
4evas_common_regionbuf_new(int w, int h)
5{
6 Regionbuf *rb;
7
8 rb = calloc(1, sizeof(Regionbuf) + (h * sizeof(Regionspan)));
9 if (!rb) return NULL;
10 rb->spans = (Regionspan **)(rb + sizeof(Regionbuf));
11 rb->w = w;
12 rb->h = h;
13 return rb;
14}
15
16void
17evas_common_regionbuf_free(Regionbuf *rb)
18{
19 evas_common_regionbuf_clear(rb);
20 free(rb);
21}
22
23void
24evas_common_regionbuf_clear(Regionbuf *rb)
25{
26 int y;
27
28 for (y = 0; y < rb->h; y++)
29 {
30 while (rb->spans[y])
31 {
32 Regionspan *span;
33
34 span = rb->spans[y];
35 rb->spans[y] = evas_object_list_remove(rb->spans[y], rb->spans[y]);
36 free(span);
37 }
38 }
39}
40
41void
42evas_common_regionbuf_span_add(Regionbuf *rb, int x1, int x2, int y)
43{
44 Evas_Object_List *l;
45 Regionspan *span, *span2, *nspan, *sp_start, *sp_stop;
46
47 /* abort if outside */
48 if ((y < 0) ||
49 (y >= rb->h) ||
50 (x2 < 0) ||
51 (x1 >= rb->w)) return;
52 /* clip to horiz bounds */
53 if (x1 < 0) x1 = 0;
54 if (x2 < (rb->w - 1)) x2 = rb->w - 1;
55 sp_start = NULL;
56 sp_stop = NULL;
57 for (l = (Evas_Object_List *)rb->spans[y]; l; l = l->next)
58 {
59 span = (Regionspan *)l;
60 nspan = (Regionspan *)l->next;
61 /* we dont know what t do with the span yet */
62 if (!sp_start)
63 {
64 /* if new span starts before or on this span or just after
65 * with no gap */
66 if (x1 <= (span->x2 + 1))
67 sp_start = span;
68 /* if there is no next span */
69 if (!nspan)
70 {
71 sp_stop = span;
72 break;
73 }
74 /* if new span ends before the next span starts with a gap of
75 * 1 pixel (or more) */
76 else if (x2 < (nspan->x1 - 1))
77 {
78 sp_stop = span;
79 break;
80 }
81 }
82 /* we already know it already starts before or in sp_start */
83 else
84 {
85 /* there is no span after this one, so this has to be the stop */
86 if (!nspan)
87 {
88 sp_stop = span;
89 break;
90 }
91 /* if new span ends before the next span starts with a gap of
92 * 1 pixel (or more) */
93 else if (x2 < (nspan->x1 - 1))
94 {
95 sp_stop = span;
96 break;
97 }
98 }
99 }
100 /* sp_start is where the new span starts in or before */
101 /* sp_stop is where the new span stops in or after */
102 if ((sp_start) && (sp_stop))
103 {
104 /* same start and stop */
105 if (sp_start == sp_stop)
106 {
107 if (x2 < (sp_start->x1 - 1))
108 {
109 span2 = calloc(1, sizeof(Regionspan));
110 span2->x1 = x1;
111 span2->x2 = x2;
112 rb->spans[y] = evas_object_list_prepend_relative(rb->spans[y], span2, sp_start);
113 return;
114 }
115 if (x1 < sp_start->x1)
116 sp_start->x1 = x1;
117 if (x2 > sp_start->x2)
118 sp_start->x2 = x2;
119 return;
120 }
121 else
122 {
123 /* remove all nodes after sp_start and before_sp_stop because
124 * the new */
125 for (l = ((Evas_Object_List *)sp_start)->next; l != (Evas_Object_List *)sp_stop;)
126 {
127 span = (Regionspan *)l;
128 l = l->next;
129 rb->spans[y] = evas_object_list_remove(rb->spans[y], span);
130 free(span);
131 }
132 /* remove the end span */
133 rb->spans[y] = evas_object_list_remove(rb->spans[y], sp_stop);
134 /* if the new span is before the start span - extend */
135 if (x1 < sp_start->x1)
136 sp_start->x1 = x1;
137 /* if it goes beyond the stop span - extend stop span */
138 if (x2 > sp_stop->x2)
139 sp_stop->x2 = x2;
140 /* extend start span to stop span */
141 sp_start->x2 = sp_stop->x2;
142 /* don't need stop span anymore */
143 free(sp_stop);
144 return;
145 }
146 }
147 /* no start AND stop... just append */
148 span2 = calloc(1, sizeof(Regionspan));
149 span2->x1 = x1;
150 span2->x2 = x2;
151 rb->spans[y] = evas_object_list_append(rb->spans[y], span2);
152}
153
154void
155evas_common_regionbuf_span_del(Regionbuf *rb, int x1, int x2, int y)
156{
157 /* FIXME: del span */
158 Evas_Object_List *l;
159 Regionspan *span, *span2, *nspan, *sp_start, *sp_stop;
160
161 /* abort if outside */
162 if ((y < 0) ||
163 (y >= rb->h) ||
164 (x2 < 0) ||
165 (x1 >= rb->w)) return;
166 /* clip to horiz bounds */
167 if (x1 < 0) x1 = 0;
168 if (x2 < (rb->w - 1)) x2 = rb->w - 1;
169 sp_start = NULL;
170 sp_stop = NULL;
171 for (l = (Evas_Object_List *)rb->spans[y]; l; l = l->next)
172 {
173 span = (Regionspan *)l;
174 nspan = (Regionspan *)l->next;
175 /* we dont know what t do with the span yet */
176 if (!sp_start)
177 {
178 /* if new span starts before or on this span or just after
179 * with no gap */
180 if (x1 <= (span->x2))
181 sp_start = span;
182 /* if there is no next span */
183 if (!nspan)
184 {
185 sp_stop = span;
186 break;
187 }
188 /* if new span ends before the next span starts with a gap of
189 * 1 pixel (or more) */
190 else if (x2 < nspan->x1)
191 {
192 sp_stop = span;
193 break;
194 }
195 }
196 /* we already know it already starts before or in sp_start */
197 else
198 {
199 /* there is no span after this one, so this has to be the stop */
200 if (!nspan)
201 {
202 sp_stop = span;
203 break;
204 }
205 /* if new span ends before the next span starts with a gap of
206 * 1 pixel (or more) */
207 else if (x2 < nspan->x1)
208 {
209 sp_stop = span;
210 break;
211 }
212 }
213 }
214 /* sp_start is where the new span starts in or before */
215 /* sp_stop is where the new span stops in or after */
216 if ((sp_start) && (sp_stop))
217 {
218 /* same start and stop */
219 if (sp_start == sp_stop)
220 {
221 /* if it ends before this the span start starts... return */
222 if (x2 < sp_start->x1)
223 return;
224 /* it starts on or before this span */
225 else if (x1 <= sp_start->x1)
226 {
227 /* right edge is within the span */
228 if (x2 < sp_start->x2)
229 {
230 sp_start->x2 = x2;
231 return;
232 }
233 else
234 {
235 rb->spans[y] = evas_object_list_remove(rb->spans[y], sp_start);
236 return;
237 }
238 }
239 /* it ends on or after the end of thsi span */
240 else if (x2 >= sp_start->x2)
241 {
242 /* it starts after the start */
243 if (x1 > sp_start->x1)
244 {
245 sp_start->x1 = x1;
246 return;
247 }
248 /* remove it all */
249 else
250 {
251 rb->spans[y] = evas_object_list_remove(rb->spans[y], sp_start);
252 return;
253 }
254 return;
255 }
256 /* this breaks the span into 2 */
257 else
258 {
259 span2 = calloc(1, sizeof(Regionspan));
260 span2->x1 = sp_start->x1;
261 span2->x2 = x1 - 1;
262 rb->spans[y] = evas_object_list_prepend_relative(rb->spans[y], span2, sp_start);
263 sp_start->x1 = x2 + 1;
264 return;
265 }
266 }
267 else
268 {
269 /* remove all nodes after sp_start and before_sp_stop because
270 * the new */
271 for (l = ((Evas_Object_List *)sp_start)->next; l != (Evas_Object_List *)sp_stop;)
272 {
273 span = (Regionspan *)l;
274 l = l->next;
275 rb->spans[y] = evas_object_list_remove(rb->spans[y], span);
276 free(span);
277 }
278 /* all of the start span is cut out */
279 if (x1 <= sp_start->x1)
280 {
281 rb->spans[y] = evas_object_list_remove(rb->spans[y], sp_start);
282 free(sp_start);
283 }
284 /* chup it off at the new span start */
285 else
286 sp_start->x2 = x1 - 1;
287 /* all of the end span is cut out */
288 if (x2 >= sp_stop->x2)
289 {
290 rb->spans[y] = evas_object_list_remove(rb->spans[y], sp_stop);
291 free(sp_stop);
292 }
293 /* chop it up at the end */
294 else
295 sp_stop->x1 = x2 + 1;
296 return;
297 }
298 }
299}
300
301Tilebuf_Rect *
302evas_common_regionbuf_rects_get(Regionbuf *rb)
303{
304 Tilebuf_Rect *rects = NULL, *r;
305 int y;
306
307 /* FIXME: take spans, make rects */
308 for (y = 0; y < rb->h; y++)
309 {
310 Evas_Object_List *l, *ll;
311
312 for (l = (Evas_Object_List *)rb->spans[y]; l;)
313 {
314 Regionspan *span;
315 Regionspan *sp_start;
316 int yy;
317
318 sp_start = (Regionspan *)l;
319 l = l->next;
320 rb->spans[y] = evas_object_list_remove(rb->spans[y], sp_start);
321 for (yy = y + 1; yy < rb->h; yy++)
322 {
323 int match = 0;
324
325 for (ll = (Evas_Object_List *)rb->spans[yy]; ll;)
326 {
327 span = (Regionspan *)ll;
328 ll = ll->next;
329 if (span->x1 == sp_start->x1)
330 {
331 if ((span->x1 != sp_start->x1) ||
332 (span->x2 != sp_start->x2))
333 {
334 goto coallate;
335 }
336 match = 1;
337 rb->spans[yy] = evas_object_list_remove(rb->spans[yy], span);
338 free(span);
339 }
340 }
341 if (!match) goto coallate;
342 }
343 coallate:
344 r = calloc(1, sizeof(Tilebuf_Rect));
345 r->x = sp_start->x1;
346 r->y = y;
347 r->w = sp_start->x2 - sp_start->x1 + 1;
348 r->h = yy - y;
349 rects = evas_object_list_append(rects, r);
350 free(sp_start);
351 }
352 }
353 evas_common_regionbuf_clear(rb);
354 return rects;
355}
diff --git a/legacy/evas/src/lib/engines/common/evas_tiler.c b/legacy/evas/src/lib/engines/common/evas_tiler.c
index 660fe078dd..e9d9b51600 100644
--- a/legacy/evas/src/lib/engines/common/evas_tiler.c
+++ b/legacy/evas/src/lib/engines/common/evas_tiler.c
@@ -2,9 +2,12 @@
2 2
3#define TILE(tb, x, y) ((tb)->tiles.tiles[((y) * (tb)->tiles.w) + (x)]) 3#define TILE(tb, x, y) ((tb)->tiles.tiles[((y) * (tb)->tiles.w) + (x)])
4 4
5#ifdef RECTUPDATE
6#else
5static int tilebuf_x_intersect(Tilebuf *tb, int x, int w, int *x1, int *x2, int *x1_fill, int *x2_fill); 7static int tilebuf_x_intersect(Tilebuf *tb, int x, int w, int *x1, int *x2, int *x1_fill, int *x2_fill);
6static int tilebuf_y_intersect(Tilebuf *tb, int y, int h, int *y1, int *y2, int *y1_fill, int *y2_fill); 8static int tilebuf_y_intersect(Tilebuf *tb, int y, int h, int *y1, int *y2, int *y1_fill, int *y2_fill);
7static int tilebuf_intersect(int tsize, int tlen, int tnum, int x, int w, int *x1, int *x2, int *x1_fill, int *x2_fill); 9static int tilebuf_intersect(int tsize, int tlen, int tnum, int x, int w, int *x1, int *x2, int *x1_fill, int *x2_fill);
10#endif
8static void tilebuf_setup(Tilebuf *tb); 11static void tilebuf_setup(Tilebuf *tb);
9 12
10void 13void
@@ -31,7 +34,11 @@ evas_common_tilebuf_new(int w, int h)
31void 34void
32evas_common_tilebuf_free(Tilebuf *tb) 35evas_common_tilebuf_free(Tilebuf *tb)
33{ 36{
37#ifdef RECTUPDATE
38 evas_common_regionbuf_free(tb->rb);
39#else
34 if (tb->tiles.tiles) free(tb->tiles.tiles); 40 if (tb->tiles.tiles) free(tb->tiles.tiles);
41#endif
35 free(tb); 42 free(tb);
36} 43}
37 44
@@ -126,6 +133,13 @@ evas_common_tilebuf_get_tile_size(Tilebuf *tb, int *tw, int *th)
126int 133int
127evas_common_tilebuf_add_redraw(Tilebuf *tb, int x, int y, int w, int h) 134evas_common_tilebuf_add_redraw(Tilebuf *tb, int x, int y, int w, int h)
128{ 135{
136#ifdef RECTUPDATE
137 int i;
138
139 for (i = 0; i < h; i++)
140 evas_common_regionbuf_span_add(tb->rb, x, x + w - 1, y + i);
141 return 1;
142#else
129 int tx1, tx2, ty1, ty2, tfx1, tfx2, tfy1, tfy2, xx, yy; 143 int tx1, tx2, ty1, ty2, tfx1, tfx2, tfy1, tfy2, xx, yy;
130 int num; 144 int num;
131 145
@@ -148,11 +162,18 @@ evas_common_tilebuf_add_redraw(Tilebuf *tb, int x, int y, int w, int h)
148 } 162 }
149 } 163 }
150 return num; 164 return num;
165#endif
151} 166}
152 167
153int 168int
154evas_common_tilebuf_del_redraw(Tilebuf *tb, int x, int y, int w, int h) 169evas_common_tilebuf_del_redraw(Tilebuf *tb, int x, int y, int w, int h)
155{ 170{
171#ifdef RECTUPDATE
172 int i;
173
174 for (i = 0; i < h; i++)
175 evas_common_regionbuf_span_del(tb->rb, x, x + w - 1, y + i);
176#else
156 int tx1, tx2, ty1, ty2, tfx1, tfx2, tfy1, tfy2, xx, yy; 177 int tx1, tx2, ty1, ty2, tfx1, tfx2, tfy1, tfy2, xx, yy;
157 int num; 178 int num;
158 179
@@ -179,6 +200,7 @@ evas_common_tilebuf_del_redraw(Tilebuf *tb, int x, int y, int w, int h)
179 } 200 }
180 } 201 }
181 return num; 202 return num;
203#endif
182} 204}
183 205
184int 206int
@@ -198,13 +220,20 @@ evas_common_tilebuf_add_motion_vector(Tilebuf *tb, int x, int y, int w, int h, i
198void 220void
199evas_common_tilebuf_clear(Tilebuf *tb) 221evas_common_tilebuf_clear(Tilebuf *tb)
200{ 222{
223#ifdef RECTUPDATE
224 evas_common_regionbuf_clear(tb->rb);
225#else
201 if (!tb->tiles.tiles) return; 226 if (!tb->tiles.tiles) return;
202 memset(tb->tiles.tiles, 0, tb->tiles.w * tb->tiles.h * sizeof(Tilebuf_Tile)); 227 memset(tb->tiles.tiles, 0, tb->tiles.w * tb->tiles.h * sizeof(Tilebuf_Tile));
228#endif
203} 229}
204 230
205Tilebuf_Rect * 231Tilebuf_Rect *
206evas_common_tilebuf_get_render_rects(Tilebuf *tb) 232evas_common_tilebuf_get_render_rects(Tilebuf *tb)
207{ 233{
234#ifdef RECTUPDATE
235 return evas_common_regionbuf_rects_get(tb->rb);
236#else
208 Tilebuf_Rect *rects = NULL; 237 Tilebuf_Rect *rects = NULL;
209 int x, y; 238 int x, y;
210 239
@@ -269,6 +298,7 @@ evas_common_tilebuf_get_render_rects(Tilebuf *tb)
269 } 298 }
270 } 299 }
271 return rects; 300 return rects;
301#endif
272} 302}
273 303
274void 304void
@@ -295,6 +325,9 @@ evas_common_tilebuf_free_render_rects(Tilebuf_Rect *rects)
295static void 325static void
296tilebuf_setup(Tilebuf *tb) 326tilebuf_setup(Tilebuf *tb)
297{ 327{
328#ifdef RECTUPDATE
329 tb->rb = evas_common_regionbuf_new(tb->outbuf_w, tb->outbuf_h);
330#else
298 if (tb->tiles.tiles) free(tb->tiles.tiles); 331 if (tb->tiles.tiles) free(tb->tiles.tiles);
299 tb->tiles.tiles = NULL; 332 tb->tiles.tiles = NULL;
300 333
@@ -310,8 +343,11 @@ tilebuf_setup(Tilebuf *tb)
310 return; 343 return;
311 } 344 }
312 memset(tb->tiles.tiles, 0, tb->tiles.w * tb->tiles.h * sizeof(Tilebuf_Tile)); 345 memset(tb->tiles.tiles, 0, tb->tiles.w * tb->tiles.h * sizeof(Tilebuf_Tile));
346#endif
313} 347}
314 348
349#ifdef RECTUPDATE
350#else
315static int 351static int
316tilebuf_x_intersect(Tilebuf *tb, int x, int w, int *x1, int *x2, int *x1_fill, int *x2_fill) 352tilebuf_x_intersect(Tilebuf *tb, int x, int w, int *x1, int *x2, int *x1_fill, int *x2_fill)
317{ 353{
@@ -359,3 +395,4 @@ tilebuf_intersect(int tsize, int tlen, int tnum, int x, int w, int *x1, int *x2,
359 return 1; 395 return 1;
360 tnum = 0; 396 tnum = 0;
361} 397}
398#endif