summaryrefslogtreecommitdiff
path: root/src/lib/evas/common/evas_line_main.c
diff options
context:
space:
mode:
authorLeandro Pereira <leandro@profusion.mobi>2012-12-17 21:28:08 +0000
committerLeandro Pereira <leandro@profusion.mobi>2012-12-17 21:28:08 +0000
commit52104d26c81dde82bd9d99248d2ce743000d8388 (patch)
tree64b7e83b787e7830636aa61be052b7c742f479a9 /src/lib/evas/common/evas_line_main.c
parentbfe46f54ff449760b5270b7300d591aa09b0fddc (diff)
evas/common: Prepare soil to land line drawing code for threaded render
SVN revision: 81185
Diffstat (limited to 'src/lib/evas/common/evas_line_main.c')
-rw-r--r--src/lib/evas/common/evas_line_main.c718
1 files changed, 628 insertions, 90 deletions
diff --git a/src/lib/evas/common/evas_line_main.c b/src/lib/evas/common/evas_line_main.c
index baea395d5d..1985b469c0 100644
--- a/src/lib/evas/common/evas_line_main.c
+++ b/src/lib/evas/common/evas_line_main.c
@@ -1,20 +1,6 @@
1#include "evas_common.h" 1#include "evas_common.h"
2#include "evas_blend_private.h" 2#include "evas_blend_private.h"
3 3
4
5static void
6_evas_draw_point(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y);
7
8static void
9_evas_draw_simple_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1, int y1);
10
11static void
12_evas_draw_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1, int y1);
13
14static 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) \ 4#define IN_RANGE(x, y, w, h) \
19 ( x > 0 && y > 0 &&((unsigned)(x) < (unsigned)(w)) && ((unsigned)(y) < (unsigned)(h)) ) 5 ( x > 0 && y > 0 &&((unsigned)(x) < (unsigned)(w)) && ((unsigned)(y) < (unsigned)(h)) )
20 6
@@ -34,79 +20,11 @@ _evas_draw_line_aa(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x
34 x1 = _tmp; \ 20 x1 = _tmp; \
35 } 21 }
36 22
37
38EAPI void 23EAPI void
39evas_common_line_init(void) 24evas_common_line_init(void)
40{ 25{
41} 26}
42 27
43EAPI void
44evas_common_line_draw_cb(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1, int y1, Evas_Common_Line_Draw_Cb cb)
45{
46 int x, y, w, h;
47 int clx, cly, clw, clh;
48 int cuse, cx, cy, cw, ch;
49
50 /* No cutout ? FIXME ? */
51
52 if ((x0 == x1) && (y0 == y1))
53 {
54 _evas_draw_point(dst, dc, x0, y0);
55 return;
56 }
57
58 clx = cly = 0;
59 clw = dst->cache_entry.w;
60 clh = dst->cache_entry.h;
61
62 /* save out clip info */
63 cuse = dc->clip.use;
64 cx = dc->clip.x;
65 cy = dc->clip.y;
66 cw = dc->clip.w;
67 ch = dc->clip.h;
68
69 if (cuse)
70 {
71 RECTS_CLIP_TO_RECT(clx, cly, clw, clh, cx, cy, cw, ch);
72 if ((clw < 1) || (clh < 1))
73 return;
74 }
75
76 x = MIN(x0, x1);
77 y = MIN(y0, y1);
78 w = MAX(x0, x1) - x + 1;
79 h = MAX(y0, y1) - y + 1;
80
81 RECTS_CLIP_TO_RECT(clx, cly, clw, clh, x, y, w, h);
82 if ((clw < 1) || (clh < 1))
83 return;
84
85 dc->clip.use = 1;
86 dc->clip.x = clx;
87 dc->clip.y = cly;
88 dc->clip.w = clw;
89 dc->clip.h = clh;
90
91 cb(dst, dc, x0, y0, x1, y1);
92
93 /* restore clip info */
94 dc->clip.use = cuse;
95 dc->clip.x = cx;
96 dc->clip.y = cy;
97 dc->clip.w = cw;
98 dc->clip.h = ch;
99}
100
101EAPI void
102evas_common_line_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1, int y1)
103{
104 Evas_Common_Line_Draw_Cb cb;
105
106 cb = dc->anti_alias ? _evas_draw_line_aa : _evas_draw_line;
107 evas_common_line_draw_cb(dst, dc, x0, y0, x1, y1, cb);
108}
109
110static void 28static void
111_evas_draw_point(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y) 29_evas_draw_point(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y)
112{ 30{
@@ -136,6 +54,25 @@ _evas_draw_point(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y)
136 } 54 }
137} 55}
138 56
57EAPI void
58evas_common_line_point_draw(RGBA_Image *dst, int clip_x, int clip_y, int clip_w, int clip_h, DATA32 color, int render_op, int x, int y)
59{
60 Eina_Bool no_cuse;
61 RGBA_Gfx_Pt_Func pfunc;
62
63 no_cuse = ((clip_x == 0) && (clip_y == 0) &&
64 ((clip_w == (int)dst->cache_entry.w) &&
65 (clip_h == (int)dst->cache_entry.h)));
66
67 if (!IN_RANGE(x, y, dst->cache_entry.w, dst->cache_entry.h)) return;
68 if ((!no_cuse) && (!IN_RECT(x, y, clip_x, clip_y, clip_w, clip_h)))
69 return;
70
71 pfunc = evas_common_gfx_func_composite_color_pt_get(color, dst, render_op);
72 if (pfunc)
73 pfunc(0, 255, color, dst->image.data + (dst->cache_entry.w * y) + x);
74}
75
139/* 76/*
140 these functions use the dc->clip data as bounding 77 these functions use the dc->clip data as bounding
141 data. they assume that such data has already been cut 78 data. they assume that such data has already been cut
@@ -503,6 +440,415 @@ _evas_draw_simple_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, i
503 rx = clw - 1; 440 rx = clw - 1;
504 441
505static void 442static void
443_draw_render_thread_simple_line(RGBA_Image *dst, int clip_x, int clip_y, int clip_w, int clip_h, DATA32 color, int render_op, int x0, int y0, int x1, int y1)
444{
445 int dx, dy, len, lx, ty, rx, by;
446 int clx, cly, clw, clh;
447 int dstw;
448 DATA32 *p;
449 RGBA_Gfx_Pt_Func pfunc;
450 RGBA_Gfx_Func sfunc;
451
452 dstw = dst->cache_entry.w;
453
454 if (y0 > y1)
455 EXCHANGE_POINTS(x0, y0, x1, y1)
456 if (x0 > x1)
457 EXCHANGE_POINTS(x0, y0, x1, y1)
458
459 dx = x1 - x0;
460 dy = y1 - y0;
461
462 clx = clip_x;
463 cly = clip_y;
464 clw = clip_w;
465 clh = clip_h;
466
467 lx = clx;
468 rx = clx + clw - 1;
469 ty = cly;
470 by = cly + clh - 1;
471
472 if (dy == 0)
473 {
474 if ((y0 >= ty) && (y0 <= by))
475 {
476 if (dx < 0)
477 {
478 int tmp = x1;
479
480 x1 = x0;
481 x0 = tmp;
482 }
483
484 if (x0 < lx) x0 = lx;
485 if (x1 > rx) x1 = rx;
486
487 len = x1 - x0 + 1;
488 p = dst->image.data + (dstw * y0) + x0;
489 sfunc = evas_common_gfx_func_composite_color_span_get(color, dst, len, render_op);
490 if (sfunc) sfunc(NULL, NULL, color, p, len);
491 }
492 return;
493 }
494
495 pfunc = evas_common_gfx_func_composite_color_pt_get(color, dst, render_op);
496 if (!pfunc) return;
497
498 if (dx == 0)
499 {
500 if ((x0 >= lx) && (x0 <= rx))
501 {
502 if (y0 < ty) y0 = ty;
503 if (y1 > by) y1 = by;
504
505 len = y1 - y0 + 1;
506 p = dst->image.data + (dstw * y0) + x0;
507 while (len--)
508 {
509 pfunc(0, 255, color, p);
510 p += dstw;
511 }
512 }
513 return;
514 }
515
516 if ((dy == dx) || (dy == -dx))
517 {
518 int p0_in, p1_in;
519
520 p0_in = (IN_RECT(x0, y0, clx, cly, clw, clh) ? 1 : 0);
521 p1_in = (IN_RECT(x1, y1, clx, cly, clw, clh) ? 1 : 0);
522
523 if (dy > 0)
524 {
525 if (!p0_in)
526 {
527 x0 = x0 + (ty - y0);
528 y0 = ty;
529 if (x0 > rx) return;
530 if (x0 < lx)
531 {
532 y0 = y0 + (lx - x0);
533 x0 = lx;
534 if ((y0 < ty) || (y0 > by)) return;
535 }
536 }
537 if (!p1_in)
538 {
539 x1 = x0 + (by - y0);
540 y1 = by;
541 if (x1 < lx) return;
542 if (x1 > rx)
543 {
544 y1 = y0 + (rx - x0);
545 x1 = rx;
546 if ((y1 < ty) || (y1 > by)) return;
547 }
548 }
549 }
550 else
551 {
552 if (!p0_in)
553 {
554 x0 = x0 - (by - y0);
555 y0 = by;
556 if (x0 > rx) return;
557 if (x0 < lx)
558 {
559 y0 = y0 - (lx - x0);
560 x0 = lx;
561 if ((y0 < ty) || (y0 > by)) return;
562 }
563 }
564 if (!p1_in)
565 {
566 x1 = x0 - (ty - y0);
567 y1 = ty;
568 if (x1 < lx) return;
569 if (x1 > rx)
570 {
571 y1 = y0 - (rx - x0);
572 x1 = rx;
573 if ((y1 < ty) || (y1 > by)) return;
574 }
575 }
576 }
577 if (y1 > y0)
578 {
579 p = dst->image.data + (dstw * y0) + x0;
580 len = y1 - y0 + 1;
581 if (dx > 0) dstw++;
582 else dstw--;
583 }
584 else
585 {
586 len = y0 - y1 + 1;
587 p = dst->image.data + (dstw * y1) + x1;
588 if (dx > 0) dstw--;
589 else dstw++;
590 }
591 while (len--)
592 {
593 pfunc(0, 255, color, p);
594 p += dstw;
595 }
596 }
597}
598
599#define SETUP_LINE_SHALLOW \
600 if (x0 > x1) \
601 { \
602 EXCHANGE_POINTS(x0, y0, x1, y1); \
603 dx = -dx; \
604 dy = -dy; \
605 } \
606 \
607 px = x0; \
608 py = y0; \
609 \
610 p0_in = (IN_RANGE(x0 , y0 , clw, clh) ? 1 : 0); \
611 p1_in = (IN_RANGE(x1 , y1 , clw, clh) ? 1 : 0); \
612 \
613 dely = 1; \
614 dh = dstw; \
615 if (dy < 0) \
616 { \
617 dely = -1; \
618 dh = -dstw; \
619 } \
620 \
621 dyy = ((dy) << 16) / (dx); \
622 \
623 if (!p0_in) \
624 { \
625 dxx = ((dx) << 16) / (dy); \
626 if (px < 0) \
627 { \
628 x = -px; px = 0; \
629 yy = x * dyy; \
630 y = yy >> 16; \
631 if (!a_a) \
632 y += (yy - (y << 16)) >> 15; \
633 py += y; \
634 if ((dely > 0) && (py >= clh)) \
635 return; \
636 else if ((dely < 0) && (py < -1)) \
637 return; \
638 } \
639 \
640 y = 0; \
641 if ((dely > 0) && (py < 0)) \
642 y = (-1 - py); \
643 else if ((dely < 0) && (py >= clh)) \
644 y = (clh - 1 - py); \
645 \
646 xx = y * dxx; \
647 x = xx >> 16; \
648 if (!a_a) \
649 x += (xx - (x << 16)) >> 15; \
650 px += x; \
651 if (px >= clw) return; \
652 \
653 yy = x * dyy; \
654 y = yy >> 16; \
655 if (!a_a) \
656 y += (yy - (y << 16)) >> 15; \
657 py += y; \
658 if ((dely > 0) && (py >= clh)) \
659 return; \
660 else if ((dely < 0) && (py < -1)) \
661 return; \
662 } \
663 \
664 p = data + (dstw * py) + px; \
665 \
666 x = px - x0; \
667 yy = x * dyy; \
668 prev_y = (yy >> 16); \
669 \
670 rx = MIN(x1 + 1, clw); \
671 by = clh - 1;
672
673
674#define SETUP_LINE_STEEP \
675 if (y0 > y1) \
676 { \
677 EXCHANGE_POINTS(x0, y0, x1, y1); \
678 dx = -dx; \
679 dy = -dy; \
680 } \
681 \
682 px = x0; \
683 py = y0; \
684 \
685 p0_in = (IN_RANGE(x0 , y0 , clw, clh) ? 1 : 0); \
686 p1_in = (IN_RANGE(x1 , y1 , clw, clh) ? 1 : 0); \
687 \
688 delx = 1; \
689 if (dx < 0) \
690 delx = -1; \
691 \
692 dxx = ((dx) << 16) / (dy); \
693 \
694 if (!p0_in) \
695 { \
696 dyy = ((dy) << 16) / (dx); \
697 \
698 if (py < 0) \
699 { \
700 y = -py; py = 0; \
701 xx = y * dxx; \
702 x = xx >> 16; \
703 if (!a_a) \
704 x += (xx - (x << 16)) >> 15; \
705 px += x; \
706 if ((delx > 0) && (px >= clw)) \
707 return; \
708 else if ((delx < 0) && (px < -1)) \
709 return; \
710 } \
711 \
712 x = 0; \
713 if ((delx > 0) && (px < -1)) \
714 x = (-1 - px); \
715 else if ((delx < 0) && (px >= clw)) \
716 x = (clw - 1 - px); \
717 \
718 yy = x * dyy; \
719 y = yy >> 16; \
720 if (!a_a) \
721 y += (yy - (y << 16)) >> 15; \
722 py += y; \
723 if (py >= clh) return; \
724 \
725 xx = y * dxx; \
726 x = xx >> 16; \
727 if (!a_a) \
728 x += (xx - (x << 16)) >> 15; \
729 px += x; \
730 if ((delx > 0) && (px >= clw)) \
731 return; \
732 else if ((delx < 0) && (px < -1)) \
733 return; \
734 } \
735 \
736 p = data + (dstw * py) + px; \
737 \
738 y = py - y0; \
739 xx = y * dxx; \
740 prev_x = (xx >> 16); \
741 \
742 by = MIN(y1 + 1, clh); \
743 rx = clw - 1;
744
745EAPI void
746evas_common_line_draw_line(RGBA_Image *dst, int clip_x, int clip_y, int clip_w, int clip_h, DATA32 color, int render_op, int x0, int y0, int x1, int y1)
747{
748 int px, py, x, y, prev_x, prev_y;
749 int dx, dy, rx, by, p0_in, p1_in, dh, a_a = 0;
750 int delx, dely, xx, yy, dxx, dyy;
751 int clx, cly, clw, clh;
752 int dstw;
753 DATA32 *p, *data;
754 RGBA_Gfx_Pt_Func pfunc;
755
756 dx = x1 - x0;
757 dy = y1 - y0;
758
759 if ( (dx == 0) || (dy == 0) || (dx == dy) || (dx == -dy) )
760 {
761 _draw_render_thread_simple_line
762 (dst, clip_x, clip_y, clip_w, clip_h,
763 color, render_op,
764 x0, y0, x1, y1);
765 return;
766 }
767
768 pfunc = evas_common_gfx_func_composite_color_pt_get(color, dst, render_op);
769 if (!pfunc) return;
770
771 clx = clip_x;
772 cly = clip_y;
773 clw = clip_w;
774 clh = clip_h;
775
776 data = dst->image.data;
777 dstw = dst->cache_entry.w;
778
779 data += (dstw * cly) + clx;
780 x0 -= clx;
781 y0 -= cly;
782 x1 -= clx;
783 y1 -= cly;
784
785 /* shallow: x-parametric */
786 if ((dy < dx) || (dy < -dx))
787 {
788 SETUP_LINE_SHALLOW;
789
790 while (px < rx)
791 {
792 y = (yy >> 16);
793 y += ((yy - (y << 16)) >> 15);
794 if (prev_y != y)
795 {
796 prev_y = y;
797 p += dh;
798 py += dely;
799 }
800 if (!p1_in)
801 {
802 if ((py < 0) && (dely < 0)) return;
803 if ((py > by) && (dely > 0)) return;
804 }
805 if (!p0_in)
806 {
807 if (py < 0) goto next_x;
808 }
809 if (IN_RANGE(px, py, clw, clh)) pfunc(0, 255, color, p);
810
811next_x:
812 yy += dyy;
813 px++;
814 p++;
815 }
816 return;
817 }
818
819 /* steep: y-parametric */
820
821 SETUP_LINE_STEEP;
822
823 while (py < by)
824 {
825 x = (xx >> 16);
826 x += ((xx - (x << 16)) >> 15);
827 if (prev_x != x)
828 {
829 prev_x = x;
830 px += delx;
831 p += delx;
832 }
833 if (!p1_in)
834 {
835 if ((px < 0) && (delx < 0)) return;
836 if ((px > rx) && (delx > 0)) return;
837 }
838 if (!p0_in)
839 {
840 if (px < 0) goto next_y;
841 }
842 if (IN_RANGE(px, py, clw, clh)) pfunc(0, 255, color, p);
843
844next_y:
845 xx += dxx;
846 py++;
847 p += dstw;
848 }
849}
850
851static void
506_evas_draw_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1, int y1) 852_evas_draw_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1, int y1)
507{ 853{
508 int px, py, x, y, prev_x, prev_y; 854 int px, py, x, y, prev_x, prev_y;
@@ -517,23 +863,23 @@ _evas_draw_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1,
517 dy = y1 - y0; 863 dy = y1 - y0;
518 864
519#ifdef HAVE_PIXMAN 865#ifdef HAVE_PIXMAN
520# ifdef PIXMAN_LINE 866# ifdef PIXMAN_LINE
521 int pix_x; 867 int pix_x;
522 int pix_y; 868 int pix_y;
523 int pix_x_unit; 869 int pix_x_unit;
524 int pix_y_unit; 870 int pix_y_unit;
525 871
526 pixman_op_t op = PIXMAN_OP_SRC; // _EVAS_RENDER_COPY 872 pixman_op_t op = PIXMAN_OP_SRC; // _EVAS_RENDER_COPY
527 if (dc->render_op == _EVAS_RENDER_BLEND) 873 if (dc->render_op == _EVAS_RENDER_BLEND)
528 op = PIXMAN_OP_OVER; 874 op = PIXMAN_OP_OVER;
529 pix_x = x0; 875 pix_x = x0;
530 pix_y = y0; 876 pix_y = y0;
531 877
532 if (dx < 0) 878 if (dx < 0)
533 pix_x_unit = -1; 879 pix_x_unit = -1;
534 else 880 else
535 pix_x_unit = 1; 881 pix_x_unit = 1;
536 882
537 if (dy < 0) 883 if (dy < 0)
538 pix_y_unit = -1; 884 pix_y_unit = -1;
539 else 885 else
@@ -580,7 +926,7 @@ _evas_draw_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1,
580 p += dh; 926 p += dh;
581 py += dely; 927 py += dely;
582#ifdef HAVE_PIXMAN 928#ifdef HAVE_PIXMAN
583# ifdef PIXMAN_LINE 929# ifdef PIXMAN_LINE
584 pix_y += pix_y_unit; 930 pix_y += pix_y_unit;
585# endif 931# endif
586#endif 932#endif
@@ -597,14 +943,14 @@ _evas_draw_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1,
597 if (IN_RANGE(px, py, clw, clh)) 943 if (IN_RANGE(px, py, clw, clh))
598 { 944 {
599#ifdef HAVE_PIXMAN 945#ifdef HAVE_PIXMAN
600# ifdef PIXMAN_LINE 946# ifdef PIXMAN_LINE
601 if ((dst->pixman.im) && (dc->col.pixman_color_image)) 947 if ((dst->pixman.im) && (dc->col.pixman_color_image))
602 pixman_image_composite(op, dc->col.pixman_color_image, 948 pixman_image_composite(op, dc->col.pixman_color_image,
603 NULL, dst->pixman.im, 949 NULL, dst->pixman.im,
604 pix_x, pix_y, 0, 0, 950 pix_x, pix_y, 0, 0,
605 pix_x, pix_y, 1, 1); 951 pix_x, pix_y, 1, 1);
606 else 952 else
607# endif 953# endif
608#endif 954#endif
609 pfunc(0, 255, color, p); 955 pfunc(0, 255, color, p);
610 } 956 }
@@ -614,7 +960,7 @@ next_x:
614 px++; 960 px++;
615 p++; 961 p++;
616#ifdef HAVE_PIXMAN 962#ifdef HAVE_PIXMAN
617# ifdef PIXMAN_LINE 963# ifdef PIXMAN_LINE
618 pix_x += pix_x_unit; 964 pix_x += pix_x_unit;
619# endif 965# endif
620#endif 966#endif
@@ -676,6 +1022,129 @@ next_y:
676 } 1022 }
677} 1023}
678 1024
1025EAPI void
1026evas_common_line_draw_line_aa(RGBA_Image *dst, int clip_x, int clip_y, int clip_w, int clip_h, DATA32 color, int render_op, int x0, int y0, int x1, int y1)
1027{
1028 int px, py, x, y, prev_x, prev_y;
1029 int dx, dy, rx, by, p0_in, p1_in, dh, a_a = 1;
1030 int delx, dely, xx, yy, dxx, dyy;
1031 int clx, cly, clw, clh;
1032 int dstw;
1033 DATA32 *p, *data;
1034 RGBA_Gfx_Pt_Func pfunc;
1035
1036 dx = x1 - x0;
1037 dy = y1 - y0;
1038
1039 if (y0 > y1)
1040 EXCHANGE_POINTS(x0, y0, x1, y1);
1041
1042 dx = x1 - x0;
1043 dy = y1 - y0;
1044
1045 if ((dx == 0) || (dy == 0) || (dx == dy) || (dx == -dy))
1046 {
1047 _draw_render_thread_simple_line
1048 (dst, clip_x, clip_y, clip_w, clip_h,
1049 color, render_op,
1050 x0, y0, x1, y1);
1051 return;
1052 }
1053
1054 pfunc = evas_common_gfx_func_composite_mask_color_pt_get(color, dst, render_op);
1055 if (!pfunc) return;
1056
1057 clx = clip_x;
1058 cly = clip_y;
1059 clw = clip_w;
1060 clh = clip_h;
1061
1062 data = evas_cache_image_pixels(&dst->cache_entry);
1063 dstw = dst->cache_entry.w;
1064
1065 data += (dstw * cly) + clx;
1066 x0 -= clx;
1067 y0 -= cly;
1068 x1 -= clx;
1069 y1 -= cly;
1070
1071 /* shallow: x-parametric */
1072 if ((dy < dx) || (dy < -dx))
1073 {
1074 SETUP_LINE_SHALLOW;
1075
1076 while (px < rx)
1077 {
1078 DATA8 aa;
1079
1080 y = (yy >> 16);
1081 if (prev_y != y)
1082 {
1083 prev_y = y;
1084 p += dh;
1085 py += dely;
1086 }
1087 if (!p1_in)
1088 {
1089 if ((py < 0) && (dely < 0)) return;
1090 if ((py > by) && (dely > 0)) return;
1091 }
1092 if (!p0_in)
1093 {
1094 if (py < 0) goto next_x;
1095 }
1096 if (px < clw)
1097 {
1098 aa = ((yy - (y << 16)) >> 8);
1099
1100 if ((py) < clh) pfunc(0, 255 - aa, color, p);
1101 if ((py + 1) < clh) pfunc(0, aa, color, p + dstw);
1102 }
1103
1104next_x:
1105 yy += dyy;
1106 px++;
1107 p++;
1108 }
1109 return;
1110 }
1111
1112 /* steep: y-parametric */
1113 SETUP_LINE_STEEP;
1114
1115 while (py < by)
1116 {
1117 DATA8 aa;
1118
1119 x = (xx >> 16);
1120 if (prev_x != x)
1121 {
1122 prev_x = x;
1123 px += delx;
1124 p += delx;
1125 }
1126 if (!p1_in)
1127 {
1128 if ((px < 0) && (delx < 0)) return;
1129 if ((px > rx) && (delx > 0)) return;
1130 }
1131 if (!p0_in)
1132 {
1133 if (px < 0) goto next_y;
1134 }
1135 if (py < clh)
1136 {
1137 aa = ((xx - (x << 16)) >> 8);
1138 if ((px) < clw) pfunc(0, 255 - aa, color, p);
1139 if ((px + 1) < clw) pfunc(0, aa, color, p + 1);
1140 }
1141
1142 next_y:
1143 xx += dxx;
1144 py++;
1145 p += dstw;
1146 }
1147}
679 1148
680static void 1149static void
681_evas_draw_line_aa(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1, int y1) 1150_evas_draw_line_aa(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1, int y1)
@@ -935,3 +1404,72 @@ next_x:
935#endif 1404#endif
936 } 1405 }
937} 1406}
1407
1408EAPI void
1409evas_common_line_draw_cb(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1, int y1, Evas_Common_Line_Draw_Cb cb)
1410{
1411 int x, y, w, h;
1412 int clx, cly, clw, clh;
1413 int cuse, cx, cy, cw, ch;
1414
1415 /* No cutout ? FIXME ? */
1416
1417 if ((x0 == x1) && (y0 == y1))
1418 {
1419 _evas_draw_point(dst, dc, x0, y0);
1420 return;
1421 }
1422
1423 clx = cly = 0;
1424 clw = dst->cache_entry.w;
1425 clh = dst->cache_entry.h;
1426
1427 /* save out clip info */
1428 cuse = dc->clip.use;
1429 cx = dc->clip.x;
1430 cy = dc->clip.y;
1431 cw = dc->clip.w;
1432 ch = dc->clip.h;
1433
1434 if (cuse)
1435 {
1436 RECTS_CLIP_TO_RECT(clx, cly, clw, clh, cx, cy, cw, ch);
1437 if ((clw < 1) || (clh < 1))
1438 return;
1439 }
1440
1441 x = MIN(x0, x1);
1442 y = MIN(y0, y1);
1443 w = MAX(x0, x1) - x + 1;
1444 h = MAX(y0, y1) - y + 1;
1445
1446 RECTS_CLIP_TO_RECT(clx, cly, clw, clh, x, y, w, h);
1447 if ((clw < 1) || (clh < 1))
1448 return;
1449
1450 dc->clip.use = 1;
1451 dc->clip.x = clx;
1452 dc->clip.y = cly;
1453 dc->clip.w = clw;
1454 dc->clip.h = clh;
1455
1456 cb(dst, dc, x0, y0, x1, y1);
1457
1458 /* restore clip info */
1459 dc->clip.use = cuse;
1460 dc->clip.x = cx;
1461 dc->clip.y = cy;
1462 dc->clip.w = cw;
1463 dc->clip.h = ch;
1464}
1465
1466EAPI void
1467evas_common_line_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1, int y1)
1468{
1469 Evas_Common_Line_Draw_Cb cb;
1470
1471 if (dc->anti_alias) cb = _evas_draw_line_aa;
1472 else cb = _evas_draw_line;
1473
1474 evas_common_line_draw_cb(dst, dc, x0, y0, x1, y1, cb);
1475}