ReactOS 0.4.15-dev-8102-g108db8f
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-2018 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 )
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 )
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 )
57 {
58 /* finalize the node */
59 gnode->gindex = 0;
60
62 }
63
64
67 FT_Pointer ftcgquery,
69 FT_Bool* list_changed )
70 {
71 FTC_GNode gnode = (FTC_GNode)ftcgnode;
72 FTC_GQuery gquery = (FTC_GQuery)ftcgquery;
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
87 FTC_GQuery gquery,
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 )
108 {
110
111
112 family->clazz = clazz->family_class;
113 family->num_nodes = 0;
114 family->cache = cache;
115 }
116
117
120 {
121 FTC_GCache cache = (FTC_GCache)ftccache;
123
124
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
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 )
154 {
155 FTC_GCache cache = (FTC_GCache)ftccache;
156
157
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 {
169 }
170
171#endif /* 0 */
172
173
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
187 FTC_GCache_Lookup( FTC_GCache cache,
189 FT_UInt gindex,
191 FTC_Node *anode )
192 {
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 */
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
FTC_Cache_Done(FTC_Cache cache)
Definition: ftccache.c:409
FTC_Cache_Init(FTC_Cache cache)
Definition: ftccache.c:328
#define FTC_NODE(x)
Definition: ftccache.h:69
#define FTC_CACHE(x)
Definition: ftccache.h:161
FTC_GNode_Compare(FTC_GNode gnode, FTC_GQuery gquery, FTC_Cache cache, FT_Bool *list_changed)
Definition: ftcglyph.c:86
FTC_GNode_Done(FTC_GNode gnode, FTC_Cache cache)
Definition: ftcglyph.c:55
ftc_gcache_init(FTC_Cache ftccache)
Definition: ftcglyph.c:119
FTC_GCache_New(FTC_Manager manager, FTC_GCacheClass clazz, FTC_GCache *acache)
Definition: ftcglyph.c:175
ftc_gnode_compare(FTC_Node ftcgnode, FT_Pointer ftcgquery, FTC_Cache cache, FT_Bool *list_changed)
Definition: ftcglyph.c:66
ftc_gcache_done(FTC_Cache ftccache)
Definition: ftcglyph.c:153
FTC_Family_Init(FTC_Family family, FTC_Cache cache)
Definition: ftcglyph.c:106
FTC_GNode_UnselectFamily(FTC_GNode gnode, FTC_Cache cache)
Definition: ftcglyph.c:42
FTC_GNode_Init(FTC_GNode gnode, FT_UInt gindex, FTC_Family family)
Definition: ftcglyph.c:31
struct FTC_GNodeRec_ * FTC_GNode
FT_BEGIN_HEADER struct FTC_FamilyRec_ * FTC_Family
const FTC_GCacheClassRec * FTC_GCacheClass
Definition: ftcglyph.h:244
#define FTC_CACHE_GCACHE_CLASS(x)
Definition: ftcglyph.h:248
struct FTC_GCacheRec_ * FTC_GCache
struct FTC_GQueryRec_ * FTC_GQuery
#define FTC_FAMILY_FREE(family, cache)
Definition: ftcglyph.h:273
FTC_Manager_RegisterCache(FTC_Manager manager, FTC_CacheClass clazz, FTC_Cache *acache)
Definition: ftcmanag.c:580
FTC_MruList_Done(FTC_MruList list)
Definition: ftcmru.c:195
FTC_MruList_Init(FTC_MruList list, FTC_MruListClass clazz, FT_UInt max_nodes, FT_Pointer data, FT_Memory memory)
Definition: ftcmru.c:169
#define FTC_MRULIST_LOOKUP(list, key, node, error)
Definition: ftcmru.h:198
#define FT_LOCAL_DEF(x)
Definition: ftconfig.h:388
#define FT_UNUSED(arg)
Definition: ftconfig.h:101
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:108
int FT_Error
Definition: fttypes.h:300
unsigned int FT_UInt
Definition: fttypes.h:231
#define FT_BOOL(x)
Definition: fttypes.h:578
size_t FT_Offset
Definition: fttypes.h:324
#define error(str)
Definition: mkdosfs.c:1605
static char memory[1024 *256]
Definition: process.c:116
FTC_MruListClass family_class
Definition: ftcglyph.h:240
FT_UInt gindex
Definition: ftcglyph.h:152
FTC_Family family
Definition: ftcglyph.h:151
FTC_Family family
Definition: ftcglyph.h:163
FT_UInt gindex
Definition: ftcglyph.h:162
Definition: cache.c:49
Definition: _hash_fun.h:40