zenilib: zenilib/jni/external/freetype2/src/cache/ftcglyph.c Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ftcglyph.c
Go to the documentation of this file.
1 /***************************************************************************/
2 /* */
3 /* ftcglyph.c */
4 /* */
5 /* FreeType Glyph Image (FT_Glyph) cache (body). */
6 /* */
7 /* Copyright 2000-2001, 2003, 2004, 2006, 2009, 2011 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 #include <ft2build.h>
20 #include FT_INTERNAL_OBJECTS_H
21 #include FT_CACHE_H
22 #include "ftcglyph.h"
23 #include FT_ERRORS_H
24
25 #include "ftccback.h"
26 #include "ftcerror.h"
27
28
29 /* create a new chunk node, setting its cache index and ref count */
30 FT_LOCAL_DEF( void )
31 FTC_GNode_Init( FTC_GNode gnode,
32 FT_UInt gindex,
33 FTC_Family family )
34 {
35 gnode->family = family;
36 gnode->gindex = gindex;
37 family->num_nodes++;
38 }
39
40
41 FT_LOCAL_DEF( void )
42 FTC_GNode_UnselectFamily( FTC_GNode gnode,
43 FTC_Cache cache )
44 {
45 FTC_Family family = gnode->family;
46
47
48 gnode->family = NULL;
49 if ( family && --family->num_nodes == 0 )
50 FTC_FAMILY_FREE( family, cache );
51 }
52
53
54 FT_LOCAL_DEF( void )
55 FTC_GNode_Done( FTC_GNode gnode,
56 FTC_Cache cache )
57 {
58 /* finalize the node */
59 gnode->gindex = 0;
60
61 FTC_GNode_UnselectFamily( gnode, cache );
62 }
63
64
65 FT_LOCAL_DEF( FT_Bool )
66 ftc_gnode_compare( FTC_Node ftcgnode,
67 FT_Pointer ftcgquery,
68 FTC_Cache cache,
69 FT_Bool* list_changed )
70 {
71 FTC_GNode gnode = (FTC_GNode)ftcgnode;
72 FTC_GQuery gquery = (FTC_GQuery)ftcgquery;
73 FT_UNUSED( cache );
74
75
76 if ( list_changed )
77 *list_changed = FALSE;
78 return FT_BOOL( gnode->family == gquery->family &&
79 gnode->gindex == gquery->gindex );
80 }
81
82
83 #ifdef FTC_INLINE
84
85 FT_LOCAL_DEF( FT_Bool )
86 FTC_GNode_Compare( FTC_GNode gnode,
87 FTC_GQuery gquery,
88 FTC_Cache cache,
89 FT_Bool* list_changed )
90 {
91 return ftc_gnode_compare( FTC_NODE( gnode ), gquery,
92 cache, list_changed );
93 }
94
95 #endif
96
97 /*************************************************************************/
98 /*************************************************************************/
99 /***** *****/
100 /***** CHUNK SETS *****/
101 /***** *****/
102 /*************************************************************************/
103 /*************************************************************************/
104
105 FT_LOCAL_DEF( void )
106 FTC_Family_Init( FTC_Family family,
107 FTC_Cache cache )
108 {
109 FTC_GCacheClass clazz = FTC_CACHE__GCACHE_CLASS( cache );
110
111
112 family->clazz = clazz->family_class;
113 family->num_nodes = 0;
114 family->cache = cache;
115 }
116
117
118 FT_LOCAL_DEF( FT_Error )
119 ftc_gcache_init( FTC_Cache ftccache )
120 {
121 FTC_GCache cache = (FTC_GCache)ftccache;
122 FT_Error error;
123
124
125 error = FTC_Cache_Init( FTC_CACHE( cache ) );
126 if ( !error )
127 {
128 FTC_GCacheClass clazz = (FTC_GCacheClass)FTC_CACHE( cache )->org_class;
129
130 FTC_MruList_Init( &cache->families,
131 clazz->family_class,
132 0, /* no maximum here! */
133 cache,
134 FTC_CACHE( cache )->memory );
135 }
136
137 return error;
138 }
139
140
141 #if 0
142
143 FT_LOCAL_DEF( FT_Error )
144 FTC_GCache_Init( FTC_GCache cache )
145 {
146 return ftc_gcache_init( FTC_CACHE( cache ) );
147 }
148
149 #endif /* 0 */
150
151
152 FT_LOCAL_DEF( void )
153 ftc_gcache_done( FTC_Cache ftccache )
154 {
155 FTC_GCache cache = (FTC_GCache)ftccache;
156
157
158 FTC_Cache_Done( (FTC_Cache)cache );
159 FTC_MruList_Done( &cache->families );
160 }
161
162
163 #if 0
164
165 FT_LOCAL_DEF( void )
166 FTC_GCache_Done( FTC_GCache cache )
167 {
168 ftc_gcache_done( FTC_CACHE( cache ) );
169 }
170
171 #endif /* 0 */
172
173
174 FT_LOCAL_DEF( FT_Error )
175 FTC_GCache_New( FTC_Manager manager,
176 FTC_GCacheClass clazz,
177 FTC_GCache *acache )
178 {
179 return FTC_Manager_RegisterCache( manager, (FTC_CacheClass)clazz,
180 (FTC_Cache*)acache );
181 }
182
183
184 #ifndef FTC_INLINE
185
186 FT_LOCAL_DEF( FT_Error )
187 FTC_GCache_Lookup( FTC_GCache cache,
188 FT_PtrDist hash,
189 FT_UInt gindex,
190 FTC_GQuery query,
191 FTC_Node *anode )
192 {
193 FT_Error error;
194
195
196 query->gindex = gindex;
197
198 FTC_MRULIST_LOOKUP( &cache->families, query, query->family, error );
199 if ( !error )
200 {
201 FTC_Family family = query->family;
202
203
204 /* prevent the family from being destroyed too early when an */
205 /* out-of-memory condition occurs during glyph node initialization. */
206 family->num_nodes++;
207
208 error = FTC_Cache_Lookup( FTC_CACHE( cache ), hash, query, anode );
209
210 if ( --family->num_nodes == 0 )
211 FTC_FAMILY_FREE( family, cache );
212 }
213 return error;
214 }
215
216 #endif /* !FTC_INLINE */
217
218
219 /* END */
ftc_gnode_compare
ftc_gnode_compare(FTC_Node gnode, FT_Pointer gquery, FTC_Cache cache, FT_Bool *list_changed)
Definition: ftcglyph.c:66
FT_Error
int FT_Error
Definition: fttypes.h:296
FT_PtrDist
ft_ptrdiff_t FT_PtrDist
Definition: fttypes.h:333
FTC_GNode_UnselectFamily
FTC_GNode_UnselectFamily(FTC_GNode gnode, FTC_Cache cache)
Definition: ftcglyph.c:42
NULL
#define NULL
Definition: ftobjs.h:61
FTC_CacheRec_
Definition: ftccache.h:150
ftcglyph.h
FTC_NODE
#define FTC_NODE(x)
Definition: ftccache.h:70
ftcerror.h
FTC_GCache
struct FTC_GCacheRec_ * FTC_GCache
FT_Bool
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:104
FTC_GNodeRec_
Definition: ftcglyph.h:148
FTC_MruList_Init
FTC_MruList_Init(FTC_MruList list, FTC_MruListClass clazz, FT_UInt max_nodes, FT_Pointer data, FT_Memory memory)
Definition: ftcmru.c:169
FTC_GCacheRec_
Definition: ftcglyph.h:212
FTC_Family_Init
FTC_Family_Init(FTC_Family family, FTC_Cache cache)
Definition: ftcglyph.c:106
FTC_GNode_Init
FTC_GNode_Init(FTC_GNode gnode, FT_UInt gindex, FTC_Family family)
Definition: ftcglyph.c:31
FTC_Cache_Done
FTC_Cache_Done(FTC_Cache cache)
Definition: ftccache.c:414
FTC_GNode
struct FTC_GNodeRec_ * FTC_GNode
query
GLenum query
Definition: glew.h:5140
FTC_Manager_RegisterCache
FTC_Manager_RegisterCache(FTC_Manager manager, FTC_CacheClass clazz, FTC_Cache *acache)
Definition: ftcmanag.c:574
FT_LOCAL_DEF
#define FT_LOCAL_DEF(x)
Definition: ftconfig.h:467
FTC_GQueryRec_::family
FTC_Family family
Definition: ftcglyph.h:163
error
FT_Error error
Definition: cffdrivr.c:407
FT_Pointer
void * FT_Pointer
Definition: fttypes.h:307
FTC_MruList_Done
FTC_MruList_Done(FTC_MruList list)
Definition: ftcmru.c:195
FTC_GQueryRec_::gindex
FT_UInt gindex
Definition: ftcglyph.h:162
FTC_CACHE
#define FTC_CACHE(x)
Definition: ftccache.h:168
FTC_GCacheClass
const FTC_GCacheClassRec * FTC_GCacheClass
Definition: ftcglyph.h:244
FTC_CacheClassRec_
Definition: ftccache.h:134
ftc_gcache_done
ftc_gcache_done(FTC_Cache cache)
Definition: ftcglyph.c:153
FALSE
#define FALSE
Definition: ftobjs.h:57
FTC_GCacheRec_::families
FTC_MruListRec families
Definition: ftcglyph.h:215
FTC_GNodeRec_::family
FTC_Family family
Definition: ftcglyph.h:151
FT_BOOL
#define FT_BOOL(x)
Definition: fttypes.h:581
FTC_ManagerRec_
Definition: ftcmanag.h:91
FTC_Family
FT_BEGIN_HEADER struct FTC_FamilyRec_ * FTC_Family
FTC_GNode_Done
FTC_GNode_Done(FTC_GNode gnode, FTC_Cache cache)
Definition: ftcglyph.c:55
ft2build.h
FTC_GNode_Compare
FTC_GNode_Compare(FTC_GNode gnode, FTC_GQuery gquery, FTC_Cache cache, FT_Bool *list_changed)
Definition: ftcglyph.c:86
FTC_FAMILY_FREE
#define FTC_FAMILY_FREE(family, cache)
Definition: ftcglyph.h:273
FT_UInt
unsigned int FT_UInt
Definition: fttypes.h:227
FTC_GQueryRec_
Definition: ftcglyph.h:160
FTC_CACHE__GCACHE_CLASS
#define FTC_CACHE__GCACHE_CLASS(x)
Definition: ftcglyph.h:248
ftc_gcache_init
ftc_gcache_init(FTC_Cache cache)
Definition: ftcglyph.c:119
FTC_GQuery
struct FTC_GQueryRec_ * FTC_GQuery
FTC_GNodeRec_::gindex
FT_UInt gindex
Definition: ftcglyph.h:152
FTC_GCacheClassRec_::family_class
FTC_MruListClass family_class
Definition: ftcglyph.h:240
FTC_NodeRec_
Definition: ftccache.h:59
ftccback.h
FTC_Cache_Init
FTC_Cache_Init(FTC_Cache cache)
Definition: ftccache.c:333
FTC_GCache_New
FTC_GCache_New(FTC_Manager manager, FTC_GCacheClass clazz, FTC_GCache *acache)
Definition: ftcglyph.c:175
FT_UNUSED
#define FT_UNUSED(arg)
Definition: ftconfig.h:101
FTC_GCacheClassRec_
Definition: ftcglyph.h:237
FTC_MRULIST_LOOKUP
#define FTC_MRULIST_LOOKUP(list, key, node, error)
Definition: ftcmru.h:196