diff --git a/ChangeLog b/ChangeLog index 63f0bfdfa..976efa1b5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2017-02-22 Alexei Podtelezhnikov + + * src/smooth/ftgrays.c (gray_hline): Improve code. + 2017-02-20 Dominik Röttsches Fix some `ttnameid.h' entries (#50313). diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c index 1fe558db4..e9a3ce7a7 100644 --- a/src/smooth/ftgrays.c +++ b/src/smooth/ftgrays.c @@ -1222,31 +1222,21 @@ typedef ptrdiff_t FT_PtrDist; static void gray_hline( RAS_ARG_ TCoord x, TCoord y, - TArea area, + TArea coverage, TCoord acount ) { - int coverage; - FT_Span span; - - - /* compute the coverage line's coverage, depending on the */ - /* outline fill rule */ - /* */ - /* the coverage percentage is area/(PIXEL_BITS*PIXEL_BITS*2) */ - /* */ - coverage = (int)( area >> ( PIXEL_BITS * 2 + 1 - 8 ) ); - /* use range 0..256 */ + /* scale the coverage from 0..(ONE_PIXEL*ONE_PIXEL*2) to 0..256 */ + coverage >>= PIXEL_BITS * 2 + 1 - 8; if ( coverage < 0 ) - coverage = -coverage; + coverage = -coverage - 1; + /* compute the line's coverage depending on the outline fill rule */ if ( ras.outline.flags & FT_OUTLINE_EVEN_ODD_FILL ) { coverage &= 511; - if ( coverage > 256 ) - coverage = 512 - coverage; - else if ( coverage == 256 ) - coverage = 255; + if ( coverage >= 256 ) + coverage = 511 - coverage; } else { @@ -1257,6 +1247,9 @@ typedef ptrdiff_t FT_PtrDist; if ( ras.render_span ) /* for FT_RASTER_FLAG_DIRECT only */ { + FT_Span span; + + span.x = (short)x; span.len = (unsigned short)acount; span.coverage = (unsigned char)coverage;