1 /***************************************************************************/
5 /* FreeType Glyph Image (FT_Glyph) cache (body). */
7 /* Copyright 2000-2001, 2003, 2004, 2006 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
10 /* This file is part of the FreeType project, and may only be used, */
11 /* modified, and distributed under the terms of the FreeType project */
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
13 /* this file you indicate that you have read the license and */
14 /* understand and accept it fully. */
16 /***************************************************************************/
23 #include FT_INTERNAL_OBJECTS_H
24 #include FT_INTERNAL_DEBUG_H
30 /* create a new chunk node, setting its cache index and ref count */
32 FTC_GNode_Init( FTC_GNode gnode
,
36 gnode
->family
= family
;
37 gnode
->gindex
= gindex
;
43 FTC_GNode_UnselectFamily( FTC_GNode gnode
,
46 FTC_Family family
= gnode
->family
;
50 if ( family
&& --family
->num_nodes
== 0 )
51 FTC_FAMILY_FREE( family
, cache
);
56 FTC_GNode_Done( FTC_GNode gnode
,
59 /* finalize the node */
62 FTC_GNode_UnselectFamily( gnode
, cache
);
66 FT_LOCAL_DEF( FT_Bool
)
67 ftc_gnode_compare( FTC_Node ftcgnode
,
71 FTC_GNode gnode
= (FTC_GNode
)ftcgnode
;
72 FTC_GQuery gquery
= (FTC_GQuery
)ftcgquery
;
76 return FT_BOOL( gnode
->family
== gquery
->family
&&
77 gnode
->gindex
== gquery
->gindex
);
81 FT_LOCAL_DEF( FT_Bool
)
82 FTC_GNode_Compare( FTC_GNode gnode
,
85 return ftc_gnode_compare( FTC_NODE( gnode
), gquery
, NULL
);
89 /*************************************************************************/
90 /*************************************************************************/
92 /***** CHUNK SETS *****/
94 /*************************************************************************/
95 /*************************************************************************/
98 FTC_Family_Init( FTC_Family family
,
101 FTC_GCacheClass clazz
= FTC_CACHE__GCACHE_CLASS( cache
);
104 family
->clazz
= clazz
->family_class
;
105 family
->num_nodes
= 0;
106 family
->cache
= cache
;
110 FT_LOCAL_DEF( FT_Error
)
111 ftc_gcache_init( FTC_Cache ftccache
)
113 FTC_GCache cache
= (FTC_GCache
)ftccache
;
117 error
= FTC_Cache_Init( FTC_CACHE( cache
) );
120 FTC_GCacheClass clazz
= (FTC_GCacheClass
)FTC_CACHE( cache
)->org_class
;
122 FTC_MruList_Init( &cache
->families
,
124 0, /* no maximum here! */
126 FTC_CACHE( cache
)->memory
);
135 FT_LOCAL_DEF( FT_Error
)
136 FTC_GCache_Init( FTC_GCache cache
)
138 return ftc_gcache_init( FTC_CACHE( cache
) );
145 ftc_gcache_done( FTC_Cache ftccache
)
147 FTC_GCache cache
= (FTC_GCache
)ftccache
;
150 FTC_Cache_Done( (FTC_Cache
)cache
);
151 FTC_MruList_Done( &cache
->families
);
158 FTC_GCache_Done( FTC_GCache cache
)
160 ftc_gcache_done( FTC_CACHE( cache
) );
166 FT_LOCAL_DEF( FT_Error
)
167 FTC_GCache_New( FTC_Manager manager
,
168 FTC_GCacheClass clazz
,
171 return FTC_Manager_RegisterCache( manager
, (FTC_CacheClass
)clazz
,
172 (FTC_Cache
*)acache
);
178 FT_LOCAL_DEF( FT_Error
)
179 FTC_GCache_Lookup( FTC_GCache cache
,
188 query
->gindex
= gindex
;
190 FTC_MRULIST_LOOKUP( &cache
->families
, query
, query
->family
, error
);
193 FTC_Family family
= query
->family
;
196 /* prevent the family from being destroyed too early when an */
197 /* out-of-memory condition occurs during glyph node initialization. */
200 error
= FTC_Cache_Lookup( FTC_CACHE( cache
), hash
, query
, anode
);
202 if ( --family
->num_nodes
== 0 )
203 FTC_FAMILY_FREE( family
, cache
);
208 #endif /* !FTC_INLINE */