diff --git a/ChangeLog b/ChangeLog index fbd83bce8..88606cf2b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,12 @@ slot->metrics.width and slot->metrics.height when loading a Windows FNT glyph. Thanks to Huw Davies + * include/freetype/cache/ftcmru.h, src/cache/ftcbasic.c, + src/cache/ftccache.c, src/cache/ftcglyph.c, src/cache/ftcmanag.c, + src/cache/ftcsbits.c: + fixing some annoying bugs and inefficiencies in the cache sub-system. + + 2004-06-05 Werner Lemberg * src/autofit/afloader.c (af_loader_load_g): Set `lsb_delta' and diff --git a/include/freetype/cache/ftcmru.h b/include/freetype/cache/ftcmru.h index 9556f58e7..d70c5cce7 100644 --- a/include/freetype/cache/ftcmru.h +++ b/include/freetype/cache/ftcmru.h @@ -86,7 +86,7 @@ FT_BEGIN_HEADER typedef struct FTC_MruListClassRec_ const * FTC_MruListClass; - typedef FT_Int + typedef FT_Bool (*FTC_MruNode_CompareFunc)( FTC_MruNode node, FT_Pointer key ); @@ -154,7 +154,7 @@ FT_BEGIN_HEADER FTC_MruList_Lookup( FTC_MruList list, FT_Pointer key, FTC_MruNode *pnode ); - + FT_EXPORT( void ) FTC_MruList_Remove( FTC_MruList list, @@ -208,7 +208,7 @@ FT_BEGIN_HEADER #else /* !FTC_INLINE */ #define FTC_MRULIST_LOOKUP( list, key, node, error ) \ - error = FTC_MruList_Lookup( (list), (key), (FTC_MruNode*)&(node) ) + error = FTC_MruList_Lookup( (list), (key), (FTC_MruNode*)&(node) ) #endif /* !FTC_INLINE */ diff --git a/src/cache/ftcbasic.c b/src/cache/ftcbasic.c index a9b66dc21..9a91f357b 100644 --- a/src/cache/ftcbasic.c +++ b/src/cache/ftcbasic.c @@ -62,7 +62,7 @@ } FTC_BasicFamilyRec, *FTC_BasicFamily; - FT_CALLBACK_DEF( FT_Int ) + FT_CALLBACK_DEF( FT_Bool ) ftc_basic_family_compare( FTC_MruNode ftcfamily, FT_Pointer ftcquery ) { diff --git a/src/cache/ftccache.c b/src/cache/ftccache.c index 2b6bee9cf..3a8a40c00 100644 --- a/src/cache/ftccache.c +++ b/src/cache/ftccache.c @@ -303,6 +303,13 @@ FT_EXPORT_DEF( FT_Error ) FTC_Cache_Init( FTC_Cache cache ) + { + return ftc_cache_init( cache ); + } + + + FT_LOCAL_DEF( FT_Error ) + ftc_cache_init( FTC_Cache cache ) { FT_Memory memory = cache->memory; @@ -315,13 +322,6 @@ } - FT_LOCAL_DEF( FT_Error ) - ftc_cache_init( FTC_Cache cache ) - { - return FTC_Cache_Init( cache ); - } - - FT_EXPORT_DEF( void ) FTC_Cache_Clear( FTC_Cache cache ) { @@ -360,8 +360,8 @@ } - FT_EXPORT_DEF( void ) - FTC_Cache_Done( FTC_Cache cache ) + FT_LOCAL_DEF( void ) + ftc_cache_done( FTC_Cache cache ) { if ( cache->memory ) { @@ -380,10 +380,10 @@ } - FT_LOCAL_DEF( void ) - ftc_cache_done( FTC_Cache cache ) + FT_EXPORT_DEF( void ) + FTC_Cache_Done( FTC_Cache cache ) { - FTC_Cache_Done( cache ); + ftc_cache_done( cache ); } diff --git a/src/cache/ftcglyph.c b/src/cache/ftcglyph.c index edcd36d53..547e3d12b 100644 --- a/src/cache/ftcglyph.c +++ b/src/cache/ftcglyph.c @@ -64,15 +64,6 @@ } - FT_EXPORT_DEF( FT_Bool ) - FTC_GNode_Compare( FTC_GNode gnode, - FTC_GQuery gquery ) - { - return FT_BOOL( gnode->family == gquery->family && - gnode->gindex == gquery->gindex ); - } - - FT_LOCAL_DEF( FT_Bool ) ftc_gnode_compare( FTC_Node ftcgnode, FT_Pointer ftcgquery, @@ -82,8 +73,16 @@ FTC_GQuery gquery = (FTC_GQuery)ftcgquery; FT_UNUSED( cache ); + return FT_BOOL( gnode->family == gquery->family && + gnode->gindex == gquery->gindex ); + } - return FTC_GNode_Compare( gnode, gquery ); + + FT_EXPORT_DEF( FT_Bool ) + FTC_GNode_Compare( FTC_GNode gnode, + FTC_GQuery gquery ) + { + return ftc_gnode_compare( FTC_NODE(gnode), gquery, NULL ); } @@ -108,10 +107,11 @@ } - FT_EXPORT_DEF( FT_Error ) - FTC_GCache_Init( FTC_GCache cache ) + FT_LOCAL_DEF( FT_Error ) + ftc_gcache_init( FTC_Cache ftccache ) { - FT_Error error; + FTC_GCache cache = (FTC_GCache)ftccache; + FT_Error error; error = FTC_Cache_Init( FTC_CACHE( cache ) ); if ( !error ) @@ -129,21 +129,17 @@ } - FT_LOCAL_DEF( FT_Error ) - ftc_gcache_init( FTC_Cache ftccache ) + FT_EXPORT_DEF( FT_Error ) + FTC_GCache_Init( FTC_GCache cache ) { - FTC_GCache cache = (FTC_GCache)ftccache; - - - return FTC_GCache_Init( cache ); + return ftc_gcache_init( FTC_CACHE(cache) ); } FT_EXPORT_DEF( void ) FTC_GCache_Done( FTC_GCache cache ) { - FTC_Cache_Done( (FTC_Cache)cache ); - FTC_MruList_Done( &cache->families ); + return ftc_gcache_done( FTC_CACHE(cache) ); } @@ -153,7 +149,8 @@ FTC_GCache cache = (FTC_GCache)ftccache; - FTC_GCache_Done( cache ); + FTC_Cache_Done( (FTC_Cache)cache ); + FTC_MruList_Done( &cache->families ); } diff --git a/src/cache/ftcimage.c b/src/cache/ftcimage.c index 29f328886..ab147a556 100644 --- a/src/cache/ftcimage.c +++ b/src/cache/ftcimage.c @@ -26,10 +26,11 @@ /* finalize a given glyph image node */ - FT_EXPORT_DEF( void ) - FTC_INode_Free( FTC_INode inode, + FT_LOCAL_DEF( void ) + ftc_inode_free( FTC_Node ftcinode, FTC_Cache cache ) { + FTC_INode inode = (FTC_INode)ftcinode; FT_Memory memory = cache->memory; @@ -44,14 +45,13 @@ } - FT_LOCAL_DEF( void ) - ftc_inode_free( FTC_Node ftcinode, + + + FT_EXPORT_DEF( void ) + FTC_INode_Free( FTC_INode inode, FTC_Cache cache ) { - FTC_INode inode = (FTC_INode)ftcinode; - - - FTC_INode_Free( inode, cache ); + ftc_inode_free( FTC_NODE(inode), cache ); } @@ -100,12 +100,15 @@ } - FT_EXPORT_DEF( FT_ULong ) - FTC_INode_Weight( FTC_INode inode ) + FT_LOCAL_DEF( FT_ULong ) + ftc_inode_weight( FTC_Node ftcinode, + FTC_Cache ftccache ) { - FT_ULong size = 0; - FT_Glyph glyph = inode->glyph; + FTC_INode inode = (FTC_INode)ftcinode; + FT_ULong size = 0; + FT_Glyph glyph = inode->glyph; + FT_UNUSED(ftccache); switch ( glyph->format ) { @@ -142,15 +145,12 @@ } - FT_LOCAL_DEF( FT_ULong ) - ftc_inode_weight( FTC_Node ftcinode, - FTC_Cache ftccache ) + + + FT_EXPORT_DEF( FT_ULong ) + FTC_INode_Weight( FTC_INode inode ) { - FTC_INode inode = (FTC_INode)ftcinode; - FT_UNUSED( ftccache ); - - - return FTC_INode_Weight( inode ); + return ftc_inode_weight( FTC_NODE(inode), NULL ); } diff --git a/src/cache/ftcmanag.c b/src/cache/ftcmanag.c index 1f83a9282..97d324c61 100644 --- a/src/cache/ftcmanag.c +++ b/src/cache/ftcmanag.c @@ -92,7 +92,7 @@ } - FT_CALLBACK_DEF( FT_Int ) + FT_CALLBACK_DEF( FT_Bool ) ftc_size_node_compare( FTC_MruNode ftcnode, FT_Pointer ftcscaler ) { @@ -156,7 +156,7 @@ /* helper function used by ftc_face_node_done */ - static FT_Int + static FT_Bool ftc_size_node_compare_faceid( FTC_MruNode ftcnode, FT_Pointer ftcface_id ) { @@ -269,7 +269,7 @@ } - FT_CALLBACK_DEF( FT_Int ) + FT_CALLBACK_DEF( FT_Bool ) ftc_face_node_compare( FTC_MruNode ftcnode, FT_Pointer ftcface_id ) { diff --git a/src/cache/ftcsbits.c b/src/cache/ftcsbits.c index 68bab08cd..a19d61f0e 100644 --- a/src/cache/ftcsbits.c +++ b/src/cache/ftcsbits.c @@ -58,10 +58,11 @@ } - FT_EXPORT_DEF( void ) - FTC_SNode_Free( FTC_SNode snode, + FT_LOCAL_DEF( void ) + ftc_snode_free( FTC_Node ftcsnode, FTC_Cache cache ) { + FTC_SNode snode = (FTC_SNode)ftcsnode; FTC_SBit sbit = snode->sbits; FT_UInt count = snode->count; FT_Memory memory = cache->memory; @@ -76,14 +77,13 @@ } - FT_LOCAL_DEF( void ) - ftc_snode_free( FTC_Node ftcsnode, + + + FT_EXPORT_DEF( void ) + FTC_SNode_Free( FTC_SNode snode, FTC_Cache cache ) { - FTC_SNode snode = (FTC_SNode)ftcsnode; - - - FTC_SNode_Free( snode, cache ); + ftc_snode_free( FTC_NODE(snode), cache ); } @@ -255,14 +255,17 @@ } - FT_EXPORT_DEF( FT_ULong ) - FTC_SNode_Weight( FTC_SNode snode ) + FT_LOCAL_DEF( FT_ULong ) + ftc_snode_weight( FTC_Node ftcsnode, + FTC_Cache cache ) { + FTC_SNode snode = (FTC_SNode)ftcsnode; FT_UInt count = snode->count; FTC_SBit sbit = snode->sbits; FT_Int pitch; FT_ULong size; + FT_UNUSED( cache ); FT_ASSERT( snode->count <= FTC_SBIT_ITEMS_PER_NODE ); @@ -286,26 +289,23 @@ } - FT_LOCAL_DEF( FT_ULong ) - ftc_snode_weight( FTC_Node ftcsnode, - FTC_Cache cache ) + FT_EXPORT_DEF( FT_ULong ) + FTC_SNode_Weight( FTC_SNode snode ) { - FTC_SNode snode = (FTC_SNode)ftcsnode; - FT_UNUSED( cache ); - - - return FTC_SNode_Weight( snode ); + return ftc_snode_weight( FTC_NODE(snode), NULL ); } - FT_EXPORT_DEF( FT_Bool ) - FTC_SNode_Compare( FTC_SNode snode, - FTC_GQuery gquery, + FT_LOCAL_DEF( FT_Bool ) + ftc_snode_compare( FTC_Node ftcsnode, + FT_Pointer ftcgquery, FTC_Cache cache ) { - FTC_GNode gnode = FTC_GNODE( snode ); - FT_UInt gindex = gquery->gindex; - FT_Bool result; + FTC_SNode snode = (FTC_SNode)ftcsnode; + FTC_GQuery gquery = (FTC_GQuery)ftcgquery; + FTC_GNode gnode = FTC_GNODE( snode ); + FT_UInt gindex = gquery->gindex; + FT_Bool result; result = FT_BOOL( gnode->family == gquery->family && @@ -333,16 +333,14 @@ } - FT_LOCAL_DEF( FT_Bool ) - ftc_snode_compare( FTC_Node ftcsnode, - FT_Pointer ftcgquery, + + + FT_EXPORT_DEF( FT_Bool ) + FTC_SNode_Compare( FTC_SNode snode, + FTC_GQuery gquery, FTC_Cache cache ) { - FTC_SNode snode = (FTC_SNode)ftcsnode; - FTC_GQuery gquery = (FTC_GQuery)ftcgquery; - - - return FTC_SNode_Compare( snode, gquery, cache ); + return ftc_snode_compare( FTC_NODE(snode), gquery, cache ); }