File: GENERIC_DrawLineAA.inc

package info (click to toggle)
libtuxcap 1.4.0.dfsg2-2.1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,176 kB
  • sloc: cpp: 43,203; ansic: 3,095; python: 774; objc: 242; makefile: 100; xml: 87
file content (108 lines) | stat: -rw-r--r-- 2,776 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
{
        if (!(dx == 0 || dy == 0)) {
	PIXEL_TYPE* aDestPixels = &aBits[aY0*STRIDE + aX0];
	uint32_t anErrAcc = 0x10000 - (uint32_t)((1.0f - fabsf(theStartX - aX0))*(1.0f - fabsf(theStartY - aY0)) * 0x10000);
	if (dx >= dy) // mostly horizontal
	{ 
		//uint32_t anErrAdj = (((uint32_t)dy << 16) / (uint32_t)dx);
		uint32_t anErrAdj = (uint32_t)(dyd / dxd * 0x10000);

		uchar aWeight = 255 - (uchar)(anErrAcc >> 8);
		uchar aWeight2 = (aWeight ^ 0xFF);

		int a = CALC_WEIGHT_A(aWeight);
		PIXEL_TYPE dest = *aDestPixels;
                if (a != 0) {
		    int oma = 256 - a;
		    BLEND_PIXEL(aDestPixels);
                }
		while (--dx)
		{
			anErrAcc += anErrAdj;
			if (anErrAcc >= 0x10000)
			{
				anErrAcc &= 0xFFFF;
				aDestPixels += STRIDE;
				aY0++;
			}
			aDestPixels += aXinc;

			uchar aWeight = 255 - (uchar)(anErrAcc >> 8);
			uchar aWeight2 = (aWeight ^ 0xFF);

			dest = *aDestPixels;
			a = CALC_WEIGHT_A(aWeight);
                        if (a != 0) {
			    int oma = 256 - a;
			    BLEND_PIXEL(aDestPixels);
                        }
			if (aY0 < mHeight-1)
			{
				dest = *(aDestPixels+STRIDE);
				a = CALC_WEIGHT_A(aWeight2);
                                if (a != 0) {				
                                    int oma = 256 - a;
				    BLEND_PIXEL(aDestPixels+STRIDE);
                                }
			}
		}
	}
	else // mostly vertical
	{
		//uint32_t anErrAdj = (uint32_t)(((uint32_t)dx << 16) / (uint32_t)dy);
		uint32_t anErrAdj = (uint32_t)(dxd / dyd * 0x10000);

		uchar aWeight = 255 - (uchar)(anErrAcc >> 8);
		uchar aWeight2 = (aWeight ^ 0xFF);

		PIXEL_TYPE dest = *aDestPixels;
		int a = CALC_WEIGHT_A(aWeight);
                if (a != 0) {
		    int oma = 256 - a;
		    BLEND_PIXEL(aDestPixels);
                }
		while (--dy)
		{
			anErrAcc += anErrAdj;
			if (anErrAcc >= 0x10000)
			{
				anErrAcc &= 0xFFFF;
				aDestPixels += aXinc;
				aX0 += aXinc;
			}
			aDestPixels += STRIDE;

			uchar aWeight = 255 - (uchar)(anErrAcc >> 8);
			uchar aWeight2 = (aWeight ^ 0xFF);

			dest = *aDestPixels;
			int a = CALC_WEIGHT_A(aWeight);
                        if (a != 0) {
                           int oma = 256 - a;
		 	   BLEND_PIXEL(aDestPixels);
                        }
			if (aX0 < STRIDE-1)
			{
				dest = *(aDestPixels+aXinc);
				a = CALC_WEIGHT_A(aWeight2);
                                if (a != 0) {
				    int oma = 256 - a;
				    BLEND_PIXEL(aDestPixels+aXinc);
                                }
			}
		}
	}
	aDestPixels = &aBits[aY1*STRIDE + aX1];
	uchar aWeight = 255 - (uchar)(anErrAcc >> 8);
	uchar aWeight2 = (aWeight ^ 0xFF);

	PIXEL_TYPE dest = *aDestPixels;
	int a = CALC_WEIGHT_A(aWeight);
        if (a != 0) {
	    int oma = 256 - a;
	    BLEND_PIXEL(aDestPixels);
        }
    }
}