The BIG graph update
[rrdtool.git] / libraries / freetype-2.0.5 / include / freetype / cache / ftcglyph.h
1 /***************************************************************************/
2 /*                                                                         */
3 /*  ftcglyph.h                                                             */
4 /*                                                                         */
5 /*    FreeType abstract glyph 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 glyph cache class.  You need to      */
23   /*            provide additional logic to implement a complete cache.    */
24   /*            For example, see `ftcimage.h' and `ftcimage.c' which       */
25   /*            implement a FT_Glyph cache based on this code.             */
26   /*                                                                       */
27   /*  NOTE: For now, each glyph set is implemented as a static hash table. */
28   /*        It would be interesting to experiment with dynamic hashes to   */
29   /*        see whether this improves performance or not (I don't know why */
30   /*        but something tells me it won't).                              */
31   /*                                                                       */
32   /*        In all cases, this change should not affect any derived glyph  */
33   /*        cache class.                                                   */
34   /*                                                                       */
35   /*************************************************************************/
36
37
38   /*************************************************************************/
39   /*************************************************************************/
40   /*************************************************************************/
41   /*************************************************************************/
42   /*************************************************************************/
43   /*********                                                       *********/
44   /*********             WARNING, THIS IS BETA CODE.               *********/
45   /*********                                                       *********/
46   /*************************************************************************/
47   /*************************************************************************/
48   /*************************************************************************/
49   /*************************************************************************/
50   /*************************************************************************/
51
52
53 #ifndef __FTCGLYPH_H__
54 #define __FTCGLYPH_H__
55
56
57 #include <ft2build.h>
58 #include FT_CACHE_H
59 #include FT_CACHE_MANAGER_H
60
61 #include <stddef.h>
62
63
64 FT_BEGIN_HEADER
65
66
67   /* maximum number of glyph sets per glyph cache; must be < 256 */
68 #define FTC_MAX_GLYPH_SETS          16
69 #define FTC_GSET_HASH_SIZE_DEFAULT  64
70
71
72   typedef struct FTC_GlyphSetRec_*     FTC_GlyphSet;
73   typedef struct FTC_GlyphNodeRec_*    FTC_GlyphNode;
74   typedef struct FTC_Glyph_CacheRec_*  FTC_Glyph_Cache;
75
76   typedef struct  FTC_GlyphNodeRec_
77   {
78     FTC_CacheNodeRec  root;
79     FTC_GlyphNode     gset_next;   /* next in glyph set's bucket list */
80     FT_UShort         glyph_index;
81     FT_UShort         gset_index;
82
83   } FTC_GlyphNodeRec;
84
85
86 #define FTC_GLYPHNODE( x )             ( (FTC_GlyphNode)( x ) )
87 #define FTC_GLYPHNODE_TO_LRUNODE( n )  ( (FT_ListNode)( n ) )
88 #define FTC_LRUNODE_TO_GLYPHNODE( n )  ( (FTC_GlyphNode)( n ) )
89
90
91   /*************************************************************************/
92   /*                                                                       */
93   /* Glyph set methods.                                                    */
94   /*                                                                       */
95
96   typedef FT_Error
97   (*FTC_GlyphSet_InitFunc)( FTC_GlyphSet    gset,
98                             FT_Pointer      type );
99
100   typedef void
101   (*FTC_GlyphSet_DoneFunc)( FTC_GlyphSet    gset );
102
103   typedef FT_Bool
104   (*FTC_GlyphSet_CompareFunc)( FTC_GlyphSet    gset,
105                                FT_Pointer      type );
106
107
108   typedef FT_Error
109   (*FTC_GlyphSet_NewNodeFunc)( FTC_GlyphSet    gset,
110                                FT_UInt         gindex,
111                                FTC_GlyphNode*  anode );
112
113   typedef void
114   (*FTC_GlyphSet_DestroyNodeFunc)( FTC_GlyphNode   node,
115                                    FTC_GlyphSet    gset );
116
117   typedef FT_ULong
118   (*FTC_GlyphSet_SizeNodeFunc)( FTC_GlyphNode   node,
119                                 FTC_GlyphSet    gset );
120
121
122   typedef struct  FTC_GlyphSet_Class_
123   {
124     FT_UInt                       gset_byte_size;
125
126     FTC_GlyphSet_InitFunc         init;
127     FTC_GlyphSet_DoneFunc         done;
128     FTC_GlyphSet_CompareFunc      compare;
129
130     FTC_GlyphSet_NewNodeFunc      new_node;
131     FTC_GlyphSet_SizeNodeFunc     size_node;
132     FTC_GlyphSet_DestroyNodeFunc  destroy_node;
133
134   } FTC_GlyphSet_Class;
135
136
137   typedef struct  FTC_GlyphSetRec_
138   {
139     FTC_Glyph_Cache      cache;
140     FTC_Manager          manager;
141     FT_Memory            memory;
142     FTC_GlyphSet_Class*  clazz;
143     FT_UInt              hash_size;
144     FTC_GlyphNode*       buckets;
145     FT_UInt              gset_index;  /* index in parent cache    */
146
147   } FTC_GlyphSetRec;
148
149
150   /* the abstract glyph cache class */
151   typedef struct  FTC_Glyph_Cache_Class_
152   {
153     FTC_Cache_Class      root;
154     FTC_GlyphSet_Class*  gset_class;
155
156   } FTC_Glyph_Cache_Class;
157
158
159   /* the abstract glyph cache object */
160   typedef struct  FTC_Glyph_CacheRec_
161   {
162     FTC_CacheRec              root;
163     FT_Lru                    gsets_lru;    /* static sets lru list */
164     FTC_GlyphSet              last_gset;    /* small cache :-)      */
165     FTC_GlyphSet_CompareFunc  compare;      /* useful shortcut      */
166
167   } FTC_Glyph_CacheRec;
168
169
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   /*                                                                       */
176
177   FT_EXPORT( void )
178   FTC_GlyphNode_Init( FTC_GlyphNode  node,
179                       FTC_GlyphSet   gset,
180                       FT_UInt        gindex );
181
182 #define FTC_GlyphNode_Ref( n ) \
183           FTC_CACHENODE_TO_DATA_P( &(n)->root )->ref_count++
184
185 #define FTC_GlyphNode_Unref( n ) \
186           FTC_CACHENODE_TO_DATA_P( &(n)->root )->ref_count--
187
188
189   FT_EXPORT( void )
190   FTC_GlyphNode_Destroy( FTC_GlyphNode    node,
191                          FTC_Glyph_Cache  cache );
192
193   FT_EXPORT( FT_Error )
194   FTC_Glyph_Cache_Init(  FTC_Glyph_Cache  cache );
195
196   FT_EXPORT( void )
197   FTC_Glyph_Cache_Done(  FTC_Glyph_Cache  cache );
198
199
200   FT_EXPORT( FT_Error )
201   FTC_GlyphSet_New( FTC_Glyph_Cache  cache,
202                     FT_Pointer       type,
203                     FTC_GlyphSet    *aset );
204
205   FT_EXPORT( FT_Error )
206   FTC_GlyphSet_Lookup_Node( FTC_GlyphSet    gset,
207                             FT_UInt         glyph_index,
208                             FTC_GlyphNode  *anode );
209
210   FT_EXPORT( FT_Error )
211   FTC_Glyph_Cache_Lookup( FTC_Glyph_Cache  cache,
212                           FT_Pointer       type,
213                           FT_UInt          gindex,
214                           FTC_GlyphNode   *anode );
215
216
217 FT_END_HEADER
218
219 #endif /* __FTCGLYPH_H__ */
220
221
222 /* END */