[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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
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