ReactOS 0.4.16-dev-2357-g35d0dfe
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 (C) 2000-2020 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
20#include <freetype/ftcache.h>
21#include "ftcglyph.h"
22#include <freetype/fterrors.h>
23
24#include "ftccback.h"
25#include "ftcerror.h"
26
27
28 /* create a new chunk node, setting its cache index and ref count */
29 FT_LOCAL_DEF( void )
31 FT_UInt gindex,
32 FTC_Family family )
33 {
34 gnode->family = family;
35 gnode->gindex = gindex;
36 family->num_nodes++;
37 }
38
39
40 FT_LOCAL_DEF( void )
43 {
44 FTC_Family family = gnode->family;
45
46
47 gnode->family = NULL;
48 if ( family && --family->num_nodes == 0 )
49 FTC_FAMILY_FREE( family, cache );
50 }
51
52
53 FT_LOCAL_DEF( void )
56 {
57 /* finalize the node */
58 gnode->gindex = 0;
59
61 }
62
63
66 FT_Pointer ftcgquery,
68 FT_Bool* list_changed )
69 {
70 FTC_GNode gnode = (FTC_GNode)ftcgnode;
71 FTC_GQuery gquery = (FTC_GQuery)ftcgquery;
73
74
75 if ( list_changed )
76 *list_changed = FALSE;
77 return FT_BOOL( gnode->family == gquery->family &&
78 gnode->gindex == gquery->gindex );
79 }
80
81
82#ifdef FTC_INLINE
83
86 FTC_GQuery gquery,
88 FT_Bool* list_changed )
89 {
90 return ftc_gnode_compare( FTC_NODE( gnode ), gquery,
91 cache, list_changed );
92 }
93
94#endif
95
96 /*************************************************************************/
97 /*************************************************************************/
98 /***** *****/
99 /***** CHUNK SETS *****/
100 /***** *****/
101 /*************************************************************************/
102 /*************************************************************************/
103
104 FT_LOCAL_DEF( void )
107 {
109
110
111 family->clazz = clazz->family_class;
112 family->num_nodes = 0;
113 family->cache = cache;
114 }
115
116
119 {
120 FTC_GCache cache = (FTC_GCache)ftccache;
122
123
125 if ( !error )
126 {
127 FTC_GCacheClass clazz = (FTC_GCacheClass)FTC_CACHE( cache )->org_class;
128
129 FTC_MruList_Init( &cache->families,
130 clazz->family_class,
131 0, /* no maximum here! */
132 cache,
133 FTC_CACHE( cache )->memory );
134 }
135
136 return error;
137 }
138
139
140#if 0
141
143 FTC_GCache_Init( FTC_GCache cache )
144 {
145 return ftc_gcache_init( FTC_CACHE( cache ) );
146 }
147
148#endif /* 0 */
149
150
151 FT_LOCAL_DEF( void )
153 {
154 FTC_GCache cache = (FTC_GCache)ftccache;
155
156
158 FTC_MruList_Done( &cache->families );
159 }
160
161
162#if 0
163
164 FT_LOCAL_DEF( void )
165 FTC_GCache_Done( FTC_GCache cache )
166 {
168 }
169
170#endif /* 0 */
171
172
175 FTC_GCacheClass clazz,
176 FTC_GCache *acache )
177 {
178 return FTC_Manager_RegisterCache( manager, (FTC_CacheClass)clazz,
179 (FTC_Cache*)acache );
180 }
181
182
183#ifndef FTC_INLINE
184
186 FTC_GCache_Lookup( FTC_GCache cache,
188 FT_UInt gindex,
190 FTC_Node *anode )
191 {
193
194
195 query->gindex = gindex;
196
197 FTC_MRULIST_LOOKUP( &cache->families, query, query->family, error );
198 if ( !error )
199 {
200 FTC_Family family = query->family;
201
202
203 /* prevent the family from being destroyed too early when an */
204 /* out-of-memory condition occurs during glyph node initialization. */
205 family->num_nodes++;
206
207 error = FTC_Cache_Lookup( FTC_CACHE( cache ), hash, query, anode );
208
209 if ( --family->num_nodes == 0 )
210 FTC_FAMILY_FREE( family, cache );
211 }
212 return error;
213 }
214
215#endif /* !FTC_INLINE */
216
217
218/* END */
#define FT_LOCAL_DEF(x)
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
FTC_Cache_Done(FTC_Cache cache)
Definition: ftccache.c:408
FTC_Cache_Init(FTC_Cache cache)
Definition: ftccache.c:327
#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:85
FTC_GNode_Done(FTC_GNode gnode, FTC_Cache cache)
Definition: ftcglyph.c:54
ftc_gcache_init(FTC_Cache ftccache)
Definition: ftcglyph.c:118
FTC_GCache_New(FTC_Manager manager, FTC_GCacheClass clazz, FTC_GCache *acache)
Definition: ftcglyph.c:174
ftc_gnode_compare(FTC_Node ftcgnode, FT_Pointer ftcgquery, FTC_Cache cache, FT_Bool *list_changed)
Definition: ftcglyph.c:65
ftc_gcache_done(FTC_Cache ftccache)
Definition: ftcglyph.c:152
FTC_Family_Init(FTC_Family family, FTC_Cache cache)
Definition: ftcglyph.c:105
FTC_GNode_UnselectFamily(FTC_GNode gnode, FTC_Cache cache)
Definition: ftcglyph.c:41
FTC_GNode_Init(FTC_GNode gnode, FT_UInt gindex, FTC_Family family)
Definition: ftcglyph.c:30
struct FTC_GNodeRec_ * FTC_GNode
FT_BEGIN_HEADER struct FTC_FamilyRec_ * FTC_Family
const FTC_GCacheClassRec * FTC_GCacheClass
Definition: ftcglyph.h:243
#define FTC_CACHE_GCACHE_CLASS(x)
Definition: ftcglyph.h:247
struct FTC_GCacheRec_ * FTC_GCache
struct FTC_GQueryRec_ * FTC_GQuery
#define FTC_FAMILY_FREE(family, cache)
Definition: ftcglyph.h:272
FTC_Manager_RegisterCache(FTC_Manager manager, FTC_CacheClass clazz, FTC_Cache *acache)
Definition: ftcmanag.c:575
FTC_MruList_Done(FTC_MruList list)
Definition: ftcmru.c:194
FTC_MruList_Init(FTC_MruList list, FTC_MruListClass clazz, FT_UInt max_nodes, FT_Pointer data, FT_Memory memory)
Definition: ftcmru.c:168
#define FTC_MRULIST_LOOKUP(list, key, node, error)
Definition: ftcmru.h:198
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:108
int FT_Error
Definition: fttypes.h:299
unsigned int FT_UInt
Definition: fttypes.h:231
#define FT_BOOL(x)
Definition: fttypes.h:591
size_t FT_Offset
Definition: fttypes.h:323
#define error(str)
Definition: mkdosfs.c:1605
static char memory[1024 *256]
Definition: process.c:122
#define FT_UNUSED(arg)
FTC_MruListClass family_class
Definition: ftcglyph.h:239
FT_UInt gindex
Definition: ftcglyph.h:151
FTC_Family family
Definition: ftcglyph.h:150
FTC_Family family
Definition: ftcglyph.h:162
FT_UInt gindex
Definition: ftcglyph.h:161
Definition: cache.c:49
Definition: _hash_fun.h:40