Home | History | Annotate | Download | only in cache

Lines Matching refs:cache

5 /*    The FreeType internal cache interface (body).                        */
42 /***** CACHE NODE DEFINITIONS *****/
87 /* get a top bucket for specified hash from cache,
88 * body for FTC_NODE_TOP_FOR_HASH( cache, hash )
91 ftc_get_top_node_for_hash( FTC_Cache cache,
98 idx = hash & cache->mask;
99 if ( idx < cache->p )
100 idx = hash & ( 2 * cache->mask + 1 );
101 pnode = cache->buckets + idx;
113 ftc_cache_resize( FTC_Cache cache )
118 FT_UFast p = cache->p;
119 FT_UFast mask = cache->mask;
124 if ( cache->slack < 0 )
134 FT_Memory memory = cache->memory;
139 if ( FT_RENEW_ARRAY( cache->buckets,
145 pnode = cache->buckets + p;
163 cache->buckets[p + mask + 1] = new_list;
165 cache->slack += FTC_HASH_MAX_LOAD;
169 cache->mask = 2 * mask + 1;
170 cache->p = 0;
173 cache->p = p + 1;
177 else if ( cache->slack > (FT_Long)count * FTC_HASH_SUB_LOAD )
188 FT_Memory memory = cache->memory;
193 if ( FT_RENEW_ARRAY( cache->buckets,
197 cache->mask >>= 1;
198 p = cache->mask;
203 pnode = cache->buckets + p;
207 pold = cache->buckets + old_index;
211 cache->slack -= FTC_HASH_MAX_LOAD;
212 cache->p = p;
222 /* remove a node from its cache's hash table */
225 FTC_Cache cache )
227 FTC_Node *pnode = FTC_NODE_TOP_FOR_HASH( cache, node0->hash );
250 cache->slack++;
251 ftc_cache_resize( cache );
255 /* add a node to the `top' of its cache's hash table */
258 FTC_Cache cache )
260 FTC_Node *pnode = FTC_NODE_TOP_FOR_HASH( cache, node->hash );
266 cache->slack--;
267 ftc_cache_resize( cache );
271 /* remove a node from the cache manager */
276 FTC_Cache cache;
280 /* find node's cache */
288 cache = manager->caches[node->cache_index];
291 if ( !cache )
298 manager->cur_weight -= cache->clazz.node_weight( node, cache );
303 /* remove node from cache's hash table */
304 ftc_node_hash_unlink( node, cache );
307 cache->clazz.node_free( node, cache );
312 FT_TRACE0(( "ftc_node_destroy: invalid cache node count (%d)\n",
321 /***** ABSTRACT CACHE CLASS *****/
328 FTC_Cache_Init( FTC_Cache cache )
330 return ftc_cache_init( cache );
335 ftc_cache_init( FTC_Cache cache )
337 FT_Memory memory = cache->memory;
341 cache->p = 0;
342 cache->mask = FTC_HASH_INITIAL_SIZE - 1;
343 cache->slack = FTC_HASH_INITIAL_SIZE * FTC_HASH_MAX_LOAD;
345 (void)FT_NEW_ARRAY( cache->buckets, FTC_HASH_INITIAL_SIZE * 2 );
351 FTC_Cache_Clear( FTC_Cache cache )
353 if ( cache && cache->buckets )
355 FTC_Manager manager = cache->manager;
360 count = cache->p + cache->mask + 1;
364 FTC_Node *pnode = cache->buckets + i, next, node = *pnode;
376 manager->cur_weight -= cache->clazz.node_weight( node, cache );
378 cache->clazz.node_free( node, cache );
381 cache->buckets[i] = NULL;
383 ftc_cache_resize( cache );
389 ftc_cache_done( FTC_Cache cache )
391 if ( cache->memory )
393 FT_Memory memory = cache->memory;
396 FTC_Cache_Clear( cache );
398 FT_FREE( cache->buckets );
399 cache->mask = 0;
400 cache->p = 0;
401 cache->slack = 0;
403 cache->memory = NULL;
409 FTC_Cache_Done( FTC_Cache cache )
411 ftc_cache_done( cache );
416 ftc_cache_add( FTC_Cache cache,
421 node->cache_index = (FT_UInt16)cache->index;
424 ftc_node_hash_link( node, cache );
425 ftc_node_mru_link( node, cache->manager );
428 FTC_Manager manager = cache->manager;
431 manager->cur_weight += cache->clazz.node_weight( node, cache );
444 FTC_Cache_NewNode( FTC_Cache cache,
455 * errors (OOM) correctly, i.e., by flushing the cache progressively
459 FTC_CACHE_TRYLOOP( cache )
461 error = cache->clazz.node_new( &node, query, cache );
469 /* don't assume that the cache has the same number of buckets, since
470 * our allocation request might have triggered global cache flushing
472 ftc_cache_add( cache, hash, node );
483 FTC_Cache_Lookup( FTC_Cache cache,
494 FTC_Node_CompareFunc compare = cache->clazz.node_compare;
497 if ( !cache || !anode )
501 bucket = pnode = FTC_NODE_TOP_FOR_HASH( cache, hash );
512 compare( node, query, cache, &list_changed ) )
521 bucket = pnode = FTC_NODE_TOP_FOR_HASH( cache, hash );
546 FTC_Manager manager = cache->manager;
557 return FTC_Cache_NewNode( cache, hash, query, anode );
564 FTC_Cache_RemoveFaceID( FTC_Cache cache,
568 FTC_Manager manager = cache->manager;
572 count = cache->p + cache->mask + 1;
575 FTC_Node* bucket = cache->buckets + i;
588 if ( cache->clazz.node_remove_faceid( node, face_id,
589 cache, &list_changed ) )
609 manager->cur_weight -= cache->clazz.node_weight( node, cache );
612 cache->clazz.node_free( node, cache );
614 cache->slack++;
617 ftc_cache_resize( cache );