27#define FTC_FACE_ID_HASH( i ) \
28 ( ( (FT_Offset)(i) >> 3 ) ^ ( (FT_Offset)(i) << 7 ) )
69#define FTC_NODE( x ) ( (FTC_Node)(x) )
70#define FTC_NODE_P( x ) ( (FTC_Node*)(x) )
72#define FTC_NODE_NEXT( x ) FTC_NODE( (x)->mru.next )
73#define FTC_NODE_PREV( x ) FTC_NODE( (x)->mru.prev )
76#define FTC_NODE_TOP_FOR_HASH( cache, hash ) \
77 ( ( cache )->buckets + \
78 ( ( ( ( hash ) & ( cache )->mask ) < ( cache )->p ) \
79 ? ( ( hash ) & ( ( cache )->mask * 2 + 1 ) ) \
80 : ( ( hash ) & ( cache )->mask ) ) )
85#define FTC_NODE_TOP_FOR_HASH( cache, hash ) \
86 ftc_get_top_node_for_hash( ( cache ), ( hash ) )
161#define FTC_CACHE( x ) ( (FTC_Cache)(x) )
162#define FTC_CACHE_P( x ) ( (FTC_Cache*)(x) )
210#define FTC_CACHE_LOOKUP_CMP( cache, nodecmp, hash, query, node, error ) \
212 FTC_Node *_bucket, *_pnode, _node; \
213 FTC_Cache _cache = FTC_CACHE(cache); \
214 FT_Offset _hash = (FT_Offset)(hash); \
215 FTC_Node_CompareFunc _nodcomp = (FTC_Node_CompareFunc)(nodecmp); \
216 FT_Bool _list_changed = FALSE; \
223 _bucket = _pnode = FTC_NODE_TOP_FOR_HASH( _cache, _hash ); \
233 if ( _node->hash == _hash && \
234 _nodcomp( _node, query, _cache, &_list_changed ) ) \
237 _pnode = &_node->link; \
240 if ( _list_changed ) \
243 _bucket = _pnode = FTC_NODE_TOP_FOR_HASH( _cache, _hash ); \
246 while ( *_pnode != _node ) \
250 FT_ERROR(( "FTC_CACHE_LOOKUP_CMP: oops!!! node missing\n" )); \
254 _pnode = &((*_pnode)->link); \
259 if ( _node != *_bucket ) \
261 *_pnode = _node->link; \
262 _node->link = *_bucket; \
268 FTC_Manager _manager = _cache->manager; \
269 void* _nl = &_manager->nodes_list; \
272 if ( _node != _manager->nodes_list ) \
273 FTC_MruNode_Up( (FTC_MruNode*)_nl, \
274 (FTC_MruNode)_node ); \
279 error = FTC_Cache_NewNode( _cache, _hash, query, &_node ); \
287#define FTC_CACHE_LOOKUP_CMP( cache, nodecmp, hash, query, node, error ) \
289 error = FTC_Cache_Lookup( FTC_CACHE( cache ), hash, query, \
290 (FTC_Node*)&(node) ); \
312#define FTC_CACHE_TRYLOOP( cache ) \
314 FTC_Manager _try_manager = FTC_CACHE( cache )->manager; \
315 FT_UInt _try_count = 4; \
323#define FTC_CACHE_TRYLOOP_END( list_changed ) \
324 if ( !error || FT_ERR_NEQ( error, Out_Of_Memory ) ) \
327 _try_done = FTC_Manager_FlushN( _try_manager, _try_count ); \
328 if ( _try_done > 0 && list_changed != NULL ) \
329 *(FT_Bool*)( list_changed ) = TRUE; \
331 if ( _try_done == 0 ) \
334 if ( _try_done == _try_count ) \
337 if ( _try_count < _try_done || \
338 _try_count > _try_manager->num_nodes ) \
339 _try_count = _try_manager->num_nodes; \
FT_BEGIN_HEADER typedef FT_Pointer FTC_FaceID
struct FTC_CacheRec_ FTC_CacheRec
FTC_Cache_NewNode(FTC_Cache cache, FT_Offset hash, FT_Pointer query, FTC_Node *anode)
struct FTC_CacheRec_ * FTC_Cache
FT_Error(* FTC_Node_NewFunc)(FTC_Node *pnode, FT_Pointer query, FTC_Cache cache)
FTC_Cache_Done(FTC_Cache cache)
void(* FTC_Node_FreeFunc)(FTC_Node node, FTC_Cache cache)
FT_Error(* FTC_Cache_InitFunc)(FTC_Cache cache)
const struct FTC_CacheClassRec_ * FTC_CacheClass
struct FTC_CacheClassRec_ FTC_CacheClassRec
FT_Offset(* FTC_Node_WeightFunc)(FTC_Node node, FTC_Cache cache)
struct FTC_NodeRec_ FTC_NodeRec
FT_Bool(* FTC_Node_CompareFunc)(FTC_Node node, FT_Pointer key, FTC_Cache cache, FT_Bool *list_changed)
FTC_Cache_Init(FTC_Cache cache)
void(* FTC_Cache_DoneFunc)(FTC_Cache cache)
FTC_Cache_RemoveFaceID(FTC_Cache cache, FTC_FaceID face_id)
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
FT_BEGIN_HEADER typedef unsigned char FT_Bool
FTC_Cache_DoneFunc cache_done
FTC_Node_CompareFunc node_remove_faceid
FTC_Node_WeightFunc node_weight
FTC_Node_FreeFunc node_free
FTC_Cache_InitFunc cache_init
FTC_Node_NewFunc node_new
FTC_Node_CompareFunc node_compare