[truetype] Shortcut ppem calculations for square pixels. * src/truetype/ttinterp.h (TT_ExecContextRec): New field `cur_ppem_func' with a function pointer. * src/truetype/ttinterp.c (TT_RunIns): Initialize `cur_ppem_func' depending on the pixel geometry to either... (Current_Ppem_Stretched): ... this for stretched pixels. (Current_Ppem): ... or this for square pixels. (DO_MPPEM, DO_MPS, Ins_DELTAP, Ins_DELTAC): Use `cur_ppem_func'.
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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
diff --git a/ChangeLog b/ChangeLog
index 1824c0c..62ec7ae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2014-09-02 Alexei Podtelezhnikov <apodtele@gmail.com>
+
+ [truetype] Shortcut ppem calculations for square pixels.
+
+ * src/truetype/ttinterp.h (TT_ExecContextRec): New field
+ `cur_ppem_func' with a function pointer.
+ * src/truetype/ttinterp.c (TT_RunIns): Initialize `cur_ppem_func'
+ depending on the pixel geometry to either...
+ (Current_Ppem_Stretched): ... this for stretched pixels.
+ (Current_Ppem): ... or this for square pixels.
+ (DO_MPPEM, DO_MPS, Ins_DELTAP, Ins_DELTAC): Use `cur_ppem_func'.
+
2014-08-31 Behdad Esfahbod <behdad@behdad.org>
Don't use `register' keyword. Fixes compiler warnings.
@@ -8,7 +20,7 @@
2014-08-24 Alexei Podtelezhnikov <apodtele@gmail.com>
- [truetype] Optimize DELTAP and DELTAC.
+ [truetype] Optimize DELTAP and DELTAC.
* src/truetype/ttinterp.c (Ins_DELTAP, Ins_DELTAC): Move ppem
calculations outside of the loop.
diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c
index 1f8debf..7d0248b 100644
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -172,6 +172,9 @@
#define CUR_Func_round( d, c ) \
CUR.func_round( EXEC_ARG_ d, c )
+#define CUR_Func_cur_ppem() \
+ CUR.func_cur_ppem( EXEC_ARG )
+
#define CUR_Func_read_cvt( index ) \
CUR.func_read_cvt( EXEC_ARG_ index )
@@ -184,12 +187,6 @@
#define CURRENT_Ratio() \
Current_Ratio( EXEC_ARG )
-#define CURRENT_Ppem() \
- Current_Ppem( EXEC_ARG )
-
-#define CUR_Ppem() \
- Cur_PPEM( EXEC_ARG )
-
#define INS_SxVTL( a, b, c, d ) \
Ins_SxVTL( EXEC_ARG_ a, b, c, d )
@@ -1706,9 +1703,16 @@
}
- static FT_Long
+ FT_CALLBACK_DEF( FT_Long )
Current_Ppem( EXEC_OP )
{
+ return CUR.tt_metrics.ppem;
+ }
+
+
+ FT_CALLBACK_DEF( FT_Long )
+ Current_Ppem_Stretched( EXEC_OP )
+ {
return FT_MulFix( CUR.tt_metrics.ppem, CURRENT_Ratio() );
}
@@ -3089,7 +3093,7 @@
#define DO_MPPEM \
- args[0] = CURRENT_Ppem();
+ args[0] = CUR_Func_cur_ppem();
/* Note: The pointSize should be irrelevant in a given font program; */
@@ -3102,7 +3106,7 @@
#else
#define DO_MPS \
- args[0] = CURRENT_Ppem();
+ args[0] = CUR_Func_cur_ppem();
#endif /* 0 */
@@ -7523,7 +7527,7 @@
}
#endif
- P = (FT_ULong)CURRENT_Ppem();
+ P = (FT_ULong)CUR_Func_cur_ppem();
nump = (FT_ULong)args[0]; /* some points theoretically may occur more
than once, thus UShort isn't enough */
@@ -7692,7 +7696,7 @@
}
#endif
- P = (FT_ULong)CURRENT_Ppem();
+ P = (FT_ULong)CUR_Func_cur_ppem();
nump = (FT_ULong)args[0];
for ( k = 1; k <= nump; k++ )
@@ -8271,11 +8275,12 @@
CUR.iup_called = FALSE;
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
- /* set CVT functions */
+ /* set PPEM and CVT functions */
CUR.tt_metrics.ratio = 0;
if ( CUR.metrics.x_ppem != CUR.metrics.y_ppem )
{
/* non-square pixels, use the stretched routines */
+ CUR.func_cur_ppem = Current_Ppem_Stretched;
CUR.func_read_cvt = Read_CVT_Stretched;
CUR.func_write_cvt = Write_CVT_Stretched;
CUR.func_move_cvt = Move_CVT_Stretched;
@@ -8283,6 +8288,7 @@
else
{
/* square pixels, use normal routines */
+ CUR.func_cur_ppem = Current_Ppem;
CUR.func_read_cvt = Read_CVT;
CUR.func_write_cvt = Write_CVT;
CUR.func_move_cvt = Move_CVT;
diff --git a/src/truetype/ttinterp.h b/src/truetype/ttinterp.h
index 1d8825d..3cfc859 100644
--- a/src/truetype/ttinterp.h
+++ b/src/truetype/ttinterp.h
@@ -4,7 +4,7 @@
/* */
/* TrueType bytecode interpreter (specification). */
/* */
-/* Copyright 1996-2007, 2010, 2012-2013 by */
+/* Copyright 1996-2007, 2010, 2012-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -81,6 +81,10 @@ FT_BEGIN_HEADER
(*TT_Project_Func)( EXEC_OP_ FT_Pos dx,
FT_Pos dy );
+ /* getting current ppem. Take care of non-square pixels if necessary */
+ typedef FT_Long
+ (*TT_Cur_Ppem_Func)( EXEC_OP );
+
/* reading a cvt value. Take care of non-square pixels if necessary */
typedef FT_F26Dot6
(*TT_Get_CVT_Func)( EXEC_OP_ FT_ULong idx );
@@ -228,11 +232,6 @@ FT_BEGIN_HEADER
FT_F26Dot6 phase; /* `SuperRounding' */
FT_F26Dot6 threshold;
-#if 0
- /* this seems to be unused */
- FT_Int cur_ppem; /* ppem along the current proj vector */
-#endif
-
FT_Bool instruction_trap; /* If `True', the interpreter will */
/* exit after each instruction */
@@ -254,6 +253,8 @@ FT_BEGIN_HEADER
TT_Move_Func func_move; /* current point move function */
TT_Move_Func func_move_orig; /* move original position function */
+ TT_Cur_Ppem_Func func_cur_ppem; /* get current proj. ppem value */
+
TT_Get_CVT_Func func_read_cvt; /* read a cvt entry */
TT_Set_CVT_Func func_write_cvt; /* write a cvt entry (in pixels) */
TT_Set_CVT_Func func_move_cvt; /* incr a cvt entry (in pixels) */