diff options
Diffstat (limited to 'libraries/evas/src/lib/engines/common/evas_line_main.c')
-rw-r--r-- | libraries/evas/src/lib/engines/common/evas_line_main.c | 678 |
1 files changed, 678 insertions, 0 deletions
diff --git a/libraries/evas/src/lib/engines/common/evas_line_main.c b/libraries/evas/src/lib/engines/common/evas_line_main.c new file mode 100644 index 0000000..04401cb --- /dev/null +++ b/libraries/evas/src/lib/engines/common/evas_line_main.c | |||
@@ -0,0 +1,678 @@ | |||
1 | #include "evas_common.h" | ||
2 | #include "evas_blend_private.h" | ||
3 | |||
4 | |||
5 | static void | ||
6 | _evas_draw_point(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y); | ||
7 | |||
8 | static void | ||
9 | _evas_draw_simple_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1, int y1); | ||
10 | |||
11 | static void | ||
12 | _evas_draw_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1, int y1); | ||
13 | |||
14 | static void | ||
15 | _evas_draw_line_aa(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1, int y1); | ||
16 | |||
17 | |||
18 | #define IN_RANGE(x, y, w, h) \ | ||
19 | ( x > 0 && y > 0 &&((unsigned)(x) < (unsigned)(w)) && ((unsigned)(y) < (unsigned)(h)) ) | ||
20 | |||
21 | #define IN_RECT(x, y, rx, ry, rw, rh) \ | ||
22 | ( ((unsigned)((x) - (rx)) < (unsigned)(rw)) && \ | ||
23 | ((unsigned)((y) - (ry)) < (unsigned)(rh)) ) | ||
24 | |||
25 | #define EXCHANGE_POINTS(x0, y0, x1, y1) \ | ||
26 | { \ | ||
27 | int _tmp = y0; \ | ||
28 | \ | ||
29 | y0 = y1; \ | ||
30 | y1 = _tmp; \ | ||
31 | \ | ||
32 | _tmp = x0; \ | ||
33 | x0 = x1; \ | ||
34 | x1 = _tmp; \ | ||
35 | } | ||
36 | |||
37 | |||
38 | EAPI void | ||
39 | evas_common_line_init(void) | ||
40 | { | ||
41 | } | ||
42 | |||
43 | EAPI void | ||
44 | evas_common_line_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1, int y1) | ||
45 | { | ||
46 | int x, y, w, h; | ||
47 | int clx, cly, clw, clh; | ||
48 | int cuse, cx, cy, cw, ch; | ||
49 | |||
50 | if ((x0 == x1) && (y0 == y1)) | ||
51 | { | ||
52 | _evas_draw_point(dst, dc, x0, y0); | ||
53 | return; | ||
54 | } | ||
55 | |||
56 | clx = cly = 0; | ||
57 | clw = dst->cache_entry.w; | ||
58 | clh = dst->cache_entry.h; | ||
59 | |||
60 | /* save out clip info */ | ||
61 | cuse = dc->clip.use; | ||
62 | cx = dc->clip.x; | ||
63 | cy = dc->clip.y; | ||
64 | cw = dc->clip.w; | ||
65 | ch = dc->clip.h; | ||
66 | |||
67 | if (cuse) | ||
68 | { | ||
69 | RECTS_CLIP_TO_RECT(clx, cly, clw, clh, cx, cy, cw, ch); | ||
70 | if ((clw < 1) || (clh < 1)) | ||
71 | return; | ||
72 | } | ||
73 | |||
74 | x = MIN(x0, x1); | ||
75 | y = MIN(y0, y1); | ||
76 | w = MAX(x0, x1) - x + 1; | ||
77 | h = MAX(y0, y1) - y + 1; | ||
78 | |||
79 | RECTS_CLIP_TO_RECT(clx, cly, clw, clh, x, y, w, h); | ||
80 | if ((clw < 1) || (clh < 1)) | ||
81 | return; | ||
82 | |||
83 | dc->clip.use = 1; | ||
84 | dc->clip.x = clx; | ||
85 | dc->clip.y = cly; | ||
86 | dc->clip.w = clw; | ||
87 | dc->clip.h = clh; | ||
88 | |||
89 | if (dc->anti_alias) | ||
90 | _evas_draw_line_aa(dst, dc, x0, y0, x1, y1); | ||
91 | else | ||
92 | _evas_draw_line(dst, dc, x0, y0, x1, y1); | ||
93 | |||
94 | /* restore clip info */ | ||
95 | dc->clip.use = cuse; | ||
96 | dc->clip.x = cx; | ||
97 | dc->clip.y = cy; | ||
98 | dc->clip.w = cw; | ||
99 | dc->clip.h = ch; | ||
100 | } | ||
101 | |||
102 | |||
103 | static void | ||
104 | _evas_draw_point(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y) | ||
105 | { | ||
106 | RGBA_Gfx_Pt_Func pfunc; | ||
107 | |||
108 | if (!IN_RANGE(x, y, dst->cache_entry.w, dst->cache_entry.h)) | ||
109 | return; | ||
110 | if ((dc->clip.use) && (!IN_RECT(x, y, dc->clip.x, dc->clip.y, dc->clip.w, dc->clip.h))) | ||
111 | return; | ||
112 | pfunc = evas_common_gfx_func_composite_color_pt_get(dc->col.col, dst, dc->render_op); | ||
113 | if (pfunc) | ||
114 | pfunc(0, 255, dc->col.col, dst->image.data + (dst->cache_entry.w * y) + x); | ||
115 | } | ||
116 | |||
117 | /* | ||
118 | these functions use the dc->clip data as bounding | ||
119 | data. they assume that such data has already been cut | ||
120 | back to lie in the dst image rect and the object's | ||
121 | (line) bounding rect. | ||
122 | */ | ||
123 | static void | ||
124 | _evas_draw_simple_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1, int y1) | ||
125 | { | ||
126 | int dx, dy, len, lx, ty, rx, by; | ||
127 | int clx, cly, clw, clh; | ||
128 | int dstw; | ||
129 | DATA32 *p, color; | ||
130 | RGBA_Gfx_Pt_Func pfunc; | ||
131 | RGBA_Gfx_Func sfunc; | ||
132 | |||
133 | dstw = dst->cache_entry.w; | ||
134 | color = dc->col.col; | ||
135 | |||
136 | if (y0 > y1) | ||
137 | EXCHANGE_POINTS(x0, y0, x1, y1) | ||
138 | if (x0 > x1) | ||
139 | EXCHANGE_POINTS(x0, y0, x1, y1) | ||
140 | |||
141 | dx = x1 - x0; | ||
142 | dy = y1 - y0; | ||
143 | |||
144 | clx = dc->clip.x; | ||
145 | cly = dc->clip.y; | ||
146 | clw = dc->clip.w; | ||
147 | clh = dc->clip.h; | ||
148 | |||
149 | lx = clx; | ||
150 | rx = clx + clw - 1; | ||
151 | ty = cly; | ||
152 | by = cly + clh - 1; | ||
153 | |||
154 | if (dy == 0) | ||
155 | { | ||
156 | #ifdef EVAS_SLI | ||
157 | if (((y0) % dc->sli.h) == dc->sli.y) | ||
158 | #endif | ||
159 | { | ||
160 | if ((y0 >= ty) && (y0 <= by)) | ||
161 | { | ||
162 | if (dx < 0) | ||
163 | { | ||
164 | int tmp = x1; | ||
165 | |||
166 | x1 = x0; | ||
167 | x0 = tmp; | ||
168 | } | ||
169 | |||
170 | if (x0 < lx) x0 = lx; | ||
171 | if (x1 > rx) x1 = rx; | ||
172 | |||
173 | len = x1 - x0 + 1; | ||
174 | p = dst->image.data + (dstw * y0) + x0; | ||
175 | sfunc = evas_common_gfx_func_composite_color_span_get(color, dst, len, dc->render_op); | ||
176 | if (sfunc) | ||
177 | sfunc(NULL, NULL, color, p, len); | ||
178 | } | ||
179 | } | ||
180 | return; | ||
181 | } | ||
182 | |||
183 | pfunc = evas_common_gfx_func_composite_color_pt_get(color, dst, dc->render_op); | ||
184 | if (!pfunc) return; | ||
185 | |||
186 | if (dx == 0) | ||
187 | { | ||
188 | if ((x0 >= lx) && (x0 <= rx)) | ||
189 | { | ||
190 | if (y0 < ty) y0 = ty; | ||
191 | if (y1 > by) y1 = by; | ||
192 | |||
193 | len = y1 - y0 + 1; | ||
194 | p = dst->image.data + (dstw * y0) + x0; | ||
195 | while (len--) | ||
196 | { | ||
197 | #ifdef EVAS_SLI | ||
198 | if (((y1 + 1 - len) % dc->sli.h) == dc->sli.y) | ||
199 | #endif | ||
200 | { | ||
201 | pfunc(0, 255, color, p); | ||
202 | } | ||
203 | p += dstw; | ||
204 | } | ||
205 | } | ||
206 | return; | ||
207 | } | ||
208 | |||
209 | if ((dy == dx) || (dy == -dx)) | ||
210 | { | ||
211 | int p0_in, p1_in; | ||
212 | |||
213 | p0_in = (IN_RECT(x0, y0, clx, cly, clw, clh) ? 1 : 0); | ||
214 | p1_in = (IN_RECT(x1, y1, clx, cly, clw, clh) ? 1 : 0); | ||
215 | |||
216 | if (dy > 0) | ||
217 | { | ||
218 | if (!p0_in) | ||
219 | { | ||
220 | x0 = x0 + (ty - y0); | ||
221 | y0 = ty; | ||
222 | if (x0 > rx) return; | ||
223 | if (x0 < lx) | ||
224 | { | ||
225 | y0 = y0 + (lx - x0); | ||
226 | x0 = lx; | ||
227 | if ((y0 < ty) || (y0 > by)) return; | ||
228 | } | ||
229 | } | ||
230 | if (!p1_in) | ||
231 | { | ||
232 | x1 = x0 + (by - y0); | ||
233 | y1 = by; | ||
234 | if (x1 < lx) return; | ||
235 | if (x1 > rx) | ||
236 | { | ||
237 | y1 = y0 + (rx - x0); | ||
238 | x1 = rx; | ||
239 | if ((y1 < ty) || (y1 > by)) return; | ||
240 | } | ||
241 | } | ||
242 | } | ||
243 | else | ||
244 | { | ||
245 | if (!p0_in) | ||
246 | { | ||
247 | x0 = x0 - (by - y0); | ||
248 | y0 = by; | ||
249 | if (x0 > rx) return; | ||
250 | if (x0 < lx) | ||
251 | { | ||
252 | y0 = y0 - (lx - x0); | ||
253 | x0 = lx; | ||
254 | if ((y0 < ty) || (y0 > by)) return; | ||
255 | } | ||
256 | } | ||
257 | if (!p1_in) | ||
258 | { | ||
259 | x1 = x0 - (ty - y0); | ||
260 | y1 = ty; | ||
261 | if (x1 < lx) return; | ||
262 | if (x1 > rx) | ||
263 | { | ||
264 | y1 = y0 - (rx - x0); | ||
265 | x1 = rx; | ||
266 | if ((y1 < ty) || (y1 > by)) return; | ||
267 | } | ||
268 | } | ||
269 | } | ||
270 | if (y1 > y0) | ||
271 | { | ||
272 | p = dst->image.data + (dstw * y0) + x0; | ||
273 | len = y1 - y0 + 1; | ||
274 | if (dx > 0) dstw++; | ||
275 | else dstw--; | ||
276 | } | ||
277 | else | ||
278 | { | ||
279 | len = y0 - y1 + 1; | ||
280 | p = dst->image.data + (dstw * y1) + x1; | ||
281 | if (dx > 0) dstw--; | ||
282 | else dstw++; | ||
283 | } | ||
284 | |||
285 | while (len--) | ||
286 | { | ||
287 | #ifdef EVAS_SLI | ||
288 | if (((y1 + 1 - len) % dc->sli.h) == dc->sli.y) | ||
289 | #endif | ||
290 | { | ||
291 | pfunc(0, 255, color, p); | ||
292 | } | ||
293 | p += dstw; | ||
294 | } | ||
295 | } | ||
296 | } | ||
297 | |||
298 | |||
299 | #define SETUP_LINE_SHALLOW \ | ||
300 | if (x0 > x1) \ | ||
301 | { \ | ||
302 | EXCHANGE_POINTS(x0, y0, x1, y1); \ | ||
303 | dx = -dx; \ | ||
304 | dy = -dy; \ | ||
305 | } \ | ||
306 | \ | ||
307 | px = x0; \ | ||
308 | py = y0; \ | ||
309 | \ | ||
310 | p0_in = (IN_RANGE(x0 , y0 , clw, clh) ? 1 : 0); \ | ||
311 | p1_in = (IN_RANGE(x1 , y1 , clw, clh) ? 1 : 0); \ | ||
312 | \ | ||
313 | dely = 1; \ | ||
314 | dh = dstw; \ | ||
315 | if (dy < 0) \ | ||
316 | { \ | ||
317 | dely = -1; \ | ||
318 | dh = -dstw; \ | ||
319 | } \ | ||
320 | \ | ||
321 | dyy = ((dy) << 16) / (dx); \ | ||
322 | \ | ||
323 | if (!p0_in) \ | ||
324 | { \ | ||
325 | dxx = ((dx) << 16) / (dy); \ | ||
326 | if (px < 0) \ | ||
327 | { \ | ||
328 | x = -px; px = 0; \ | ||
329 | yy = x * dyy; \ | ||
330 | y = yy >> 16; \ | ||
331 | if (!a_a) \ | ||
332 | y += (yy - (y << 16)) >> 15; \ | ||
333 | py += y; \ | ||
334 | if ((dely > 0) && (py >= clh)) \ | ||
335 | return; \ | ||
336 | else if ((dely < 0) && (py < -1)) \ | ||
337 | return; \ | ||
338 | } \ | ||
339 | \ | ||
340 | y = 0; \ | ||
341 | if ((dely > 0) && (py < 0)) \ | ||
342 | y = (-1 - py); \ | ||
343 | else if ((dely < 0) && (py >= clh)) \ | ||
344 | y = (clh - 1 - py); \ | ||
345 | \ | ||
346 | xx = y * dxx; \ | ||
347 | x = xx >> 16; \ | ||
348 | if (!a_a) \ | ||
349 | x += (xx - (x << 16)) >> 15; \ | ||
350 | px += x; \ | ||
351 | if (px >= clw) return; \ | ||
352 | \ | ||
353 | yy = x * dyy; \ | ||
354 | y = yy >> 16; \ | ||
355 | if (!a_a) \ | ||
356 | y += (yy - (y << 16)) >> 15; \ | ||
357 | py += y; \ | ||
358 | if ((dely > 0) && (py >= clh)) \ | ||
359 | return; \ | ||
360 | else if ((dely < 0) && (py < -1)) \ | ||
361 | return; \ | ||
362 | } \ | ||
363 | \ | ||
364 | p = data + (dstw * py) + px; \ | ||
365 | \ | ||
366 | x = px - x0; \ | ||
367 | yy = x * dyy; \ | ||
368 | prev_y = (yy >> 16); \ | ||
369 | \ | ||
370 | rx = MIN(x1 + 1, clw); \ | ||
371 | by = clh - 1; | ||
372 | |||
373 | |||
374 | #define SETUP_LINE_STEEP \ | ||
375 | if (y0 > y1) \ | ||
376 | { \ | ||
377 | EXCHANGE_POINTS(x0, y0, x1, y1); \ | ||
378 | dx = -dx; \ | ||
379 | dy = -dy; \ | ||
380 | } \ | ||
381 | \ | ||
382 | px = x0; \ | ||
383 | py = y0; \ | ||
384 | \ | ||
385 | p0_in = (IN_RANGE(x0 , y0 , clw, clh) ? 1 : 0); \ | ||
386 | p1_in = (IN_RANGE(x1 , y1 , clw, clh) ? 1 : 0); \ | ||
387 | \ | ||
388 | delx = 1; \ | ||
389 | if (dx < 0) \ | ||
390 | delx = -1; \ | ||
391 | \ | ||
392 | dxx = ((dx) << 16) / (dy); \ | ||
393 | \ | ||
394 | if (!p0_in) \ | ||
395 | { \ | ||
396 | dyy = ((dy) << 16) / (dx); \ | ||
397 | \ | ||
398 | if (py < 0) \ | ||
399 | { \ | ||
400 | y = -py; py = 0; \ | ||
401 | xx = y * dxx; \ | ||
402 | x = xx >> 16; \ | ||
403 | if (!a_a) \ | ||
404 | x += (xx - (x << 16)) >> 15; \ | ||
405 | px += x; \ | ||
406 | if ((delx > 0) && (px >= clw)) \ | ||
407 | return; \ | ||
408 | else if ((delx < 0) && (px < -1)) \ | ||
409 | return; \ | ||
410 | } \ | ||
411 | \ | ||
412 | x = 0; \ | ||
413 | if ((delx > 0) && (px < -1)) \ | ||
414 | x = (-1 - px); \ | ||
415 | else if ((delx < 0) && (px >= clw)) \ | ||
416 | x = (clw - 1 - px); \ | ||
417 | \ | ||
418 | yy = x * dyy; \ | ||
419 | y = yy >> 16; \ | ||
420 | if (!a_a) \ | ||
421 | y += (yy - (y << 16)) >> 15; \ | ||
422 | py += y; \ | ||
423 | if (py >= clh) return; \ | ||
424 | \ | ||
425 | xx = y * dxx; \ | ||
426 | x = xx >> 16; \ | ||
427 | if (!a_a) \ | ||
428 | x += (xx - (x << 16)) >> 15; \ | ||
429 | px += x; \ | ||
430 | if ((delx > 0) && (px >= clw)) \ | ||
431 | return; \ | ||
432 | else if ((delx < 0) && (px < -1)) \ | ||
433 | return; \ | ||
434 | } \ | ||
435 | \ | ||
436 | p = data + (dstw * py) + px; \ | ||
437 | \ | ||
438 | y = py - y0; \ | ||
439 | xx = y * dxx; \ | ||
440 | prev_x = (xx >> 16); \ | ||
441 | \ | ||
442 | by = MIN(y1 + 1, clh); \ | ||
443 | rx = clw - 1; | ||
444 | |||
445 | static void | ||
446 | _evas_draw_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1, int y1) | ||
447 | { | ||
448 | int px, py, x, y, prev_x, prev_y; | ||
449 | int dx, dy, rx, by, p0_in, p1_in, dh, a_a = 0; | ||
450 | int delx, dely, xx, yy, dxx, dyy; | ||
451 | int clx, cly, clw, clh; | ||
452 | int dstw; | ||
453 | DATA32 *p, *data, color; | ||
454 | RGBA_Gfx_Pt_Func pfunc; | ||
455 | |||
456 | dx = x1 - x0; | ||
457 | dy = y1 - y0; | ||
458 | |||
459 | if ( (dx == 0) || (dy == 0) || (dx == dy) || (dx == -dy) ) | ||
460 | { | ||
461 | _evas_draw_simple_line(dst, dc, x0, y0, x1, y1); | ||
462 | return; | ||
463 | } | ||
464 | |||
465 | color = dc->col.col; | ||
466 | pfunc = evas_common_gfx_func_composite_color_pt_get(color, dst, dc->render_op); | ||
467 | if (!pfunc) return; | ||
468 | |||
469 | clx = dc->clip.x; | ||
470 | cly = dc->clip.y; | ||
471 | clw = dc->clip.w; | ||
472 | clh = dc->clip.h; | ||
473 | |||
474 | data = dst->image.data; | ||
475 | dstw = dst->cache_entry.w; | ||
476 | |||
477 | data += (dstw * cly) + clx; | ||
478 | x0 -= clx; | ||
479 | y0 -= cly; | ||
480 | x1 -= clx; | ||
481 | y1 -= cly; | ||
482 | |||
483 | /* shallow: x-parametric */ | ||
484 | if ((dy < dx) || (dy < -dx)) | ||
485 | { | ||
486 | SETUP_LINE_SHALLOW; | ||
487 | |||
488 | while (px < rx) | ||
489 | { | ||
490 | y = (yy >> 16); | ||
491 | y += ((yy - (y << 16)) >> 15); | ||
492 | if (prev_y != y) | ||
493 | { | ||
494 | prev_y = y; | ||
495 | p += dh; | ||
496 | py += dely; | ||
497 | } | ||
498 | if (!p1_in) | ||
499 | { | ||
500 | if ((py < 0) && (dely < 0)) return; | ||
501 | if ((py > by) && (dely > 0)) return; | ||
502 | } | ||
503 | if (!p0_in) | ||
504 | { | ||
505 | if (py < 0) goto next_x; | ||
506 | } | ||
507 | #ifdef EVAS_SLI | ||
508 | if (((py) % dc->sli.h) == dc->sli.y) | ||
509 | #endif | ||
510 | { | ||
511 | if (IN_RANGE(px, py, clw, clh)) | ||
512 | pfunc(0, 255, color, p); | ||
513 | } | ||
514 | next_x: | ||
515 | yy += dyy; | ||
516 | px++; | ||
517 | p++; | ||
518 | } | ||
519 | return; | ||
520 | } | ||
521 | |||
522 | /* steep: y-parametric */ | ||
523 | |||
524 | SETUP_LINE_STEEP; | ||
525 | |||
526 | while (py < by) | ||
527 | { | ||
528 | x = (xx >> 16); | ||
529 | x += ((xx - (x << 16)) >> 15); | ||
530 | if (prev_x != x) | ||
531 | { | ||
532 | prev_x = x; | ||
533 | px += delx; | ||
534 | p += delx; | ||
535 | } | ||
536 | if (!p1_in) | ||
537 | { | ||
538 | if ((px < 0) && (delx < 0)) return; | ||
539 | if ((px > rx) && (delx > 0)) return; | ||
540 | } | ||
541 | if (!p0_in) | ||
542 | { | ||
543 | if (px < 0) goto next_y; | ||
544 | } | ||
545 | #ifdef EVAS_SLI | ||
546 | if (((py) % dc->sli.h) == dc->sli.y) | ||
547 | #endif | ||
548 | { | ||
549 | if (IN_RANGE(px, py, clw, clh)) | ||
550 | pfunc(0, 255, color, p); | ||
551 | } | ||
552 | next_y: | ||
553 | xx += dxx; | ||
554 | py++; | ||
555 | p += dstw; | ||
556 | } | ||
557 | } | ||
558 | |||
559 | |||
560 | static void | ||
561 | _evas_draw_line_aa(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1, int y1) | ||
562 | { | ||
563 | int px, py, x, y, prev_x, prev_y; | ||
564 | int dx, dy, rx, by, p0_in, p1_in, dh, a_a = 1; | ||
565 | int delx, dely, xx, yy, dxx, dyy; | ||
566 | int clx, cly, clw, clh; | ||
567 | int dstw; | ||
568 | DATA32 *p, *data, color; | ||
569 | RGBA_Gfx_Pt_Func pfunc; | ||
570 | |||
571 | if (y0 > y1) | ||
572 | EXCHANGE_POINTS(x0, y0, x1, y1); | ||
573 | dx = x1 - x0; | ||
574 | dy = y1 - y0; | ||
575 | |||
576 | if ( (dx == 0) || (dy == 0) || (dx == dy) || (dx == -dy) ) | ||
577 | { | ||
578 | _evas_draw_simple_line(dst, dc, x0, y0, x1, y1); | ||
579 | return; | ||
580 | } | ||
581 | |||
582 | color = dc->col.col; | ||
583 | pfunc = evas_common_gfx_func_composite_mask_color_pt_get(color, dst, dc->render_op); | ||
584 | if (!pfunc) return; | ||
585 | |||
586 | clx = dc->clip.x; | ||
587 | cly = dc->clip.y; | ||
588 | clw = dc->clip.w; | ||
589 | clh = dc->clip.h; | ||
590 | |||
591 | data = evas_cache_image_pixels(&dst->cache_entry); | ||
592 | dstw = dst->cache_entry.w; | ||
593 | |||
594 | data += (dstw * cly) + clx; | ||
595 | x0 -= clx; | ||
596 | y0 -= cly; | ||
597 | x1 -= clx; | ||
598 | y1 -= cly; | ||
599 | |||
600 | /* shallow: x-parametric */ | ||
601 | if ((dy < dx) || (dy < -dx)) | ||
602 | { | ||
603 | SETUP_LINE_SHALLOW; | ||
604 | |||
605 | while (px < rx) | ||
606 | { | ||
607 | DATA8 aa; | ||
608 | |||
609 | y = (yy >> 16); | ||
610 | if (prev_y != y) | ||
611 | { | ||
612 | prev_y = y; | ||
613 | p += dh; | ||
614 | py += dely; | ||
615 | } | ||
616 | if (!p1_in) | ||
617 | { | ||
618 | if ((py < 0) && (dely < 0)) return; | ||
619 | if ((py > by) && (dely > 0)) return; | ||
620 | } | ||
621 | if (!p0_in) | ||
622 | { | ||
623 | if (py < 0) goto next_x; | ||
624 | } | ||
625 | if (px < clw) | ||
626 | { | ||
627 | aa = ((yy - (y << 16)) >> 8); | ||
628 | if ((py) < clh) | ||
629 | pfunc(0, 255 - aa, color, p); | ||
630 | if ((py + 1) < clh) | ||
631 | pfunc(0, aa, color, p + dstw); | ||
632 | } | ||
633 | |||
634 | next_x: | ||
635 | yy += dyy; | ||
636 | px++; | ||
637 | p++; | ||
638 | } | ||
639 | return; | ||
640 | } | ||
641 | |||
642 | /* steep: y-parametric */ | ||
643 | SETUP_LINE_STEEP; | ||
644 | |||
645 | while (py < by) | ||
646 | { | ||
647 | DATA8 aa; | ||
648 | |||
649 | x = (xx >> 16); | ||
650 | if (prev_x != x) | ||
651 | { | ||
652 | prev_x = x; | ||
653 | px += delx; | ||
654 | p += delx; | ||
655 | } | ||
656 | if (!p1_in) | ||
657 | { | ||
658 | if ((px < 0) && (delx < 0)) return; | ||
659 | if ((px > rx) && (delx > 0)) return; | ||
660 | } | ||
661 | if (!p0_in) | ||
662 | { | ||
663 | if (px < 0) goto next_y; | ||
664 | } | ||
665 | if (py < clh) | ||
666 | { | ||
667 | aa = ((xx - (x << 16)) >> 8); | ||
668 | if ((px) < clw) | ||
669 | pfunc(0, 255 - aa, color, p); | ||
670 | if ((px + 1) < clw) | ||
671 | pfunc(0, aa, color, p + 1); | ||
672 | } | ||
673 | next_y: | ||
674 | xx += dxx; | ||
675 | py++; | ||
676 | p += dstw; | ||
677 | } | ||
678 | } | ||