Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / modules / freetype2 / src / cache / ftcglyph.c
blob5c03abe055277a43337252751bf6fb22b33bebfb
1 /***************************************************************************/
2 /* */
3 /* ftcglyph.c */
4 /* */
5 /* FreeType Glyph Image (FT_Glyph) cache (body). */
6 /* */
7 /* Copyright 2000-2001, 2003, 2004, 2006 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
9 /* */
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. */
15 /* */
16 /***************************************************************************/
19 #include <ft2build.h>
20 #include FT_CACHE_H
21 #include "ftcglyph.h"
22 #include FT_ERRORS_H
23 #include FT_INTERNAL_OBJECTS_H
24 #include FT_INTERNAL_DEBUG_H
26 #include "ftccback.h"
27 #include "ftcerror.h"
30 /* create a new chunk node, setting its cache index and ref count */
31 FT_LOCAL_DEF( void )
32 FTC_GNode_Init( FTC_GNode gnode,
33 FT_UInt gindex,
34 FTC_Family family )
36 gnode->family = family;
37 gnode->gindex = gindex;
38 family->num_nodes++;
42 FT_LOCAL_DEF( void )
43 FTC_GNode_UnselectFamily( FTC_GNode gnode,
44 FTC_Cache cache )
46 FTC_Family family = gnode->family;
49 gnode->family = NULL;
50 if ( family && --family->num_nodes == 0 )
51 FTC_FAMILY_FREE( family, cache );
55 FT_LOCAL_DEF( void )
56 FTC_GNode_Done( FTC_GNode gnode,
57 FTC_Cache cache )
59 /* finalize the node */
60 gnode->gindex = 0;
62 FTC_GNode_UnselectFamily( gnode, cache );
66 FT_LOCAL_DEF( FT_Bool )
67 ftc_gnode_compare( FTC_Node ftcgnode,
68 FT_Pointer ftcgquery,
69 FTC_Cache cache )
71 FTC_GNode gnode = (FTC_GNode)ftcgnode;
72 FTC_GQuery gquery = (FTC_GQuery)ftcgquery;
73 FT_UNUSED( cache );
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,
83 FTC_GQuery gquery )
85 return ftc_gnode_compare( FTC_NODE( gnode ), gquery, NULL );
89 /*************************************************************************/
90 /*************************************************************************/
91 /***** *****/
92 /***** CHUNK SETS *****/
93 /***** *****/
94 /*************************************************************************/
95 /*************************************************************************/
97 FT_LOCAL_DEF( void )
98 FTC_Family_Init( FTC_Family family,
99 FTC_Cache cache )
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;
114 FT_Error error;
117 error = FTC_Cache_Init( FTC_CACHE( cache ) );
118 if ( !error )
120 FTC_GCacheClass clazz = (FTC_GCacheClass)FTC_CACHE( cache )->org_class;
122 FTC_MruList_Init( &cache->families,
123 clazz->family_class,
124 0, /* no maximum here! */
125 cache,
126 FTC_CACHE( cache )->memory );
129 return error;
133 #if 0
135 FT_LOCAL_DEF( FT_Error )
136 FTC_GCache_Init( FTC_GCache cache )
138 return ftc_gcache_init( FTC_CACHE( cache ) );
141 #endif /* 0 */
144 FT_LOCAL_DEF( void )
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 );
155 #if 0
157 FT_LOCAL_DEF( void )
158 FTC_GCache_Done( FTC_GCache cache )
160 ftc_gcache_done( FTC_CACHE( cache ) );
163 #endif /* 0 */
166 FT_LOCAL_DEF( FT_Error )
167 FTC_GCache_New( FTC_Manager manager,
168 FTC_GCacheClass clazz,
169 FTC_GCache *acache )
171 return FTC_Manager_RegisterCache( manager, (FTC_CacheClass)clazz,
172 (FTC_Cache*)acache );
176 #ifndef FTC_INLINE
178 FT_LOCAL_DEF( FT_Error )
179 FTC_GCache_Lookup( FTC_GCache cache,
180 FT_UInt32 hash,
181 FT_UInt gindex,
182 FTC_GQuery query,
183 FTC_Node *anode )
185 FT_Error error;
188 query->gindex = gindex;
190 FTC_MRULIST_LOOKUP( &cache->families, query, query->family, error );
191 if ( !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. */
198 family->num_nodes++;
200 error = FTC_Cache_Lookup( FTC_CACHE( cache ), hash, query, anode );
202 if ( --family->num_nodes == 0 )
203 FTC_FAMILY_FREE( family, cache );
205 return error;
208 #endif /* !FTC_INLINE */
211 /* END */