Some improvements to make the new anti-alias algorithm faster when large glyph images are generated (e.g. ` fttimer -g' runs 20% faster). For small pixel sizes (i.e. typically less than 64 pixels), rendering speed is unaffected.
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 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
diff --git a/src/base/ftraster.c b/src/base/ftraster.c
index abf78f3..15b557f 100644
--- a/src/base/ftraster.c
+++ b/src/base/ftraster.c
@@ -2990,7 +2990,6 @@
/*************************************************************************/
/*************************************************************************/
-
#ifdef FT_RASTER_OPTION_ANTI_ALIAS
/*************************************************************************/
@@ -3043,11 +3042,10 @@
TPos x1,
TPos x2 )
{
- TPos e1, e2;
- int shift = ras.precision_bits - 6;
+ TPos e1, e2;
+ int shift = ras.precision_bits - 6;
PByte target;
-
UNUSED( y );
x1 += ras.precision_half;
@@ -3086,19 +3084,20 @@
if ( e2 > 0 )
{
- target[0] += (Byte)(64-x1);
+ if (x1 > 0) target[0] += (Byte)(64-x1) << 1;
+ else target[0] = 127;
e2--;
while (e2 > 0)
{
- *(++target) += 64;
+ *(++target) = 127;
e2--;
}
if (x2)
- target[1] += (Byte)x2;
+ target[1] += (Byte)x2 << 1;
}
else
{
- target[0] += (Byte)(x2-x1);
+ target[0] += (Byte)(x2-x1) << 1;
}
}
}
@@ -3167,7 +3166,7 @@
if (color < 64)
color = 64;
- *pixel = ( color >= 128 ? 128 : (unsigned char)color );
+ *pixel = ( color >= 127 ? 127 : (unsigned char)color );
}
}
@@ -3256,10 +3255,11 @@
TPos x1,
TPos x2 )
{
- TPos e1, e2;
- int shift = ras.precision_bits - 6;
- int incr;
+ TPos e1, e2;
+ int shift = ras.precision_bits - 6;
+ int incr;
PByte bits;
+ Byte b;
UNUSED( y );
@@ -3305,20 +3305,36 @@
if ( e2 > 0 )
{
- bits[0] += (Byte)(64-x1);
+ b = bits[0];
+ if (b < 127) b++;
+ bits[0] = (64-x1) + (b >> 1);
+
e2--;
while (e2 > 0)
{
- bits += incr;
- bits[0] += 64;
+ bits += incr;
+ b = bits[0];
+
+ if (b < 127)
+ bits[0] = (Byte)(63+((b+1) >> 1));
+
e2--;
}
+
if (x2)
- bits[incr] += (Byte)x2;
+ {
+ bits += incr;
+ b = bits[0];
+ if (b < 127) b++;
+ bits[0] = (Byte)(x2 + (b >> 1));
+ }
+
}
else
{
- bits[0] += (Byte)(x2-x1);
+ b = bits[0];
+ if (b < 127) b++;
+ bits[0] = (Byte)((b >> 1)+(x2-x1));
}
}
}
@@ -3391,8 +3407,9 @@
color += *pixel;
if (color < 64)
color = 64;
-
- *pixel = (color >= 128 ? 128 : (unsigned char)color );
+/*
+ *pixel = (color >= 127 ? 127 : (unsigned char)color );
+ */
}
}