summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/freetype/src/base/fttrigon.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/freetype/src/base/fttrigon.c')
-rw-r--r--src/3rdparty/freetype/src/base/fttrigon.c75
1 files changed, 37 insertions, 38 deletions
diff --git a/src/3rdparty/freetype/src/base/fttrigon.c b/src/3rdparty/freetype/src/base/fttrigon.c
index 22b7ecf1bf..5b24304c2f 100644
--- a/src/3rdparty/freetype/src/base/fttrigon.c
+++ b/src/3rdparty/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, */
@@ -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;
@@ -120,7 +120,7 @@
lo += 0x40000000UL;
hi += ( lo < 0x40000000UL );
- val = (FT_Fixed)hi;
+ val = (FT_Fixed)hi;
return s < 0 ? -val : val;
}
@@ -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 );
}
@@ -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;