From cec3f6878e37fcd1c6c15e0e2ab011931d55549e Mon Sep 17 00:00:00 2001 From: Oliver Chang Date: Thu, 5 Nov 2015 16:00:40 -0800 Subject: Merge to XFA: Update bundled freetype to 2.6.1 Also adds a README.pdfium and 0000-include.patch that details the local modifications made. Also rolls testing/corpus to 45f88c6914fcac26ad930bb0ebbfa468c21db0a5 which includes regenerated corpus expectations. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1413673003 . (cherry picked from commit 87ee069d05ca06f60d6cfacd9e426739d8f2053d) Review URL: https://codereview.chromium.org/1416993005 . --- third_party/freetype/src/base/fttrigon.c | 87 ++++++++++++++++---------------- 1 file changed, 43 insertions(+), 44 deletions(-) (limited to 'third_party/freetype/src/base/fttrigon.c') diff --git a/third_party/freetype/src/base/fttrigon.c b/third_party/freetype/src/base/fttrigon.c index 9b2ccd5d61..5b24304c2f 100644 --- a/third_party/freetype/src/base/fttrigon.c +++ b/third_party/freetype/src/base/fttrigon.c @@ -4,7 +4,7 @@ /* */ /* FreeType trigonometric functions (body). */ /* */ -/* Copyright 2001-2005, 2012-2014 by */ +/* Copyright 2001-2015 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -73,7 +73,7 @@ /* and CORDIC hypotenuse, so it minimizes the error */ val = (FT_Fixed)( ( (FT_Int64)val * FT_TRIG_SCALE + 0x40000000UL ) >> 32 ); - return ( s >= 0 ) ? val : -val; + return s < 0 ? -val : val; } #else /* !FT_LONG64 */ @@ -92,8 +92,8 @@ s = -1; } - lo1 = val & 0x0000FFFFU; - hi1 = val >> 16; + lo1 = (FT_UInt32)val & 0x0000FFFFU; + hi1 = (FT_UInt32)val >> 16; lo2 = FT_TRIG_SCALE & 0x0000FFFFU; hi2 = FT_TRIG_SCALE >> 16; @@ -117,12 +117,12 @@ /* and CORDIC hypotenuse, so it minimizes the error */ /* Check carry overflow of lo + 0x40000000 */ - lo += 0x40000000U; - hi += ( lo < 0x40000000U ); + lo += 0x40000000UL; + hi += ( lo < 0x40000000UL ); - val = (FT_Fixed)hi; + val = (FT_Fixed)hi; - return ( s >= 0 ) ? val : -val; + return s < 0 ? -val : val; } #endif /* !FT_LONG64 */ @@ -139,7 +139,7 @@ x = vec->x; y = vec->y; - shift = FT_MSB( FT_ABS( x ) | FT_ABS( y ) ); + shift = FT_MSB( (FT_UInt32)( FT_ABS( x ) | FT_ABS( y ) ) ); if ( shift <= FT_TRIG_SAFE_MSB ) { @@ -299,11 +299,9 @@ FT_Vector v; - v.x = FT_TRIG_SCALE >> 8; - v.y = 0; - ft_trig_pseudo_rotate( &v, angle ); + FT_Vector_Unit( &v, angle ); - return ( v.x + 0x80L ) >> 8; + return v.x; } @@ -312,7 +310,12 @@ FT_EXPORT_DEF( FT_Fixed ) FT_Sin( FT_Angle angle ) { - return FT_Cos( FT_ANGLE_PI2 - angle ); + FT_Vector v; + + + FT_Vector_Unit( &v, angle ); + + return v.y; } @@ -324,9 +327,7 @@ FT_Vector v; - v.x = FT_TRIG_SCALE >> 8; - v.y = 0; - ft_trig_pseudo_rotate( &v, angle ); + FT_Vector_Unit( &v, angle ); return FT_DivFix( v.y, v.x ); } @@ -388,33 +389,32 @@ FT_Vector v; - if ( !vec ) + if ( !vec || !angle ) return; - v.x = vec->x; - v.y = vec->y; + v = *vec; - if ( angle && ( v.x != 0 || v.y != 0 ) ) - { - shift = ft_trig_prenorm( &v ); - ft_trig_pseudo_rotate( &v, angle ); - v.x = ft_trig_downscale( v.x ); - v.y = ft_trig_downscale( v.y ); + if ( v.x == 0 && v.y == 0 ) + return; - if ( shift > 0 ) - { - FT_Int32 half = (FT_Int32)1L << ( shift - 1 ); + shift = ft_trig_prenorm( &v ); + ft_trig_pseudo_rotate( &v, angle ); + v.x = ft_trig_downscale( v.x ); + v.y = ft_trig_downscale( v.y ); + if ( shift > 0 ) + { + FT_Int32 half = (FT_Int32)1L << ( shift - 1 ); - vec->x = ( v.x + half + FT_SIGN_LONG( v.x ) ) >> shift; - vec->y = ( v.y + half + FT_SIGN_LONG( v.y ) ) >> shift; - } - else - { - shift = -shift; - vec->x = (FT_Pos)( (FT_ULong)v.x << shift ); - vec->y = (FT_Pos)( (FT_ULong)v.y << shift ); - } + + vec->x = ( v.x + half + FT_SIGN_LONG( v.x ) ) >> shift; + vec->y = ( v.y + half + FT_SIGN_LONG( v.y ) ) >> shift; + } + else + { + shift = -shift; + vec->x = (FT_Pos)( (FT_ULong)v.x << shift ); + vec->y = (FT_Pos)( (FT_ULong)v.y << shift ); } } @@ -450,7 +450,7 @@ v.x = ft_trig_downscale( v.x ); if ( shift > 0 ) - return ( v.x + ( 1 << ( shift - 1 ) ) ) >> shift; + return ( v.x + ( 1L << ( shift - 1 ) ) ) >> shift; return (FT_Fixed)( (FT_UInt32)v.x << -shift ); } @@ -480,8 +480,8 @@ v.x = ft_trig_downscale( v.x ); - *length = ( shift >= 0 ) ? ( v.x >> shift ) - : (FT_Fixed)( (FT_UInt32)v.x << -shift ); + *length = shift >= 0 ? ( v.x >> shift ) + : (FT_Fixed)( (FT_UInt32)v.x << -shift ); *angle = v.y; } @@ -512,11 +512,10 @@ FT_Angle delta = angle2 - angle1; - delta %= FT_ANGLE_2PI; - if ( delta < 0 ) + while ( delta <= -FT_ANGLE_PI ) delta += FT_ANGLE_2PI; - if ( delta > FT_ANGLE_PI ) + while ( delta > FT_ANGLE_PI ) delta -= FT_ANGLE_2PI; return delta; -- cgit v1.2.3