ref: 125c3ca8f0a9646995375fd63b7b3ea48e957942
parent: 1ec98b29ec0b9cd6ab138aac44e34562706b0016
author: Alexei Podtelezhnikov <[email protected]>
date: Tue Sep 2 18:38:59 EDT 2014
[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'.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2014-09-02 Alexei Podtelezhnikov <[email protected]>
+
+ [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 <[email protected]>
Don't use `register' keyword. Fixes compiler warnings.
@@ -8,7 +20,7 @@
2014-08-24 Alexei Podtelezhnikov <[email protected]>
- [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.
--- 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;
--- 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 @@
(*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_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 */
@@ -253,6 +252,8 @@
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) */