diff options
author | Alexei Podtelezhnikov <apodtele@gmail.com> | 2019-04-25 22:06:33 -0400 |
---|---|---|
committer | Alexei Podtelezhnikov <apodtele@gmail.com> | 2019-04-25 22:06:33 -0400 |
commit | 7a81b63abc2b3da0d7f0950f69377d2b3f54b0fb (patch) | |
tree | 3141714c82a59fcc50c8627c4039d56ccf9b3e14 /src/raster | |
parent | 432bb50ff539e7672723dc9161e44046710a1334 (diff) | |
download | freetype2-7a81b63abc2b3da0d7f0950f69377d2b3f54b0fb.tar.gz |
Optimize Bézier bisections.
* src/raster/ftraster.c (Split_Conic, Split_Cubic): Use shifts and
refactor.
* src/smooth/ftgrays.c (gray_split_conic, gray_split_cubic): Ditto.
* src/base/ftstroke.c (ft_conic_split, ft_cubic_split): Ditto.
* src/base/ftbbox.c (cubic_peak): Use shifts.
Diffstat (limited to 'src/raster')
-rw-r--r-- | src/raster/ftraster.c | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/src/raster/ftraster.c b/src/raster/ftraster.c index 798a72d02..2859113a3 100644 --- a/src/raster/ftraster.c +++ b/src/raster/ftraster.c @@ -914,16 +914,18 @@ base[4].x = base[2].x; - b = base[1].x; - a = base[3].x = ( base[2].x + b ) / 2; - b = base[1].x = ( base[0].x + b ) / 2; - base[2].x = ( a + b ) / 2; + a = base[0].x + base[1].x; + b = base[1].x + base[2].x; + base[3].x = b >> 1; + base[2].x = ( a + b ) >> 2; + base[1].x = a >> 1; base[4].y = base[2].y; - b = base[1].y; - a = base[3].y = ( base[2].y + b ) / 2; - b = base[1].y = ( base[0].y + b ) / 2; - base[2].y = ( a + b ) / 2; + a = base[0].y + base[1].y; + b = base[1].y + base[2].y; + base[3].y = b >> 1; + base[2].y = ( a + b ) >> 2; + base[1].y = a >> 1; /* hand optimized. gcc doesn't seem to be too good at common */ /* expression substitution and instruction scheduling ;-) */ @@ -947,28 +949,32 @@ static void Split_Cubic( TPoint* base ) { - Long a, b, c, d; + Long a, b, c; base[6].x = base[3].x; - c = base[1].x; - d = base[2].x; - base[1].x = a = ( base[0].x + c + 1 ) >> 1; - base[5].x = b = ( base[3].x + d + 1 ) >> 1; - c = ( c + d + 1 ) >> 1; - base[2].x = a = ( a + c + 1 ) >> 1; - base[4].x = b = ( b + c + 1 ) >> 1; - base[3].x = ( a + b + 1 ) >> 1; + a = base[0].x + base[1].x; + b = base[1].x + base[2].x; + c = base[2].x + base[3].x; + base[5].x = c >> 1; + c += b; + base[4].x = c >> 2; + base[1].x = a >> 1; + a += b; + base[2].x = a >> 2; + base[3].x = ( a + c ) >> 3; base[6].y = base[3].y; - c = base[1].y; - d = base[2].y; - base[1].y = a = ( base[0].y + c + 1 ) >> 1; - base[5].y = b = ( base[3].y + d + 1 ) >> 1; - c = ( c + d + 1 ) >> 1; - base[2].y = a = ( a + c + 1 ) >> 1; - base[4].y = b = ( b + c + 1 ) >> 1; - base[3].y = ( a + b + 1 ) >> 1; + a = base[0].y + base[1].y; + b = base[1].y + base[2].y; + c = base[2].y + base[3].y; + base[5].y = c >> 1; + c += b; + base[4].y = c >> 2; + base[1].y = a >> 1; + a += b; + base[2].y = a >> 2; + base[3].y = ( a + c ) >> 3; } |