summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChunEon Park <hermet@hermet.pe.kr>2014-11-25 21:35:33 +0900
committerChunEon Park <hermet@hermet.pe.kr>2014-11-25 21:35:33 +0900
commitcc115ec7869fcb706d2280a0a68fc3f0acb8a246 (patch)
tree3c7d867eee521a0f92b71102fd5a193cd2e3611d
parentb395d7dbd47abadc0ac28e9ff5d5dc1827f66ac6 (diff)
evas/map: code refactoring.
use array for easier indexing in the coming anti-alias logic code.
-rw-r--r--src/lib/evas/common/evas_map_image.c88
-rw-r--r--src/lib/evas/common/evas_map_image_core.c16
2 files changed, 52 insertions, 52 deletions
diff --git a/src/lib/evas/common/evas_map_image.c b/src/lib/evas/common/evas_map_image.c
index e6f1cbe949..01573d2c95 100644
--- a/src/lib/evas/common/evas_map_image.c
+++ b/src/lib/evas/common/evas_map_image.c
@@ -21,7 +21,7 @@ typedef struct _Span Span;
21 21
22struct _Span 22struct _Span
23{ 23{
24 int x1, x2; 24 int x[2];
25 FPc o1, o2, z1, z2; 25 FPc o1, o2, z1, z2;
26 FPc u[2], v[2]; 26 FPc u[2], v[2];
27 DATA32 col[2]; 27 DATA32 col[2];
@@ -60,23 +60,23 @@ _interp_col(int x1, int x2, int p, DATA32 col1, DATA32 col2)
60static inline void 60static inline void
61_interpolated_clip_span(Span *s, int c1, int c2, Eina_Bool interp_col) 61_interpolated_clip_span(Span *s, int c1, int c2, Eina_Bool interp_col)
62{ 62{
63 if (s->x1 < c1) 63 if (s->x[0] < c1)
64 { 64 {
65 s->u[0] = _interp(s->x1, s->x2, c1, s->u[0], s->u[1]); 65 s->u[0] = _interp(s->x[0], s->x[1], c1, s->u[0], s->u[1]);
66 s->v[0] = _interp(s->x1, s->x2, c1, s->v[0], s->v[1]); 66 s->v[0] = _interp(s->x[0], s->x[1], c1, s->v[0], s->v[1]);
67 if (interp_col) 67 if (interp_col)
68 s->col[0] = _interp_col(s->x1, s->x2, c1, s->col[0], s->col[1]); 68 s->col[0] = _interp_col(s->x[0], s->x[1], c1, s->col[0], s->col[1]);
69 s->x1 = c1; 69 s->x[0] = c1;
70 s->o1 = c1 << FP; 70 s->o1 = c1 << FP;
71 // FIXME: do s->z1 71 // FIXME: do s->z1
72 } 72 }
73 if (s->x2 > c2) 73 if (s->x[1] > c2)
74 { 74 {
75 s->u[1] = _interp(s->x1, s->x2, c2, s->u[0], s->u[1]); 75 s->u[1] = _interp(s->x[0], s->x[1], c2, s->u[0], s->u[1]);
76 s->v[1] = _interp(s->x1, s->x2, c2, s->v[0], s->v[1]); 76 s->v[1] = _interp(s->x[0], s->x[1], c2, s->v[0], s->v[1]);
77 if (interp_col) 77 if (interp_col)
78 s->col[1] = _interp_col(s->x1, s->x2, c2, s->col[0], s->col[1]); 78 s->col[1] = _interp_col(s->x[0], s->x[1], c2, s->col[0], s->col[1]);
79 s->x2 = c2; 79 s->x[1] = c2;
80 s->o2 = c2 << FP; 80 s->o2 = c2 << FP;
81 // FIXME: do s->z2 81 // FIXME: do s->z2
82 } 82 }
@@ -115,31 +115,31 @@ _calc_spans(RGBA_Map_Point *p, Line *spans, int ystart, int yend, int cx, int cy
115 if (y == py[0]) 115 if (y == py[0])
116 { 116 {
117 i = 0; 117 i = 0;
118 spans[yp].span[i].x1 = p[leftp].x >> FP; 118 spans[yp].span[i].x[0] = p[leftp].x >> FP;
119 spans[yp].span[i].o1 = p[leftp].x; 119 spans[yp].span[i].o1 = p[leftp].x;
120 spans[yp].span[i].u[0] = p[leftp].u; 120 spans[yp].span[i].u[0] = p[leftp].u;
121 spans[yp].span[i].v[0] = p[leftp].v; 121 spans[yp].span[i].v[0] = p[leftp].v;
122 spans[yp].span[i].col[0] = p[leftp].col; 122 spans[yp].span[i].col[0] = p[leftp].col;
123 spans[yp].span[i].x2 = p[rightp].x >> FP; 123 spans[yp].span[i].x[1] = p[rightp].x >> FP;
124 spans[yp].span[i].o2 = p[rightp].x; 124 spans[yp].span[i].o2 = p[rightp].x;
125 spans[yp].span[i].u[1] = p[rightp].u; 125 spans[yp].span[i].u[1] = p[rightp].u;
126 spans[yp].span[i].v[1] = p[rightp].v; 126 spans[yp].span[i].v[1] = p[rightp].v;
127 spans[yp].span[i].col[1] = p[rightp].col; 127 spans[yp].span[i].col[1] = p[rightp].col;
128 //Outside of the clipper 128 //Outside of the clipper
129 if ((spans[yp].span[i].x1 >= (cx + cw)) || 129 if ((spans[yp].span[i].x[0] > (cx + cw)) ||
130 (spans[yp].span[i].x2 < cx)) 130 (spans[yp].span[i].x[1] < cx))
131 spans[yp].span[i].x1 = -1; 131 spans[yp].span[i].x[0] = -1;
132 else 132 else
133 { 133 {
134 _interpolated_clip_span(&(spans[yp].span[i]), cx, 134 _interpolated_clip_span(&(spans[yp].span[i]), cx,
135 (cx + cw), interp_col); 135 (cx + cw), interp_col);
136 i++; 136 i++;
137 spans[yp].span[i].x1 = -1; 137 spans[yp].span[i].x[0] = -1;
138 } 138 }
139 } 139 }
140 //The polygon shape seems not be completed definitely. 140 //The polygon shape seems not be completed definitely.
141 else 141 else
142 spans[yp].span[0].x1 = -1; 142 spans[yp].span[0].x[0] = -1;
143 } 143 }
144 return; 144 return;
145 } 145 }
@@ -268,47 +268,47 @@ _calc_spans(RGBA_Map_Point *p, Line *spans, int ystart, int yend, int cx, int cy
268 if (edge_num == 2) 268 if (edge_num == 2)
269 { 269 {
270 i = 0; 270 i = 0;
271 spans[yp].span[i].x1 = edge[order[0]][2]; 271 spans[yp].span[i].x[0] = edge[order[0]][2];
272 spans[yp].span[i].o1 = edge[order[0]][3]; 272 spans[yp].span[i].o1 = edge[order[0]][3];
273 spans[yp].span[i].u[0] = uv[order[0]][0]; 273 spans[yp].span[i].u[0] = uv[order[0]][0];
274 spans[yp].span[i].v[0] = uv[order[0]][1]; 274 spans[yp].span[i].v[0] = uv[order[0]][1];
275 spans[yp].span[i].col[0] = col[order[0]]; 275 spans[yp].span[i].col[0] = col[order[0]];
276 276
277 spans[yp].span[i].x2 = edge[order[1]][2]; 277 spans[yp].span[i].x[1] = edge[order[1]][2];
278 spans[yp].span[i].o2 = edge[order[1]][3]; 278 spans[yp].span[i].o2 = edge[order[1]][3];
279 spans[yp].span[i].u[1] = uv[order[1]][0]; 279 spans[yp].span[i].u[1] = uv[order[1]][0];
280 spans[yp].span[i].v[1] = uv[order[1]][1]; 280 spans[yp].span[i].v[1] = uv[order[1]][1];
281 spans[yp].span[i].col[1] = col[order[1]]; 281 spans[yp].span[i].col[1] = col[order[1]];
282 282
283 //Outside of the clipper 283 //Outside of the clipper
284 if ((spans[yp].span[i].x1 >= (cx + cw)) || 284 if ((spans[yp].span[i].x[0] >= (cx + cw)) ||
285 (spans[yp].span[i].x2 < cx)) 285 (spans[yp].span[i].x[1] < cx))
286 spans[yp].span[i].x1 = -1; 286 spans[yp].span[i].x[0] = -1;
287 else 287 else
288 { 288 {
289 _interpolated_clip_span(&(spans[yp].span[i]), cx, (cx + cw), 289 _interpolated_clip_span(&(spans[yp].span[i]), cx, (cx + cw),
290 interp_col); 290 interp_col);
291 i++; 291 i++;
292 spans[yp].span[i].x1 = -1; 292 spans[yp].span[i].x[0] = -1;
293 } 293 }
294 } 294 }
295 else if (edge_num == 4) 295 else if (edge_num == 4)
296 { 296 {
297 i = 0; 297 i = 0;
298 spans[yp].span[i].x1 = edge[order[0]][2]; 298 spans[yp].span[i].x[0] = edge[order[0]][2];
299 spans[yp].span[i].u[0] = uv[order[0]][0]; 299 spans[yp].span[i].u[0] = uv[order[0]][0];
300 spans[yp].span[i].v[0] = uv[order[0]][1]; 300 spans[yp].span[i].v[0] = uv[order[0]][1];
301 spans[yp].span[i].col[0] = col[order[0]]; 301 spans[yp].span[i].col[0] = col[order[0]];
302 302
303 spans[yp].span[i].x2 = edge[order[1]][2]; 303 spans[yp].span[i].x[1] = edge[order[1]][2];
304 spans[yp].span[i].u[1] = uv[order[1]][0]; 304 spans[yp].span[i].u[1] = uv[order[1]][0];
305 spans[yp].span[i].v[1] = uv[order[1]][1]; 305 spans[yp].span[i].v[1] = uv[order[1]][1];
306 spans[yp].span[i].col[1] = col[order[1]]; 306 spans[yp].span[i].col[1] = col[order[1]];
307 307
308 //Outside of the clipper 308 //Outside of the clipper
309 if ((spans[yp].span[i].x1 >= (cx + cw)) || 309 if ((spans[yp].span[i].x[0] >= (cx + cw)) ||
310 (spans[yp].span[i].x2 < cx)) 310 (spans[yp].span[i].x[1] < cx))
311 spans[yp].span[i].x1 = -1; 311 spans[yp].span[i].x[0] = -1;
312 else 312 else
313 { 313 {
314 _interpolated_clip_span(&(spans[yp].span[i]), cx, (cx + cw), 314 _interpolated_clip_span(&(spans[yp].span[i]), cx, (cx + cw),
@@ -316,32 +316,32 @@ _calc_spans(RGBA_Map_Point *p, Line *spans, int ystart, int yend, int cx, int cy
316 i++; 316 i++;
317 } 317 }
318 318
319 spans[yp].span[i].x1 = edge[order[2]][2]; 319 spans[yp].span[i].x[0] = edge[order[2]][2];
320 spans[yp].span[i].u[0] = uv[order[2]][0]; 320 spans[yp].span[i].u[0] = uv[order[2]][0];
321 spans[yp].span[i].v[0] = uv[order[2]][1]; 321 spans[yp].span[i].v[0] = uv[order[2]][1];
322 spans[yp].span[i].col[0] = col[order[2]]; 322 spans[yp].span[i].col[0] = col[order[2]];
323 323
324 spans[yp].span[i].x2 = edge[order[3]][2]; 324 spans[yp].span[i].x[1] = edge[order[3]][2];
325 spans[yp].span[i].u[1] = uv[order[3]][0]; 325 spans[yp].span[i].u[1] = uv[order[3]][0];
326 spans[yp].span[i].v[1] = uv[order[3]][1]; 326 spans[yp].span[i].v[1] = uv[order[3]][1];
327 spans[yp].span[i].col[1] = col[order[3]]; 327 spans[yp].span[i].col[1] = col[order[3]];
328 328
329 //Outside of the clipper 329 //Outside of the clipper
330 if ((spans[yp].span[i].x1 >= (cx + cw)) || 330 if ((spans[yp].span[i].x[0] >= (cx + cw)) ||
331 (spans[yp].span[i].x2 < cx)) 331 (spans[yp].span[i].x[1] < cx))
332 spans[yp].span[i].x1 = -1; 332 spans[yp].span[i].x[0] = -1;
333 else 333 else
334 { 334 {
335 int l = cx; 335 int l = cx;
336 336
337 if (i > 0) l = spans[yp].span[i - 1].x2; 337 if (i > 0) l = spans[yp].span[i - 1].x[1];
338 _interpolated_clip_span(&(spans[yp].span[i]), l, (cx + cw), 338 _interpolated_clip_span(&(spans[yp].span[i]), l, (cx + cw),
339 interp_col); 339 interp_col);
340 } 340 }
341 } 341 }
342 //The polygon shape seems not be completed definitely. 342 //The polygon shape seems not be completed definitely.
343 else 343 else
344 spans[yp].span[0].x1 = -1; 344 spans[yp].span[0].x[0] = -1;
345 } 345 }
346} 346}
347 347
@@ -356,27 +356,27 @@ _clip_spans(Line *spans, int ystart, int yend,
356 356
357 for (y = ystart, yp = 0; y <= yend; y++, yp++) 357 for (y = ystart, yp = 0; y <= yend; y++, yp++)
358 { 358 {
359 if (spans[yp].span[0].x1 > -1) 359 if (spans[yp].span[0].x[0] > -1)
360 { 360 {
361 if ((spans[yp].span[0].x1 >= (cx + cw)) || 361 if ((spans[yp].span[0].x[0] >= (cx + cw)) ||
362 (spans[yp].span[0].x2 < cx)) 362 (spans[yp].span[0].x[1] < cx))
363 { 363 {
364 spans[yp].span[0].x1 = -1; 364 spans[yp].span[0].x[0] = -1;
365 } 365 }
366 else 366 else
367 { 367 {
368 _interpolated_clip_span(&(spans[yp].span[0]), cx, (cx + cw), 368 _interpolated_clip_span(&(spans[yp].span[0]), cx, (cx + cw),
369 interp_col); 369 interp_col);
370 370
371 if ((spans[yp].span[1].x1 >= (cx + cw)) || 371 if ((spans[yp].span[1].x[0] >= (cx + cw)) ||
372 (spans[yp].span[1].x2 < cx)) 372 (spans[yp].span[1].x[1] < cx))
373 { 373 {
374 spans[yp].span[1].x1 = -1; 374 spans[yp].span[1].x[0] = -1;
375 } 375 }
376 else 376 else
377 { 377 {
378 _interpolated_clip_span(&(spans[yp].span[1]), 378 _interpolated_clip_span(&(spans[yp].span[1]),
379 spans[yp].span[0].x2, 379 spans[yp].span[0].x[1],
380 cx + cw, interp_col); 380 cx + cw, interp_col);
381 } 381 }
382 } 382 }
diff --git a/src/lib/evas/common/evas_map_image_core.c b/src/lib/evas/common/evas_map_image_core.c
index c81ccbb1b9..e5f3380322 100644
--- a/src/lib/evas/common/evas_map_image_core.c
+++ b/src/lib/evas/common/evas_map_image_core.c
@@ -26,11 +26,11 @@
26 span = &(line->span[i]); 26 span = &(line->span[i]);
27 27
28 //The polygon shape won't be completed type 28 //The polygon shape won't be completed type
29 if (span->x1 < 0) break; 29 if (span->x[0] < 0) break;
30 30
31 x = span->x1; 31 x = span->x[0];
32 32
33 w = (span->x2 - x); 33 w = (span->x[1] - x);
34 if (w <= 0) continue; 34 if (w <= 0) continue;
35 35
36 dv = (span->o2 - span->o1); 36 dv = (span->o2 - span->o1);
@@ -47,7 +47,7 @@
47 else if (u2 > swp) u2 = swp; 47 else if (u2 > swp) u2 = swp;
48 ud = (u2 - u) / w; 48 ud = (u2 - u) / w;
49 ud = ((long long)ud * (w << FP)) / dv; 49 ud = ((long long)ud * (w << FP)) / dv;
50 u -= (ud * (span->o1 - (span->x1 << FP))) / FP1; 50 u -= (ud * (span->o1 - (span->x[0] << FP))) / FP1;
51 if (ud < 0) u += ud; 51 if (ud < 0) u += ud;
52 if (u < 0) u = 0; 52 if (u < 0) u = 0;
53 else if (u >= swp) u = swp - 1; 53 else if (u >= swp) u = swp - 1;
@@ -61,7 +61,7 @@
61 else if (v2 > shp) v2 = shp; 61 else if (v2 > shp) v2 = shp;
62 vd = (v2 - v) / w; 62 vd = (v2 - v) / w;
63 vd = ((long long)vd * (w << FP)) / dv; 63 vd = ((long long)vd * (w << FP)) / dv;
64 v -= (vd * (span->o1 - (span->x1 << FP))) / FP1; 64 v -= (vd * (span->o1 - (span->x[0] << FP))) / FP1;
65 if (vd < 0) v += vd; 65 if (vd < 0) v += vd;
66 if (v < 0) v = 0; 66 if (v < 0) v = 0;
67 else if (v >= shp) v = shp - 1; 67 else if (v >= shp) v = shp - 1;
@@ -141,11 +141,11 @@
141 span = &(line->span[i]); 141 span = &(line->span[i]);
142 142
143 //The polygon shape won't be completed type 143 //The polygon shape won't be completed type
144 if (span->x1 < 0) break; 144 if (span->x[0] < 0) break;
145 145
146 x = span->x1; 146 x = span->x[0];
147 147
148 w = (span->x2 - x); 148 w = (span->x[1] - x);
149 if (w <= 0) continue; 149 if (w <= 0) continue;
150 150
151 ww = w; 151 ww = w;