misc fixes to get rrdtool working without included libraries.
[rrdtool.git] / libraries / freetype-2.0.5 / include / freetype / cache / ftcchunk.h
1 /***************************************************************************/
2 /*                                                                         */
3 /*  ftcchunk.h                                                             */
4 /*                                                                         */
5 /*    FreeType chunk cache (specification).                                */
6 /*                                                                         */
7 /*  Copyright 2000-2001 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 /***************************************************************************/
17
18
19   /*************************************************************************/
20   /*                                                                       */
21   /* Important: The functions defined in this file are only used to        */
22   /*            implement an abstract chunk cache class.  You need to      */
23   /*            provide additional logic to implement a complete cache.    */
24   /*            For example, see `ftcmetrx.h' and `ftcmetrx.c' which       */
25   /*            implement a glyph metrics cache based on this code.        */
26   /*                                                                       */
27   /*************************************************************************/
28
29
30   /*************************************************************************/
31   /*************************************************************************/
32   /*************************************************************************/
33   /*************************************************************************/
34   /*************************************************************************/
35   /*********                                                       *********/
36   /*********             WARNING, THIS IS BETA CODE.               *********/
37   /*********                                                       *********/
38   /*************************************************************************/
39   /*************************************************************************/
40   /*************************************************************************/
41   /*************************************************************************/
42   /*************************************************************************/
43
44
45 #ifndef __FTCCHUNK_H__
46 #define __FTCCHUNK_H__
47
48
49 #include <ft2build.h>
50 #include FT_CACHE_H
51 #include FT_CACHE_MANAGER_H
52
53
54 FT_BEGIN_HEADER
55
56
57   /* maximum number of chunk sets in a given chunk cache */
58 #define FTC_MAX_CHUNK_SETS  16
59
60
61   typedef struct FTC_ChunkNodeRec_*    FTC_ChunkNode;
62   typedef struct FTC_ChunkSetRec_*     FTC_ChunkSet;
63   typedef struct FTC_Chunk_CacheRec_*  FTC_Chunk_Cache;
64
65   typedef struct  FTC_ChunkNodeRec_
66   {
67     FTC_CacheNodeRec  root;
68     FTC_ChunkSet      cset;
69     FT_UShort         cset_index;
70     FT_UShort         num_elements;
71     FT_Byte*          elements;
72
73   } FTC_ChunkNodeRec;
74
75
76 #define FTC_CHUNKNODE_TO_LRUNODE( x )  ((FT_ListNode)( x ))
77 #define FTC_LRUNODE_TO_CHUNKNODE( x )  ((FTC_ChunkNode)( x ))
78
79
80   /*************************************************************************/
81   /*                                                                       */
82   /*  chunk set methods                                                    */
83   /*                                                                       */
84
85   /* used to set "element_max", "element_count" and "element_size" */
86   typedef FT_Error
87   (*FTC_ChunkSet_SizesFunc)( FTC_ChunkSet  cset,
88                              FT_Pointer    type );
89
90   typedef FT_Error
91   (*FTC_ChunkSet_InitFunc)( FTC_ChunkSet  cset,
92                             FT_Pointer    type );
93
94   typedef void
95   (*FTC_ChunkSet_DoneFunc)( FTC_ChunkSet  cset );
96
97   typedef FT_Bool
98   (*FTC_ChunkSet_CompareFunc)( FTC_ChunkSet  cset,
99                                FT_Pointer    type );
100
101
102   typedef FT_Error
103   (*FTC_ChunkSet_NewNodeFunc)( FTC_ChunkSet    cset,
104                                FT_UInt         index,
105                                FTC_ChunkNode*  anode );
106
107   typedef void
108   (*FTC_ChunkSet_DestroyNodeFunc)( FTC_ChunkNode   node );
109
110   typedef FT_ULong
111   (*FTC_ChunkSet_SizeNodeFunc)( FTC_ChunkNode   node );
112
113
114   typedef struct  FTC_ChunkSet_Class_
115   {
116     FT_UInt                       cset_byte_size;
117
118     FTC_ChunkSet_InitFunc         init;
119     FTC_ChunkSet_DoneFunc         done;
120     FTC_ChunkSet_CompareFunc      compare;
121     FTC_ChunkSet_SizesFunc        sizes;
122
123     FTC_ChunkSet_NewNodeFunc      new_node;
124     FTC_ChunkSet_SizeNodeFunc     size_node;
125     FTC_ChunkSet_DestroyNodeFunc  destroy_node;
126
127   } FTC_ChunkSet_Class;
128
129
130   typedef struct  FTC_ChunkSetRec_
131   {
132     FTC_Chunk_Cache      cache;
133     FTC_Manager          manager;
134     FT_Memory            memory;
135     FTC_ChunkSet_Class*  clazz;
136     FT_UInt              cset_index;     /* index in parent cache    */
137
138     FT_UInt              element_max;    /* maximum number of elements   */
139     FT_UInt              element_size;   /* element size in bytes        */
140     FT_UInt              element_count;  /* number of elements per chunk */
141
142     FT_UInt              num_chunks;
143     FTC_ChunkNode*       chunks;
144
145   } FTC_ChunkSetRec;
146
147
148   /* the abstract chunk cache class */
149   typedef struct  FTC_Chunk_Cache_Class_
150   {
151     FTC_Cache_Class      root;
152     FTC_ChunkSet_Class*  cset_class;
153
154   } FTC_Chunk_Cache_Class;
155
156
157   /* the abstract chunk cache object */
158   typedef struct  FTC_Chunk_CacheRec_
159   {
160     FTC_CacheRec              root;
161     FT_Lru                    csets_lru;   /* static chunk set lru list */
162     FTC_ChunkSet              last_cset;   /* small cache :-)           */
163     FTC_ChunkSet_CompareFunc  compare;     /* useful shortcut           */
164
165   } FTC_Chunk_CacheRec;
166
167
168   /*************************************************************************/
169   /*                                                                       */
170   /* These functions are exported so that they can be called from          */
171   /* user-provided cache classes; otherwise, they are really part of the   */
172   /* cache sub-system internals.                                           */
173   /*                                                                       */
174
175   FT_EXPORT( FT_Error )
176   FTC_ChunkNode_Init( FTC_ChunkNode  node,
177                       FTC_ChunkSet   cset,
178                       FT_UInt        index,
179                       FT_Bool        alloc );
180
181 #define FTC_ChunkNode_Ref( n ) \
182           FTC_CACHENODE_TO_DATA_P( &(n)->root )->ref_count++
183
184 #define FTC_ChunkNode_Unref( n ) \
185           FTC_CACHENODE_TO_DATA_P( &(n)->root )->ref_count--
186
187
188   /* chunk set objects */
189
190   FT_EXPORT( void )
191   FTC_ChunkNode_Destroy( FTC_ChunkNode    node );
192
193
194   FT_EXPORT( FT_Error )
195   FTC_ChunkSet_New( FTC_Chunk_Cache  cache,
196                     FT_Pointer       type,
197                     FTC_ChunkSet    *aset );
198
199
200   FT_EXPORT( FT_Error )
201   FTC_ChunkSet_Lookup_Node( FTC_ChunkSet    cset,
202                             FT_UInt         glyph_index,
203                             FTC_ChunkNode*  anode,
204                             FT_UInt        *anindex );
205
206
207   /* chunk cache objects */
208
209   FT_EXPORT( FT_Error )
210   FTC_Chunk_Cache_Init( FTC_Chunk_Cache  cache );
211
212   FT_EXPORT( void )
213   FTC_Chunk_Cache_Done( FTC_Chunk_Cache  cache );
214
215   FT_EXPORT( FT_Error )
216   FTC_Chunk_Cache_Lookup( FTC_Chunk_Cache  cache,
217                           FT_Pointer       type,
218                           FT_UInt          gindex,
219                           FTC_ChunkNode   *anode,
220                           FT_UInt         *aindex );
221
222
223 FT_END_HEADER
224
225 #endif /* __FTCCHUNK_H__ */
226
227
228 /* END */