20 #ifndef __FTCCACHE_H__
21 #define __FTCCACHE_H__
28 #define _FTC_FACE_ID_HASH( i ) \
29 ((FT_PtrDist)(( (FT_PtrDist)(i) >> 3 ) ^ ( (FT_PtrDist)(i) << 7 )))
70 #define FTC_NODE( x ) ( (FTC_Node)(x) )
71 #define FTC_NODE_P( x ) ( (FTC_Node*)(x) )
73 #define FTC_NODE__NEXT( x ) FTC_NODE( (x)->mru.next )
74 #define FTC_NODE__PREV( x ) FTC_NODE( (x)->mru.prev )
77 #define FTC_NODE__TOP_FOR_HASH( cache, hash ) \
78 ( ( cache )->buckets + \
79 ( ( ( ( hash ) & ( cache )->mask ) < ( cache )->p ) \
80 ? ( ( hash ) & ( ( cache )->mask * 2 + 1 ) ) \
81 : ( ( hash ) & ( cache )->mask ) ) )
84 ftc_get_top_node_for_hash( FTC_Cache cache,
86 #define FTC_NODE__TOP_FOR_HASH( cache, hash ) \
87 ftc_get_top_node_for_hash( ( cache ), ( hash ) )
90 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
168 #define FTC_CACHE( x ) ( (FTC_Cache)(x) )
169 #define FTC_CACHE_P( x ) ( (FTC_Cache*)(x) )
188 FTC_Cache_Lookup( FTC_Cache cache,
217 #define FTC_CACHE_LOOKUP_CMP( cache, nodecmp, hash, query, node, error ) \
219 FTC_Node *_bucket, *_pnode, _node; \
220 FTC_Cache _cache = FTC_CACHE(cache); \
221 FT_PtrDist _hash = (FT_PtrDist)(hash); \
222 FTC_Node_CompareFunc _nodcomp = (FTC_Node_CompareFunc)(nodecmp); \
223 FT_Bool _list_changed = FALSE; \
226 error = FTC_Err_Ok; \
230 _bucket = _pnode = FTC_NODE__TOP_FOR_HASH( _cache, _hash ); \
237 if ( _node == NULL ) \
240 if ( _node->hash == _hash && \
241 _nodcomp( _node, query, _cache, &_list_changed ) ) \
244 _pnode = &_node->link; \
247 if ( _list_changed ) \
250 _bucket = _pnode = FTC_NODE__TOP_FOR_HASH( _cache, _hash ); \
253 while ( *_pnode != _node ) \
255 if ( *_pnode == NULL ) \
257 FT_ERROR(( "FTC_CACHE_LOOKUP_CMP: oops!!! node missing\n" )); \
261 _pnode = &((*_pnode)->link); \
266 if ( _node != *_bucket ) \
268 *_pnode = _node->link; \
269 _node->link = *_bucket; \
275 FTC_Manager _manager = _cache->manager; \
276 void* _nl = &_manager->nodes_list; \
279 if ( _node != _manager->nodes_list ) \
280 FTC_MruNode_Up( (FTC_MruNode*)_nl, \
281 (FTC_MruNode)_node ); \
286 error = FTC_Cache_NewNode( _cache, _hash, query, &_node ); \
294 #define FTC_CACHE_LOOKUP_CMP( cache, nodecmp, hash, query, node, error ) \
296 error = FTC_Cache_Lookup( FTC_CACHE( cache ), hash, query, \
297 (FTC_Node*)&(node) ); \
319 #define FTC_CACHE_TRYLOOP( cache ) \
321 FTC_Manager _try_manager = FTC_CACHE( cache )->manager; \
322 FT_UInt _try_count = 4; \
330 #define FTC_CACHE_TRYLOOP_END( list_changed ) \
331 if ( !error || error != FTC_Err_Out_Of_Memory ) \
334 _try_done = FTC_Manager_FlushN( _try_manager, _try_count ); \
335 if ( _try_done > 0 && ( list_changed ) ) \
336 *(FT_Bool*)( list_changed ) = TRUE; \
338 if ( _try_done == 0 ) \
341 if ( _try_done == _try_count ) \
344 if ( _try_count < _try_done || \
345 _try_count > _try_manager->num_nodes ) \
346 _try_count = _try_manager->num_nodes; \
FT_Error(* FTC_Cache_InitFunc)(FTC_Cache cache)
GLvoid **typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
FT_Error(* FTC_Node_NewFunc)(FTC_Node *pnode, FT_Pointer query, FTC_Cache cache)
FT_BEGIN_HEADER typedef FT_Pointer FTC_FaceID
FTC_Cache_DoneFunc cache_done
FT_BEGIN_HEADER typedef unsigned char FT_Bool
FTC_Node_FreeFunc node_free
void(* FTC_Cache_DoneFunc)(FTC_Cache cache)
FTC_Cache_Done(FTC_Cache cache)
FTC_Cache_NewNode(FTC_Cache cache, FT_PtrDist hash, FT_Pointer query, FTC_Node *anode)
FTC_Node_CompareFunc node_compare
FTC_Node_WeightFunc node_weight
FT_Offset(* FTC_Node_WeightFunc)(FTC_Node node, FTC_Cache cache)
struct FTC_CacheClassRec_ * FTC_CacheClass
struct FTC_CacheClassRec_ FTC_CacheClassRec
ftc_node_destroy(FTC_Node node, FTC_Manager manager)
struct FTC_CacheRec_ * FTC_Cache
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
struct FTC_CacheRec_ FTC_CacheRec
FTC_Cache_RemoveFaceID(FTC_Cache cache, FTC_FaceID face_id)
FTC_Node_NewFunc node_new
FTC_Node_CompareFunc node_remove_faceid
FTC_Cache_InitFunc cache_init
FTC_Cache_Init(FTC_Cache cache)
FT_Bool(* FTC_Node_CompareFunc)(FTC_Node node, FT_Pointer key, FTC_Cache cache, FT_Bool *list_changed)
struct FTC_NodeRec_ FTC_NodeRec
void(* FTC_Node_FreeFunc)(FTC_Node node, FTC_Cache cache)