Commit 5ad05f97b60e14c0a8bf58e74016c375d2ee78c0

Alexei Podtelezhnikov 2012-12-06T00:27:20

[truetype] Microoptimizations in bytecode interpreter. * src/truetype/ttinterp.c (TT_DivFix14): New macro. (Normalize): Use it here. (Current_Ratio): Use TT_MulFix14 instead of FT_MulDiv. (Ins_SHPIX): Cancel out two TT_MulFix14 calls.

diff --git a/ChangeLog b/ChangeLog
index 838ced2..1373f64 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2012-12-06  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+	[truetype] Microoptimizations in bytecode interpreter.
+
+	* src/truetype/ttinterp.c (TT_DivFix14): New macro.
+	(Normalize): Use it here.
+	(Current_Ratio): Use TT_MulFix14 instead of FT_MulDiv.
+	(Ins_SHPIX): Cancel out two TT_MulFix14 calls.
+
 2012-12-05  Alexei Podtelezhnikov  <apodtele@gmail.com>
 
 	[truetype] Cosmetic improvement in bytecode interpreter.
@@ -750,7 +759,7 @@
 	(ALWAYS_SKIP_DELTAP_Rules): Add Russian char 0x438.
 	(COMPATIBLE_WIDTHS_Rules): Rearrange some rules.
 	(X_SCALING_Rules): Adjust Verdana `a' at 12 and 13 ppem.
-	
+
 	* src/truetype/ttsubpix.c: Updated.
 	(sph_set_tweaks): Re-execute fpgm always.
 
diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c
index c2ed254..ffdf74d 100644
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -231,6 +231,14 @@
 #define BOUNDS( x, n )   ( (FT_UInt)(x)  >= (FT_UInt)(n)  )
 #define BOUNDSL( x, n )  ( (FT_ULong)(x) >= (FT_ULong)(n) )
 
+  /*************************************************************************/
+  /*                                                                       */
+  /* This macro computes (a*2^14)/b and compliments TT_MulFix14.           */
+  /*                                                                       */
+#define TT_DivFix14( a, b ) \
+          FT_DivFix( a, (b) << 2 )
+
+
 #undef  SUCCESS
 #define SUCCESS  0
 
@@ -1660,13 +1668,13 @@
 
         else
         {
-          FT_Long  x, y;
+          FT_F26Dot6  x, y;
 
 
-          x = FT_MulDiv( CUR.GS.projVector.x,
-                         CUR.tt_metrics.x_ratio, 0x4000 );
-          y = FT_MulDiv( CUR.GS.projVector.y,
-                         CUR.tt_metrics.y_ratio, 0x4000 );
+          x = TT_MulFix14( CUR.GS.projVector.x,
+                           CUR.tt_metrics.x_ratio );
+          y = TT_MulFix14( CUR.GS.projVector.y,
+                           CUR.tt_metrics.y_ratio );
           CUR.tt_metrics.ratio = TT_VecLen( x, y );
         }
       }
@@ -2751,16 +2759,16 @@
         return SUCCESS;
       }
 
-      R->x = (FT_F2Dot14)FT_MulDiv( Vx, 0x4000L, W );
-      R->y = (FT_F2Dot14)FT_MulDiv( Vy, 0x4000L, W );
+      R->x = (FT_F2Dot14)TT_DivFix14( Vx, W );
+      R->y = (FT_F2Dot14)TT_DivFix14( Vy, W );
 
       return SUCCESS;
     }
 
     W = TT_VecLen( Vx, Vy );
 
-    Vx = FT_MulDiv( Vx, 0x4000L, W );
-    Vy = FT_MulDiv( Vy, 0x4000L, W );
+    Vx = TT_DivFix14( Vx, W );
+    Vy = TT_DivFix14( Vy, W );
 
     W = Vx * Vx + Vy * Vy;
 
@@ -6076,13 +6084,13 @@
     {
       if ( CUR.GS.both_x_axis )
       {
-        dx = TT_MulFix14( (FT_UInt32)args[0], 0x4000 );
+        dx = (FT_UInt32)args[0];
         dy = 0;
       }
       else
       {
         dx = 0;
-        dy = TT_MulFix14( (FT_UInt32)args[0], 0x4000 );
+        dy = (FT_UInt32)args[0];
       }
     }
     else