freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] master 1fc776b: * src/base/fttrigon.c (FT_Tan): Improve accu


From: Alexei Podtelezhnikov
Subject: [freetype2] master 1fc776b: * src/base/fttrigon.c (FT_Tan): Improve accuracy.
Date: Thu, 28 Jun 2018 21:43:03 -0400 (EDT)

branch: master
commit 1fc776b5f14e2be6fa3d6573f5cd3fb88a7ae468
Author: Alexei Podtelezhnikov <address@hidden>
Commit: Alexei Podtelezhnikov <address@hidden>

    * src/base/fttrigon.c (FT_Tan): Improve accuracy.
    (FT_Vector_Rotate): Simplify.
---
 ChangeLog           |  5 +++++
 src/base/fttrigon.c | 16 ++++------------
 2 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2dc6d29..e23cc96 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2018-06-28  Alexei Podtelezhnikov  <address@hidden>
 
+       * src/base/fttrigon.c (FT_Tan): Improve accuracy.
+       (FT_Vector_Rotate): Simplify.
+
+2018-06-28  Alexei Podtelezhnikov  <address@hidden>
+
        * src/base/ftobjs.c (FT_Set_Charmap): Robustify.
 
 2018-06-25  Werner Lemberg  <address@hidden>
diff --git a/src/base/fttrigon.c b/src/base/fttrigon.c
index 6a10492..d375bd7 100644
--- a/src/base/fttrigon.c
+++ b/src/base/fttrigon.c
@@ -325,10 +325,10 @@
   FT_EXPORT_DEF( FT_Fixed )
   FT_Tan( FT_Angle  angle )
   {
-    FT_Vector  v;
+    FT_Vector  v = { 1 << 24, 0 };
 
 
-    FT_Vector_Unit( &v, angle );
+    ft_trig_pseudo_rotate( &v, angle );
 
     return FT_DivFix( v.y, v.x );
   }
@@ -372,14 +372,6 @@
   }
 
 
-  /* these macros return 0 for positive numbers,
-     and -1 for negative ones */
-#define FT_SIGN_LONG( x )   ( (x) >> ( FT_SIZEOF_LONG * 8 - 1 ) )
-#define FT_SIGN_INT( x )    ( (x) >> ( FT_SIZEOF_INT * 8 - 1 ) )
-#define FT_SIGN_INT32( x )  ( (x) >> 31 )
-#define FT_SIGN_INT16( x )  ( (x) >> 15 )
-
-
   /* documentation is in fttrigon.h */
 
   FT_EXPORT_DEF( void )
@@ -408,8 +400,8 @@
       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;
+      vec->x = ( v.x + half - ( v.x < 0 ) ) >> shift;
+      vec->y = ( v.y + half - ( v.y < 0 ) ) >> shift;
     }
     else
     {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]