mirror of
git://git.sv.nongnu.org/freetype/freetype2.git
synced 2026-01-19 04:52:09 +00:00
[truetype] Clean up bytecode execution triggers.
This avoids executing the CV program twice and cleans up the use of 'fpgm' and 'prep' triggers * src/truetype/ttgload.c (tt_loader_init): Call 'tt_size_init_bytecode' and 'tt_size_run_prep' explicitly and avoid the call repetition. * src/truetype/ttobjs.c (tt_size_ready_bytecode): Removed as unused. (tt_size_init, tt_size_init_bytecode, tt_size_done_bytecode): Remove some 'fpgm' and 'prep' triggers and update. (tt_size_run_fpgm, tt_size_run_prep): Do not set the pedantic flag here. * src/truetype/ttobjs.h: Update signatures.
This commit is contained in:
@@ -2205,7 +2205,6 @@
|
||||
{
|
||||
FT_Error error;
|
||||
TT_ExecContext exec;
|
||||
FT_Bool pedantic = FT_BOOL( load_flags & FT_LOAD_PEDANTIC );
|
||||
FT_Bool grayscale = TRUE;
|
||||
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
|
||||
FT_Bool subpixel_hinting_lean;
|
||||
@@ -2216,23 +2215,19 @@
|
||||
FT_Bool reexecute = FALSE;
|
||||
|
||||
|
||||
if ( size->bytecode_ready < 0 || size->cvt_ready < 0 )
|
||||
if ( size->bytecode_ready > 0 )
|
||||
return size->bytecode_ready;
|
||||
if ( size->bytecode_ready < 0 )
|
||||
{
|
||||
error = tt_size_ready_bytecode( size, pedantic );
|
||||
FT_Bool pedantic = FT_BOOL( load_flags & FT_LOAD_PEDANTIC );
|
||||
|
||||
|
||||
error = tt_size_init_bytecode( size, pedantic );
|
||||
if ( error )
|
||||
return error;
|
||||
}
|
||||
else if ( size->bytecode_ready )
|
||||
return size->bytecode_ready;
|
||||
else if ( size->cvt_ready )
|
||||
return size->cvt_ready;
|
||||
|
||||
/* query new execution context */
|
||||
exec = size->context;
|
||||
if ( !exec )
|
||||
return FT_THROW( Could_Not_Find_Context );
|
||||
|
||||
exec->pedantic_hinting = pedantic;
|
||||
|
||||
grayscale = FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
|
||||
FT_RENDER_MODE_MONO );
|
||||
@@ -2295,9 +2290,11 @@
|
||||
reexecute = TRUE;
|
||||
}
|
||||
|
||||
if ( reexecute )
|
||||
if ( size->cvt_ready > 0 )
|
||||
return size->cvt_ready;
|
||||
if ( size->cvt_ready < 0 || reexecute )
|
||||
{
|
||||
error = tt_size_run_prep( size, pedantic );
|
||||
error = tt_size_run_prep( size );
|
||||
if ( error )
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -880,8 +880,7 @@
|
||||
* FreeType error code. 0 means success.
|
||||
*/
|
||||
FT_LOCAL_DEF( FT_Error )
|
||||
tt_size_run_fpgm( TT_Size size,
|
||||
FT_Bool pedantic )
|
||||
tt_size_run_fpgm( TT_Size size )
|
||||
{
|
||||
TT_Face face = (TT_Face)size->root.face;
|
||||
TT_ExecContext exec;
|
||||
@@ -894,8 +893,6 @@
|
||||
if ( error )
|
||||
return error;
|
||||
|
||||
exec->pedantic_hinting = pedantic;
|
||||
|
||||
/* disable CVT and glyph programs coderange */
|
||||
TT_Clear_CodeRange( exec, tt_coderange_cvt );
|
||||
TT_Clear_CodeRange( exec, tt_coderange_glyph );
|
||||
@@ -947,8 +944,7 @@
|
||||
* FreeType error code. 0 means success.
|
||||
*/
|
||||
FT_LOCAL_DEF( FT_Error )
|
||||
tt_size_run_prep( TT_Size size,
|
||||
FT_Bool pedantic )
|
||||
tt_size_run_prep( TT_Size size )
|
||||
{
|
||||
TT_Face face = (TT_Face)size->root.face;
|
||||
TT_ExecContext exec;
|
||||
@@ -987,8 +983,6 @@
|
||||
if ( error )
|
||||
return error;
|
||||
|
||||
exec->pedantic_hinting = pedantic;
|
||||
|
||||
TT_Clear_CodeRange( exec, tt_coderange_glyph );
|
||||
|
||||
if ( face->cvt_program_size > 0 )
|
||||
@@ -1020,11 +1014,10 @@
|
||||
|
||||
|
||||
static void
|
||||
tt_size_done_bytecode( FT_Size ftsize )
|
||||
tt_size_done_bytecode( TT_Size size )
|
||||
{
|
||||
TT_Size size = (TT_Size)ftsize;
|
||||
TT_Face face = (TT_Face)ftsize->face;
|
||||
FT_Memory memory = face->root.memory;
|
||||
FT_Memory memory = size->root.face->memory;
|
||||
|
||||
|
||||
if ( size->context )
|
||||
{
|
||||
@@ -1052,25 +1045,22 @@
|
||||
|
||||
size->max_func = 0;
|
||||
size->max_ins = 0;
|
||||
|
||||
size->bytecode_ready = -1;
|
||||
size->cvt_ready = -1;
|
||||
}
|
||||
|
||||
|
||||
/* Initialize bytecode-related fields in the size object. */
|
||||
/* We do this only if bytecode interpretation is really needed. */
|
||||
static FT_Error
|
||||
tt_size_init_bytecode( FT_Size ftsize,
|
||||
tt_size_init_bytecode( TT_Size size,
|
||||
FT_Bool pedantic )
|
||||
{
|
||||
FT_Error error;
|
||||
TT_Size size = (TT_Size)ftsize;
|
||||
TT_Face face = (TT_Face)ftsize->face;
|
||||
FT_Memory memory = face->root.memory;
|
||||
TT_Face face = (TT_Face)size->root.face;
|
||||
FT_Memory memory = size->root.face->memory;
|
||||
|
||||
FT_UShort n_twilight;
|
||||
TT_MaxProfile* maxp = &face->max_profile;
|
||||
TT_ExecContext exec = size->context;
|
||||
|
||||
|
||||
/* clean up bytecode related data */
|
||||
@@ -1078,15 +1068,17 @@
|
||||
FT_FREE( size->instruction_defs );
|
||||
FT_FREE( size->cvt );
|
||||
FT_FREE( size->storage );
|
||||
|
||||
if ( size->context )
|
||||
TT_Done_Context( size->context );
|
||||
tt_glyphzone_done( memory, &size->twilight );
|
||||
|
||||
size->bytecode_ready = -1;
|
||||
size->cvt_ready = -1;
|
||||
if ( exec )
|
||||
TT_Done_Context( exec );
|
||||
|
||||
size->context = TT_New_Context( (TT_Driver)face->root.driver );
|
||||
exec = TT_New_Context( (TT_Driver)face->root.driver );
|
||||
if ( !exec )
|
||||
return FT_THROW( Could_Not_Find_Context );
|
||||
|
||||
exec->pedantic_hinting = pedantic;
|
||||
size->context = exec;
|
||||
|
||||
size->max_function_defs = maxp->maxFunctionDefs;
|
||||
size->max_instruction_defs = maxp->maxInstructionDefs;
|
||||
@@ -1097,6 +1089,7 @@
|
||||
size->max_func = 0;
|
||||
size->max_ins = 0;
|
||||
|
||||
size->cvt_ready = -1;
|
||||
size->cvt_size = face->cvt_size;
|
||||
size->storage_size = maxp->maxStorage;
|
||||
|
||||
@@ -1149,41 +1142,17 @@
|
||||
/* to be executed just once; calling it again is completely useless */
|
||||
/* and might even lead to extremely slow behaviour if it is malformed */
|
||||
/* (containing an infinite loop, for example). */
|
||||
error = tt_size_run_fpgm( size, pedantic );
|
||||
error = tt_size_run_fpgm( size );
|
||||
return error;
|
||||
|
||||
Exit:
|
||||
if ( error )
|
||||
tt_size_done_bytecode( ftsize );
|
||||
tt_size_done_bytecode( size );
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
FT_LOCAL_DEF( FT_Error )
|
||||
tt_size_ready_bytecode( TT_Size size,
|
||||
FT_Bool pedantic )
|
||||
{
|
||||
FT_Error error = FT_Err_Ok;
|
||||
|
||||
|
||||
if ( size->bytecode_ready < 0 )
|
||||
error = tt_size_init_bytecode( (FT_Size)size, pedantic );
|
||||
else
|
||||
error = size->bytecode_ready;
|
||||
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
if ( size->cvt_ready < 0 )
|
||||
error = tt_size_run_prep( size, pedantic );
|
||||
else
|
||||
error = size->cvt_ready;
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
#endif /* TT_USE_BYTECODE_INTERPRETER */
|
||||
|
||||
|
||||
@@ -1211,7 +1180,6 @@
|
||||
|
||||
#ifdef TT_USE_BYTECODE_INTERPRETER
|
||||
size->bytecode_ready = -1;
|
||||
size->cvt_ready = -1;
|
||||
#endif
|
||||
|
||||
size->ttmetrics.valid = FALSE;
|
||||
@@ -1240,7 +1208,7 @@
|
||||
|
||||
|
||||
#ifdef TT_USE_BYTECODE_INTERPRETER
|
||||
tt_size_done_bytecode( ttsize );
|
||||
tt_size_done_bytecode( size );
|
||||
#endif
|
||||
|
||||
size->ttmetrics.valid = FALSE;
|
||||
|
||||
@@ -377,16 +377,14 @@ FT_BEGIN_HEADER
|
||||
#ifdef TT_USE_BYTECODE_INTERPRETER
|
||||
|
||||
FT_LOCAL( FT_Error )
|
||||
tt_size_run_fpgm( TT_Size size,
|
||||
FT_Bool pedantic );
|
||||
tt_size_run_fpgm( TT_Size size );
|
||||
|
||||
FT_LOCAL( FT_Error )
|
||||
tt_size_run_prep( TT_Size size,
|
||||
FT_Bool pedantic );
|
||||
tt_size_run_prep( TT_Size size );
|
||||
|
||||
FT_LOCAL( FT_Error )
|
||||
tt_size_ready_bytecode( TT_Size size,
|
||||
FT_Bool pedantic );
|
||||
tt_size_init_bytecode( TT_Size size,
|
||||
FT_Bool pedantic );
|
||||
|
||||
#endif /* TT_USE_BYTECODE_INTERPRETER */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user