* src/smooth/ftgrays.c (gray_hline): Improve code.

This commit is contained in:
Alexei Podtelezhnikov 2017-02-22 22:41:36 -05:00
parent 73a7ce3d00
commit 761d9e418b
2 changed files with 14 additions and 17 deletions

View File

@ -1,3 +1,7 @@
2017-02-22 Alexei Podtelezhnikov <apodtele@gmail.com>
* src/smooth/ftgrays.c (gray_hline): Improve code.
2017-02-20 Dominik Röttsches <drott@google.com>
Fix some `ttnameid.h' entries (#50313).

View File

@ -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;