#include "ftcmanag.h"
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/ftdebug.h>
#include "ftccback.h"
#include "ftcerror.h"
#undef FT_COMPONENT
#define FT_COMPONENT …
#define FTC_HASH_MAX_LOAD …
#define FTC_HASH_MIN_LOAD …
#define FTC_HASH_SUB_LOAD …
#define FTC_HASH_INITIAL_SIZE …
static void
ftc_node_mru_link( FTC_Node node,
FTC_Manager manager )
{ … }
static void
ftc_node_mru_unlink( FTC_Node node,
FTC_Manager manager )
{ … }
#ifndef FTC_INLINE
static void
ftc_node_mru_up( FTC_Node node,
FTC_Manager manager )
{
FTC_MruNode_Up( (FTC_MruNode*)&manager->nodes_list,
(FTC_MruNode)node );
}
FT_LOCAL_DEF( FTC_Node* )
ftc_get_top_node_for_hash( FTC_Cache cache,
FT_Offset hash )
{
FT_Offset idx;
idx = hash & cache->mask;
if ( idx >= cache->p )
idx = hash & ( cache->mask >> 1 );
return cache->buckets + idx;
}
#endif
static void
ftc_cache_resize( FTC_Cache cache )
{ … }
static void
ftc_node_hash_unlink( FTC_Node node0,
FTC_Cache cache )
{ … }
static void
ftc_node_hash_link( FTC_Node node,
FTC_Cache cache )
{ … }
FT_LOCAL_DEF( void )
ftc_node_destroy( FTC_Node node,
FTC_Manager manager )
{ … }
FT_LOCAL_DEF( FT_Error )
ftc_cache_init( FTC_Cache cache )
{ … }
FT_LOCAL_DEF( FT_Error )
FTC_Cache_Init( FTC_Cache cache )
{ … }
FT_LOCAL_DEF( void )
ftc_cache_done( FTC_Cache cache )
{ … }
FT_LOCAL_DEF( void )
FTC_Cache_Done( FTC_Cache cache )
{ … }
static void
ftc_cache_add( FTC_Cache cache,
FT_Offset hash,
FTC_Node node )
{ … }
FT_LOCAL_DEF( FT_Error )
FTC_Cache_NewNode( FTC_Cache cache,
FT_Offset hash,
FT_Pointer query,
FTC_Node *anode )
{ … }
#ifndef FTC_INLINE
FT_LOCAL_DEF( FT_Error )
FTC_Cache_Lookup( FTC_Cache cache,
FT_Offset hash,
FT_Pointer query,
FTC_Node *anode )
{
FTC_Node* bucket;
FTC_Node* pnode;
FTC_Node node;
FT_Error error = FT_Err_Ok;
FT_Bool list_changed = FALSE;
FTC_Node_CompareFunc compare = cache->clazz.node_compare;
if ( !cache || !anode )
return FT_THROW( Invalid_Argument );
bucket = pnode = FTC_NODE_TOP_FOR_HASH( cache, hash );
for (;;)
{
node = *pnode;
if ( !node )
goto NewNode;
if ( node->hash == hash &&
compare( node, query, cache, &list_changed ) )
break;
pnode = &node->link;
}
if ( list_changed )
{
bucket = pnode = FTC_NODE_TOP_FOR_HASH( cache, hash );
while ( *pnode != node )
{
if ( !*pnode )
{
FT_ERROR(( "FTC_Cache_Lookup: oops!!! node missing\n" ));
goto NewNode;
}
else
pnode = &(*pnode)->link;
}
}
if ( node != *bucket )
{
*pnode = node->link;
node->link = *bucket;
*bucket = node;
}
{
FTC_Manager manager = cache->manager;
if ( node != manager->nodes_list )
ftc_node_mru_up( node, manager );
}
*anode = node;
return error;
NewNode:
return FTC_Cache_NewNode( cache, hash, query, anode );
}
#endif
FT_LOCAL_DEF( void )
FTC_Cache_RemoveFaceID( FTC_Cache cache,
FTC_FaceID face_id )
{ … }