[truetype] Speed up bytecode interpreter. * src/truetype/ttinterp.c (Normalize): Use `FT_Vector_NormLen'.
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
diff --git a/ChangeLog b/ChangeLog
index 8a68824..eb6a627 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2015-06-29 Alexei Podtelezhnikov <apodtele@gmail.com>
+ [truetype] Speed up bytecode interpreter.
+
+ * src/truetype/ttinterp.c (Normalize): Use `FT_Vector_NormLen'.
+
+2015-06-29 Alexei Podtelezhnikov <apodtele@gmail.com>
+
[base] Speed up emboldening.
* src/base/ftoutln.c (FT_Outline_EmboldenXY): Use `FT_Vector_NormLen'.
diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c
index 089f604..caa4d0f 100644
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -88,13 +88,6 @@
#define BOUNDSL( x, n ) ( (FT_ULong)(x) >= (FT_ULong)(n) )
- /*************************************************************************/
- /* */
- /* This macro computes (a*2^14)/b and complements TT_MulFix14. */
- /* */
-#define TT_DivFix14( a, b ) FT_DivFix( a, (b) << 2 )
-
-
#undef SUCCESS
#define SUCCESS 0
@@ -2580,26 +2573,23 @@
FT_F26Dot6 Vy,
FT_UnitVector* R )
{
- FT_F26Dot6 W;
+ FT_Vector V;
- if ( FT_ABS( Vx ) < 0x4000L && FT_ABS( Vy ) < 0x4000L )
+ if ( Vx == 0 && Vy == 0 )
{
- if ( Vx == 0 && Vy == 0 )
- {
- /* XXX: UNDOCUMENTED! It seems that it is possible to try */
- /* to normalize the vector (0,0). Return immediately. */
- return SUCCESS;
- }
-
- Vx *= 0x4000;
- Vy *= 0x4000;
+ /* XXX: UNDOCUMENTED! It seems that it is possible to try */
+ /* to normalize the vector (0,0). Return immediately. */
+ return SUCCESS;
}
- W = FT_Hypot( Vx, Vy );
+ V.x = Vx;
+ V.y = Vy;
+
+ FT_Vector_NormLen( &V );
- R->x = (FT_F2Dot14)TT_DivFix14( Vx, W );
- R->y = (FT_F2Dot14)TT_DivFix14( Vy, W );
+ R->x = (FT_F2Dot14)( V.x / 4 );
+ R->y = (FT_F2Dot14)( V.y / 4 );
return SUCCESS;
}