some simplifications of the TrueType interpreter projection code (preliminaries to various interpreter fixes)
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 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
diff --git a/ChangeLog b/ChangeLog
index 5664b25..2f6966a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2007-02-12 David Turner <david@freetype.org>
+ * src/truetype/ttinterp.h, src/truetype/ttinterp.c: simplify
+ projection and dual-projection code interface
+
* include/freetype/internal/ftmemory.h, src/base/ftutils.c,
src/bfd/bfddrivr.c, src/bdf/bdflib.c, src/pcf/pcfread.c,
src/cff/cffdrivr.c, src/cff/cffload.c, src/cff/cffobjs.c,
diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c
index bde16d2..8851784 100644
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -163,18 +163,12 @@
#define INS_Goto_CodeRange( range, ip ) \
Ins_Goto_CodeRange( EXEC_ARG_ range, ip )
-#define CUR_Func_project( x, y ) \
- CUR.func_project( EXEC_ARG_ x, y )
-
#define CUR_Func_move( z, p, d ) \
CUR.func_move( EXEC_ARG_ z, p, d )
#define CUR_Func_move_orig( z, p, d ) \
CUR.func_move_orig( EXEC_ARG_ z, p, d )
-#define CUR_Func_dualproj( x, y ) \
- CUR.func_dualproj( EXEC_ARG_ x, y )
-
#define CUR_Func_round( d, c ) \
CUR.func_round( EXEC_ARG_ d, c )
@@ -212,6 +206,19 @@
Move_Zp2_Point( EXEC_ARG_ a, b, c, t )
+# define CUR_Func_project( v1, v2 ) \
+ CUR.func_project( EXEC_ARG_ (v1)->x - (v2)->x, (v1)->y - (v2)->y )
+
+# define CUR_Func_dualproj( v1, v2 ) \
+ CUR.func_dualproj( EXEC_ARG_ (v1)->x - (v2)->x, (v1)->y - (v2)->y )
+
+# define CUR_fast_project(v) \
+ CUR.func_project( EXEC_ARG_ (v)->x, (v)->y )
+
+# define CUR_fast_dualproj(v) \
+ CUR.func_dualproj( EXEC_ARG_ (v)->x, (v)->y )
+
+
/*************************************************************************/
/* */
/* Instruction dispatch function, as used by the interpreter. */
@@ -2150,18 +2157,17 @@
/* The distance in F26dot6 format. */
/* */
static FT_F26Dot6
- Project( EXEC_OP_ FT_Vector* v1,
- FT_Vector* v2 )
- {
+ Project( EXEC_OP_ FT_Pos dx,
+ FT_Pos dy )
+{
#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
FT_ASSERT( !CUR.face->unpatented_hinting );
#endif
- return TT_DotFix14( v1->x - v2->x,
- v1->y - v2->y,
+ return TT_DotFix14( dx, dy,
CUR.GS.projVector.x,
CUR.GS.projVector.y );
- }
+}
/*************************************************************************/
/* */
@@ -2180,16 +2186,14 @@
/* The distance in F26dot6 format. */
/* */
static FT_F26Dot6
- Dual_Project( EXEC_OP_ FT_Vector* v1,
- FT_Vector* v2 )
+ Dual_Project( EXEC_OP_ FT_Pos dx,
+ FT_Pos dy )
{
- return TT_DotFix14( v1->x - v2->x,
- v1->y - v2->y,
+ return TT_DotFix14( dx, dy,
CUR.GS.dualVector.x,
CUR.GS.dualVector.y );
}
-
/*************************************************************************/
/* */
/* <Function> */
@@ -2207,15 +2211,14 @@
/* The distance in F26dot6 format. */
/* */
static FT_F26Dot6
- Project_x( EXEC_OP_ FT_Vector* v1,
- FT_Vector* v2 )
+ Project_x( EXEC_OP_ FT_Pos dx,
+ FT_Pos dy )
{
FT_UNUSED_EXEC;
- return ( v1->x - v2->x );
+ return dx;
}
-
/*************************************************************************/
/* */
/* <Function> */
@@ -2233,15 +2236,14 @@
/* The distance in F26dot6 format. */
/* */
static FT_F26Dot6
- Project_y( EXEC_OP_ FT_Vector* v1,
- FT_Vector* v2 )
+ Project_y( EXEC_OP_ FT_Pos dx,
+ FT_Pos dy )
{
FT_UNUSED_EXEC;
- return ( v1->y - v2->y );
+ return dy;
}
-
/*************************************************************************/
/* */
/* <Function> */
@@ -4701,9 +4703,9 @@
else
{
if ( CUR.opcode & 1 )
- R = CUR_Func_dualproj( CUR.zp2.org + L, NULL_Vector );
+ R = CUR_fast_dualproj( &CUR.zp2.org[L] );
else
- R = CUR_Func_project( CUR.zp2.cur + L, NULL_Vector );
+ R = CUR_fast_project( &CUR.zp2.cur[L] );
}
args[0] = R;
@@ -4736,7 +4738,7 @@
return;
}
- K = CUR_Func_project( CUR.zp2.cur + L, NULL_Vector );
+ K = CUR_fast_project( &CUR.zp2.cur[L] );
CUR_Func_move( &CUR.zp2, L, args[1] - K );
@@ -5623,7 +5625,7 @@
/* twilight zone? ? */
if ( ( CUR.opcode & 1 ) != 0 )
{
- cur_dist = CUR_Func_project( CUR.zp0.cur + point, NULL_Vector );
+ cur_dist = CUR_fast_project( &CUR.zp0.cur[point] );
distance = CUR_Func_round( cur_dist,
CUR.tt_metrics.compensations[0] ) - cur_dist;
}
@@ -5694,7 +5696,7 @@
CUR.zp0.cur[point] = CUR.zp0.org[point];
}
- org_dist = CUR_Func_project( CUR.zp0.cur + point, NULL_Vector );
+ org_dist = CUR_fast_project( &CUR.zp0.cur[point] );
if ( ( CUR.opcode & 1 ) != 0 ) /* rounding and control cutin flag */
{
@@ -6179,18 +6181,18 @@
vec2.x = TT_MULFIX( vec2.x, CUR.metrics.x_scale );
vec2.y = TT_MULFIX( vec2.y, CUR.metrics.y_scale );
- org_a = CUR_Func_dualproj( &vec1, NULL_Vector );
- org_b = CUR_Func_dualproj( &vec2, NULL_Vector );
+ org_a = CUR_fast_dualproj( &vec1 );
+ org_b = CUR_fast_dualproj( &vec2 );
#else
- org_a = CUR_Func_dualproj( CUR.zp0.org + CUR.GS.rp1, NULL_Vector );
- org_b = CUR_Func_dualproj( CUR.zp1.org + CUR.GS.rp2, NULL_Vector );
+ org_a = CUR_fast_dualproj( &CUR.zp0.org[CUR.GS.rp1] );
+ org_b = CUR_fast_dualproj( &CUR.zp1.org[CUR.GS.rp2] );
#endif /* FIX_BYTECODE */
- cur_a = CUR_Func_project( CUR.zp0.cur + CUR.GS.rp1, NULL_Vector );
- cur_b = CUR_Func_project( CUR.zp1.cur + CUR.GS.rp2, NULL_Vector );
+ cur_a = CUR_fast_project( &CUR.zp0.cur[CUR.GS.rp1] );
+ cur_b = CUR_fast_project( &CUR.zp1.cur[CUR.GS.rp2] );
}
while ( CUR.GS.loop > 0 )
@@ -6218,15 +6220,15 @@
vec.x = TT_MULFIX( vec.x, CUR.metrics.x_scale );
vec.y = TT_MULFIX( vec.y, CUR.metrics.y_scale );
- org_x = CUR_Func_dualproj( &vec, NULL_Vector );
+ org_x = CUR_fast_dualproj( &vec );
#else
- org_x = CUR_Func_dualproj( CUR.zp2.org + point, NULL_Vector );
+ org_x = CUR_fast_dualproj( &CUR.zp2.org[point] );
#endif /* FIX_BYTECODE */
- cur_x = CUR_Func_project ( CUR.zp2.cur + point, NULL_Vector );
+ cur_x = CUR_fast_project ( &CUR.zp2.cur[point] );
if ( ( org_a <= org_b && org_x <= org_a ) ||
( org_a > org_b && org_x >= org_a ) )
diff --git a/src/truetype/ttinterp.h b/src/truetype/ttinterp.h
index 2b8dae1..fe29481 100644
--- a/src/truetype/ttinterp.h
+++ b/src/truetype/ttinterp.h
@@ -19,7 +19,6 @@
#ifndef __TTINTERP_H__
#define __TTINTERP_H__
-
#include <ft2build.h>
#include "ttobjs.h"
@@ -79,8 +78,8 @@ FT_BEGIN_HEADER
/* Distance projection along one of the projection vectors */
typedef FT_F26Dot6
- (*TT_Project_Func)( EXEC_OP_ FT_Vector* v1,
- FT_Vector* v2 );
+ (*TT_Project_Func)( EXEC_OP_ FT_Pos dx,
+ FT_Pos dy );
/* reading a cvt value. Take care of non-square pixels if necessary */
typedef FT_F26Dot6