Disabling auto-refresh of game list by default, as it is causing bugs sometimes
[open-ps2-loader.git] / thirdparty / freetype-2.3.12 / src / cache / ftcglyph.c
bloba9ab0c319f75d5fbe96a7a3569c45dca50902511
1 /***************************************************************************/
2 /* */
3 /* ftcglyph.c */
4 /* */
5 /* FreeType Glyph Image (FT_Glyph) cache (body). */
6 /* */
7 /* Copyright 2000-2001, 2003, 2004, 2006, 2009 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
24 #include "ftccback.h"
25 #include "ftcerror.h"
28 /* create a new chunk node, setting its cache index and ref count */
29 FT_LOCAL_DEF( void )
30 FTC_GNode_Init( FTC_GNode gnode,
31 FT_UInt gindex,
32 FTC_Family family )
34 gnode->family = family;
35 gnode->gindex = gindex;
36 family->num_nodes++;
40 FT_LOCAL_DEF( void )
41 FTC_GNode_UnselectFamily( FTC_GNode gnode,
42 FTC_Cache cache )
44 FTC_Family family = gnode->family;
47 gnode->family = NULL;
48 if ( family && --family->num_nodes == 0 )
49 FTC_FAMILY_FREE( family, cache );
53 FT_LOCAL_DEF( void )
54 FTC_GNode_Done( FTC_GNode gnode,
55 FTC_Cache cache )
57 /* finalize the node */
58 gnode->gindex = 0;
60 FTC_GNode_UnselectFamily( gnode, cache );
64 FT_LOCAL_DEF( FT_Bool )
65 ftc_gnode_compare( FTC_Node ftcgnode,
66 FT_Pointer ftcgquery,
67 FTC_Cache cache )
69 FTC_GNode gnode = (FTC_GNode)ftcgnode;
70 FTC_GQuery gquery = (FTC_GQuery)ftcgquery;
71 FT_UNUSED( cache );
74 return FT_BOOL( gnode->family == gquery->family &&
75 gnode->gindex == gquery->gindex );
79 FT_LOCAL_DEF( FT_Bool )
80 FTC_GNode_Compare( FTC_GNode gnode,
81 FTC_GQuery gquery )
83 return ftc_gnode_compare( FTC_NODE( gnode ), gquery, NULL );
87 /*************************************************************************/
88 /*************************************************************************/
89 /***** *****/
90 /***** CHUNK SETS *****/
91 /***** *****/
92 /*************************************************************************/
93 /*************************************************************************/
95 FT_LOCAL_DEF( void )
96 FTC_Family_Init( FTC_Family family,
97 FTC_Cache cache )
99 FTC_GCacheClass clazz = FTC_CACHE__GCACHE_CLASS( cache );
102 family->clazz = clazz->family_class;
103 family->num_nodes = 0;
104 family->cache = cache;
108 FT_LOCAL_DEF( FT_Error )
109 ftc_gcache_init( FTC_Cache ftccache )
111 FTC_GCache cache = (FTC_GCache)ftccache;
112 FT_Error error;
115 error = FTC_Cache_Init( FTC_CACHE( cache ) );
116 if ( !error )
118 FTC_GCacheClass clazz = (FTC_GCacheClass)FTC_CACHE( cache )->org_class;
120 FTC_MruList_Init( &cache->families,
121 clazz->family_class,
122 0, /* no maximum here! */
123 cache,
124 FTC_CACHE( cache )->memory );
127 return error;
131 #if 0
133 FT_LOCAL_DEF( FT_Error )
134 FTC_GCache_Init( FTC_GCache cache )
136 return ftc_gcache_init( FTC_CACHE( cache ) );
139 #endif /* 0 */
142 FT_LOCAL_DEF( void )
143 ftc_gcache_done( FTC_Cache ftccache )
145 FTC_GCache cache = (FTC_GCache)ftccache;
148 FTC_Cache_Done( (FTC_Cache)cache );
149 FTC_MruList_Done( &cache->families );
153 #if 0
155 FT_LOCAL_DEF( void )
156 FTC_GCache_Done( FTC_GCache cache )
158 ftc_gcache_done( FTC_CACHE( cache ) );
161 #endif /* 0 */
164 FT_LOCAL_DEF( FT_Error )
165 FTC_GCache_New( FTC_Manager manager,
166 FTC_GCacheClass clazz,
167 FTC_GCache *acache )
169 return FTC_Manager_RegisterCache( manager, (FTC_CacheClass)clazz,
170 (FTC_Cache*)acache );
174 #ifndef FTC_INLINE
176 FT_LOCAL_DEF( FT_Error )
177 FTC_GCache_Lookup( FTC_GCache cache,
178 FT_UInt32 hash,
179 FT_UInt gindex,
180 FTC_GQuery query,
181 FTC_Node *anode )
183 FT_Error error;
186 query->gindex = gindex;
188 FTC_MRULIST_LOOKUP( &cache->families, query, query->family, error );
189 if ( !error )
191 FTC_Family family = query->family;
194 /* prevent the family from being destroyed too early when an */
195 /* out-of-memory condition occurs during glyph node initialization. */
196 family->num_nodes++;
198 error = FTC_Cache_Lookup( FTC_CACHE( cache ), hash, query, anode );
200 if ( --family->num_nodes == 0 )
201 FTC_FAMILY_FREE( family, cache );
203 return error;
206 #endif /* !FTC_INLINE */
209 /* END */