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.h
blobc18f9c3af316abd38f376eea57638f32ba072688
1 /***************************************************************************/
2 /* */
3 /* ftcglyph.h */
4 /* */
5 /* FreeType abstract glyph cache (specification). */
6 /* */
7 /* Copyright 2000-2001, 2003, 2004, 2006, 2007 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 /***************************************************************************/
21 * FTC_GCache is an _abstract_ cache object optimized to store glyph
22 * data. It works as follows:
24 * - It manages FTC_GNode objects. Each one of them can hold one or more
25 * glyph `items'. Item types are not specified in the FTC_GCache but
26 * in classes that extend it.
28 * - Glyph attributes, like face ID, character size, render mode, etc.,
29 * can be grouped into abstract `glyph families'. This avoids storing
30 * the attributes within the FTC_GCache, since it is likely that many
31 * FTC_GNodes will belong to the same family in typical uses.
33 * - Each FTC_GNode is thus an FTC_Node with two additional fields:
35 * * gindex: A glyph index, or the first index in a glyph range.
36 * * family: A pointer to a glyph `family'.
38 * - Family types are not fully specific in the FTC_Family type, but
39 * by classes that extend it.
41 * Note that both FTC_ImageCache and FTC_SBitCache extend FTC_GCache.
42 * They share an FTC_Family sub-class called FTC_BasicFamily which is
43 * used to store the following data: face ID, pixel/point sizes, load
44 * flags. For more details see the file `src/cache/ftcbasic.c'.
46 * Client applications can extend FTC_GNode with their own FTC_GNode
47 * and FTC_Family sub-classes to implement more complex caches (e.g.,
48 * handling automatic synthesis, like obliquing & emboldening, colored
49 * glyphs, etc.).
51 * See also the FTC_ICache & FTC_SCache classes in `ftcimage.h' and
52 * `ftcsbits.h', which both extend FTC_GCache with additional
53 * optimizations.
55 * A typical FTC_GCache implementation must provide at least the
56 * following:
58 * - FTC_GNode sub-class, e.g. MyNode, with relevant methods:
59 * my_node_new (must call FTC_GNode_Init)
60 * my_node_free (must call FTC_GNode_Done)
61 * my_node_compare (must call FTC_GNode_Compare)
62 * my_node_remove_faceid (must call ftc_gnode_unselect in case
63 * of match)
65 * - FTC_Family sub-class, e.g. MyFamily, with relevant methods:
66 * my_family_compare
67 * my_family_init
68 * my_family_reset (optional)
69 * my_family_done
71 * - FTC_GQuery sub-class, e.g. MyQuery, to hold cache-specific query
72 * data.
74 * - Constant structures for a FTC_GNodeClass.
76 * - MyCacheNew() can be implemented easily as a call to the convenience
77 * function FTC_GCache_New.
79 * - MyCacheLookup with a call to FTC_GCache_Lookup. This function will
80 * automatically:
82 * - Search for the corresponding family in the cache, or create
83 * a new one if necessary. Put it in FTC_GQUERY(myquery).family
85 * - Call FTC_Cache_Lookup.
87 * If it returns NULL, you should create a new node, then call
88 * ftc_cache_add as usual.
92 /*************************************************************************/
93 /* */
94 /* Important: The functions defined in this file are only used to */
95 /* implement an abstract glyph cache class. You need to */
96 /* provide additional logic to implement a complete cache. */
97 /* */
98 /*************************************************************************/
101 /*************************************************************************/
102 /*************************************************************************/
103 /*************************************************************************/
104 /*************************************************************************/
105 /*************************************************************************/
106 /********* *********/
107 /********* WARNING, THIS IS BETA CODE. *********/
108 /********* *********/
109 /*************************************************************************/
110 /*************************************************************************/
111 /*************************************************************************/
112 /*************************************************************************/
113 /*************************************************************************/
116 #ifndef __FTCGLYPH_H__
117 #define __FTCGLYPH_H__
120 #include <ft2build.h>
121 #include "ftcmanag.h"
124 FT_BEGIN_HEADER
128 * We can group glyphs into `families'. Each family correspond to a
129 * given face ID, character size, transform, etc.
131 * Families are implemented as MRU list nodes. They are
132 * reference-counted.
135 typedef struct FTC_FamilyRec_
137 FTC_MruNodeRec mrunode;
138 FT_UInt num_nodes; /* current number of nodes in this family */
139 FTC_Cache cache;
140 FTC_MruListClass clazz;
142 } FTC_FamilyRec, *FTC_Family;
144 #define FTC_FAMILY(x) ( (FTC_Family)(x) )
145 #define FTC_FAMILY_P(x) ( (FTC_Family*)(x) )
148 typedef struct FTC_GNodeRec_
150 FTC_NodeRec node;
151 FTC_Family family;
152 FT_UInt gindex;
154 } FTC_GNodeRec, *FTC_GNode;
156 #define FTC_GNODE( x ) ( (FTC_GNode)(x) )
157 #define FTC_GNODE_P( x ) ( (FTC_GNode*)(x) )
160 typedef struct FTC_GQueryRec_
162 FT_UInt gindex;
163 FTC_Family family;
165 } FTC_GQueryRec, *FTC_GQuery;
167 #define FTC_GQUERY( x ) ( (FTC_GQuery)(x) )
170 /*************************************************************************/
171 /* */
172 /* These functions are exported so that they can be called from */
173 /* user-provided cache classes; otherwise, they are really part of the */
174 /* cache sub-system internals. */
175 /* */
177 /* must be called by derived FTC_Node_InitFunc routines */
178 FT_LOCAL( void )
179 FTC_GNode_Init( FTC_GNode node,
180 FT_UInt gindex, /* glyph index for node */
181 FTC_Family family );
183 /* returns TRUE iff the query's glyph index correspond to the node; */
184 /* this assumes that the `family' and `hash' fields of the query are */
185 /* already correctly set */
186 FT_LOCAL( FT_Bool )
187 FTC_GNode_Compare( FTC_GNode gnode,
188 FTC_GQuery gquery );
190 /* call this function to clear a node's family -- this is necessary */
191 /* to implement the `node_remove_faceid' cache method correctly */
192 FT_LOCAL( void )
193 FTC_GNode_UnselectFamily( FTC_GNode gnode,
194 FTC_Cache cache );
196 /* must be called by derived FTC_Node_DoneFunc routines */
197 FT_LOCAL( void )
198 FTC_GNode_Done( FTC_GNode node,
199 FTC_Cache cache );
202 FT_LOCAL( void )
203 FTC_Family_Init( FTC_Family family,
204 FTC_Cache cache );
206 typedef struct FTC_GCacheRec_
208 FTC_CacheRec cache;
209 FTC_MruListRec families;
211 } FTC_GCacheRec, *FTC_GCache;
213 #define FTC_GCACHE( x ) ((FTC_GCache)(x))
216 #if 0
217 /* can be used as @FTC_Cache_InitFunc */
218 FT_LOCAL( FT_Error )
219 FTC_GCache_Init( FTC_GCache cache );
220 #endif
223 #if 0
224 /* can be used as @FTC_Cache_DoneFunc */
225 FT_LOCAL( void )
226 FTC_GCache_Done( FTC_GCache cache );
227 #endif
230 /* the glyph cache class adds fields for the family implementation */
231 typedef struct FTC_GCacheClassRec_
233 FTC_CacheClassRec clazz;
234 FTC_MruListClass family_class;
236 } FTC_GCacheClassRec;
238 typedef const FTC_GCacheClassRec* FTC_GCacheClass;
240 #define FTC_GCACHE_CLASS( x ) ((FTC_GCacheClass)(x))
242 #define FTC_CACHE__GCACHE_CLASS( x ) \
243 FTC_GCACHE_CLASS( FTC_CACHE(x)->org_class )
244 #define FTC_CACHE__FAMILY_CLASS( x ) \
245 ( (FTC_MruListClass)FTC_CACHE__GCACHE_CLASS( x )->family_class )
248 /* convenience function; use it instead of FTC_Manager_Register_Cache */
249 FT_LOCAL( FT_Error )
250 FTC_GCache_New( FTC_Manager manager,
251 FTC_GCacheClass clazz,
252 FTC_GCache *acache );
254 #ifndef FTC_INLINE
255 FT_LOCAL( FT_Error )
256 FTC_GCache_Lookup( FTC_GCache cache,
257 FT_UInt32 hash,
258 FT_UInt gindex,
259 FTC_GQuery query,
260 FTC_Node *anode );
261 #endif
264 /* */
267 #define FTC_FAMILY_FREE( family, cache ) \
268 FTC_MruList_Remove( &FTC_GCACHE((cache))->families, \
269 (FTC_MruNode)(family) )
272 #ifdef FTC_INLINE
274 #define FTC_GCACHE_LOOKUP_CMP( cache, famcmp, nodecmp, hash, \
275 gindex, query, node, error ) \
276 FT_BEGIN_STMNT \
277 FTC_GCache _gcache = FTC_GCACHE( cache ); \
278 FTC_GQuery _gquery = (FTC_GQuery)( query ); \
279 FTC_MruNode_CompareFunc _fcompare = (FTC_MruNode_CompareFunc)(famcmp); \
280 FTC_MruNode _mrunode; \
283 _gquery->gindex = (gindex); \
285 FTC_MRULIST_LOOKUP_CMP( &_gcache->families, _gquery, _fcompare, \
286 _mrunode, error ); \
287 _gquery->family = FTC_FAMILY( _mrunode ); \
288 if ( !error ) \
290 FTC_Family _gqfamily = _gquery->family; \
293 _gqfamily->num_nodes++; \
295 FTC_CACHE_LOOKUP_CMP( cache, nodecmp, hash, query, node, error ); \
297 if ( --_gqfamily->num_nodes == 0 ) \
298 FTC_FAMILY_FREE( _gqfamily, _gcache ); \
300 FT_END_STMNT
301 /* */
303 #else /* !FTC_INLINE */
305 #define FTC_GCACHE_LOOKUP_CMP( cache, famcmp, nodecmp, hash, \
306 gindex, query, node, error ) \
307 FT_BEGIN_STMNT \
309 error = FTC_GCache_Lookup( FTC_GCACHE( cache ), hash, gindex, \
310 FTC_GQUERY( query ), node ); \
312 FT_END_STMNT
314 #endif /* !FTC_INLINE */
317 FT_END_HEADER
320 #endif /* __FTCGLYPH_H__ */
323 /* END */