summaryrefslogtreecommitdiff
path: root/osframework/source/SexyAppFramework/GENERIC_DrawLineAA.inc
diff options
context:
space:
mode:
Diffstat (limited to 'osframework/source/SexyAppFramework/GENERIC_DrawLineAA.inc')
-rw-r--r--osframework/source/SexyAppFramework/GENERIC_DrawLineAA.inc92
1 files changed, 92 insertions, 0 deletions
diff --git a/osframework/source/SexyAppFramework/GENERIC_DrawLineAA.inc b/osframework/source/SexyAppFramework/GENERIC_DrawLineAA.inc
new file mode 100644
index 0000000..21e8cc1
--- /dev/null
+++ b/osframework/source/SexyAppFramework/GENERIC_DrawLineAA.inc
@@ -0,0 +1,92 @@
+{
+ PIXEL_TYPE* aDestPixels = &aBits[aY0*STRIDE + aX0];
+ ulong anErrAcc = (ulong)(fabs(theStartX - aX0)*fabs(theStartY - aY0) * 0x10000);
+ if (dx >= dy) // mostly horizontal
+ {
+ //ulong anErrAdj = (((ulong)dy << 16) / (ulong)dx);
+ ulong anErrAdj = (ulong)(dyd / dxd * 0x10000);
+
+ uchar aWeight = 255 - (uchar)(anErrAcc >> 8);
+ uchar aWeight2 = (aWeight ^ 0xFF);
+
+ int a = CALC_WEIGHT_A(aWeight);
+ int oma = 256 - a;
+ PIXEL_TYPE dest = *aDestPixels;
+ 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);
+ oma = 256 - a;
+
+ BLEND_PIXEL(aDestPixels);
+ if (aY0 < mHeight-1)
+ {
+ dest = *(aDestPixels+STRIDE);
+ a = CALC_WEIGHT_A(aWeight2);
+ oma = 256 - a;
+ BLEND_PIXEL(aDestPixels+STRIDE);
+ }
+ }
+ }
+ else // mostly vertical
+ {
+ //ulong anErrAdj = (ulong)(((ulong)dx << 16) / (ulong)dy);
+ ulong anErrAdj = (ulong)(dxd / dyd * 0x10000);
+
+ uchar aWeight = 255 - (uchar)(anErrAcc >> 8);
+ uchar aWeight2 = (aWeight ^ 0xFF);
+
+ int a = CALC_WEIGHT_A(aWeight);
+ int oma = 256 - a;
+ PIXEL_TYPE dest = *aDestPixels;
+ 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);
+ int oma = 256 - a;
+
+ BLEND_PIXEL(aDestPixels);
+ if (aX0 < STRIDE-1)
+ {
+ a = CALC_WEIGHT_A(aWeight2);
+ oma = 256 - a;
+ dest = *(aDestPixels+aXinc);
+ BLEND_PIXEL(aDestPixels+aXinc);
+ }
+ }
+ }
+ aDestPixels = &aBits[aY1*STRIDE + aX1];
+ uchar aWeight = 255 - (uchar)(anErrAcc >> 8);
+ uchar aWeight2 = (aWeight ^ 0xFF);
+
+ int a = CALC_WEIGHT_A(aWeight);
+ int oma = 256 - a;
+ PIXEL_TYPE dest = *aDestPixels;
+ BLEND_PIXEL(aDestPixels);
+} \ No newline at end of file