Commit b83239b7fdd6c3a086dd9ee09a73b9b03161fa80

David Turner 2004-06-09T21:07:49

* include/freetype/cache/ftcmru.h, src/cache/ftcbasic.c, src/cache/ftccache.c, src/cache/ftcglyph.c, src/cache/ftcmanag.c, src/cache/ftcsbits.c: fixing some annoying bugs and inefficiencies in the cache sub-system.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
diff --git a/ChangeLog b/ChangeLog
index fbd83bc..88606cf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,12 @@
         slot->metrics.width and slot->metrics.height when loading a Windows
         FNT glyph. Thanks to Huw Davies
 
+        * include/freetype/cache/ftcmru.h, src/cache/ftcbasic.c,
+        src/cache/ftccache.c, src/cache/ftcglyph.c, src/cache/ftcmanag.c,
+        src/cache/ftcsbits.c:
+        fixing some annoying bugs and inefficiencies in the cache sub-system.
+
+
 2004-06-05  Werner Lemberg  <wl@gnu.org>
 
 	* src/autofit/afloader.c (af_loader_load_g): Set `lsb_delta' and
diff --git a/include/freetype/cache/ftcmru.h b/include/freetype/cache/ftcmru.h
index 9556f58..d70c5cc 100644
--- a/include/freetype/cache/ftcmru.h
+++ b/include/freetype/cache/ftcmru.h
@@ -86,7 +86,7 @@ FT_BEGIN_HEADER
   typedef struct FTC_MruListClassRec_ const *  FTC_MruListClass;
 
 
-  typedef FT_Int
+  typedef FT_Bool
   (*FTC_MruNode_CompareFunc)( FTC_MruNode  node,
                               FT_Pointer   key );
 
@@ -154,7 +154,7 @@ FT_BEGIN_HEADER
   FTC_MruList_Lookup( FTC_MruList   list,
                       FT_Pointer    key,
                       FTC_MruNode  *pnode );
-                      
+
 
   FT_EXPORT( void )
   FTC_MruList_Remove( FTC_MruList  list,
@@ -208,7 +208,7 @@ FT_BEGIN_HEADER
 #else  /* !FTC_INLINE */
 
 #define FTC_MRULIST_LOOKUP( list, key, node, error ) \
-  error = FTC_MruList_Lookup( (list), (key), (FTC_MruNode*)&(node) ) 
+  error = FTC_MruList_Lookup( (list), (key), (FTC_MruNode*)&(node) )
 
 #endif /* !FTC_INLINE */
 
diff --git a/src/cache/ftcbasic.c b/src/cache/ftcbasic.c
index a9b66dc..9a91f35 100644
--- a/src/cache/ftcbasic.c
+++ b/src/cache/ftcbasic.c
@@ -62,7 +62,7 @@
   } FTC_BasicFamilyRec, *FTC_BasicFamily;
 
 
-  FT_CALLBACK_DEF( FT_Int )
+  FT_CALLBACK_DEF( FT_Bool )
   ftc_basic_family_compare( FTC_MruNode  ftcfamily,
                             FT_Pointer   ftcquery )
   {
diff --git a/src/cache/ftccache.c b/src/cache/ftccache.c
index 2b6bee9..3a8a40c 100644
--- a/src/cache/ftccache.c
+++ b/src/cache/ftccache.c
@@ -304,6 +304,13 @@
   FT_EXPORT_DEF( FT_Error )
   FTC_Cache_Init( FTC_Cache  cache )
   {
+    return ftc_cache_init( cache );
+  }
+
+
+  FT_LOCAL_DEF( FT_Error )
+  ftc_cache_init( FTC_Cache  cache )
+  {
     FT_Memory  memory = cache->memory;
 
 
@@ -315,13 +322,6 @@
   }
 
 
-  FT_LOCAL_DEF( FT_Error )
-  ftc_cache_init( FTC_Cache  cache )
-  {
-    return FTC_Cache_Init( cache );
-  }
-
-
   FT_EXPORT_DEF( void )
   FTC_Cache_Clear( FTC_Cache  cache )
   {
@@ -360,8 +360,8 @@
   }
 
 
-  FT_EXPORT_DEF( void )
-  FTC_Cache_Done( FTC_Cache  cache )
+  FT_LOCAL_DEF( void )
+  ftc_cache_done( FTC_Cache  cache )
   {
     if ( cache->memory )
     {
@@ -380,10 +380,10 @@
   }
 
 
-  FT_LOCAL_DEF( void )
-  ftc_cache_done( FTC_Cache  cache )
+  FT_EXPORT_DEF( void )
+  FTC_Cache_Done( FTC_Cache  cache )
   {
-    FTC_Cache_Done( cache );
+    ftc_cache_done( cache );
   }
 
 
diff --git a/src/cache/ftcglyph.c b/src/cache/ftcglyph.c
index edcd36d..547e3d1 100644
--- a/src/cache/ftcglyph.c
+++ b/src/cache/ftcglyph.c
@@ -64,15 +64,6 @@
   }
 
 
-  FT_EXPORT_DEF( FT_Bool )
-  FTC_GNode_Compare( FTC_GNode   gnode,
-                     FTC_GQuery  gquery )
-  {
-    return FT_BOOL(  gnode->family == gquery->family &&
-                     gnode->gindex == gquery->gindex );
-  }
-
-
   FT_LOCAL_DEF( FT_Bool )
   ftc_gnode_compare( FTC_Node    ftcgnode,
                      FT_Pointer  ftcgquery,
@@ -82,8 +73,16 @@
     FTC_GQuery  gquery = (FTC_GQuery)ftcgquery;
     FT_UNUSED( cache );
 
+    return FT_BOOL(  gnode->family == gquery->family &&
+                     gnode->gindex == gquery->gindex );
+  }
+
 
-    return FTC_GNode_Compare( gnode, gquery );
+  FT_EXPORT_DEF( FT_Bool )
+  FTC_GNode_Compare( FTC_GNode   gnode,
+                     FTC_GQuery  gquery )
+  {
+    return ftc_gnode_compare( FTC_NODE(gnode), gquery, NULL );
   }
 
 
@@ -108,10 +107,11 @@
   }
 
 
-  FT_EXPORT_DEF( FT_Error )
-  FTC_GCache_Init( FTC_GCache  cache )
+  FT_LOCAL_DEF( FT_Error )
+  ftc_gcache_init( FTC_Cache  ftccache )
   {
-    FT_Error error;
+    FTC_GCache  cache = (FTC_GCache)ftccache;
+    FT_Error    error;
 
     error = FTC_Cache_Init( FTC_CACHE( cache ) );
     if ( !error )
@@ -129,21 +129,17 @@
   }
 
 
-  FT_LOCAL_DEF( FT_Error )
-  ftc_gcache_init( FTC_Cache  ftccache )
+  FT_EXPORT_DEF( FT_Error )
+  FTC_GCache_Init( FTC_GCache  cache )
   {
-    FTC_GCache  cache = (FTC_GCache)ftccache;
-
-
-    return FTC_GCache_Init( cache );
+    return ftc_gcache_init( FTC_CACHE(cache) );
   }
 
 
   FT_EXPORT_DEF( void )
   FTC_GCache_Done( FTC_GCache  cache )
   {
-    FTC_Cache_Done( (FTC_Cache)cache );
-    FTC_MruList_Done( &cache->families );
+    return ftc_gcache_done( FTC_CACHE(cache) );
   }
 
 
@@ -153,7 +149,8 @@
     FTC_GCache  cache = (FTC_GCache)ftccache;
 
 
-    FTC_GCache_Done( cache );
+    FTC_Cache_Done( (FTC_Cache)cache );
+    FTC_MruList_Done( &cache->families );
   }
 
 
diff --git a/src/cache/ftcimage.c b/src/cache/ftcimage.c
index 29f3288..ab147a5 100644
--- a/src/cache/ftcimage.c
+++ b/src/cache/ftcimage.c
@@ -26,10 +26,11 @@
 
 
   /* finalize a given glyph image node */
-  FT_EXPORT_DEF( void )
-  FTC_INode_Free( FTC_INode  inode,
+  FT_LOCAL_DEF( void )
+  ftc_inode_free( FTC_Node   ftcinode,
                   FTC_Cache  cache )
   {
+    FTC_INode  inode = (FTC_INode)ftcinode;
     FT_Memory  memory = cache->memory;
 
 
@@ -44,14 +45,13 @@
   }
 
 
-  FT_LOCAL_DEF( void )
-  ftc_inode_free( FTC_Node   ftcinode,
-                  FTC_Cache  cache )
-  {
-    FTC_INode  inode = (FTC_INode)ftcinode;
 
 
-    FTC_INode_Free( inode, cache );
+  FT_EXPORT_DEF( void )
+  FTC_INode_Free( FTC_INode  inode,
+                  FTC_Cache  cache )
+  {
+    ftc_inode_free( FTC_NODE(inode), cache );
   }
 
 
@@ -100,12 +100,15 @@
   }
 
 
-  FT_EXPORT_DEF( FT_ULong )
-  FTC_INode_Weight( FTC_INode  inode )
+  FT_LOCAL_DEF( FT_ULong )
+  ftc_inode_weight( FTC_Node   ftcinode,
+                    FTC_Cache  ftccache )
   {
-    FT_ULong  size  = 0;
-    FT_Glyph  glyph = inode->glyph;
+    FTC_INode  inode = (FTC_INode)ftcinode;
+    FT_ULong   size  = 0;
+    FT_Glyph   glyph = inode->glyph;
 
+    FT_UNUSED(ftccache);
 
     switch ( glyph->format )
     {
@@ -142,15 +145,12 @@
   }
 
 
-  FT_LOCAL_DEF( FT_ULong )
-  ftc_inode_weight( FTC_Node   ftcinode,
-                    FTC_Cache  ftccache )
-  {
-    FTC_INode  inode = (FTC_INode)ftcinode;
-    FT_UNUSED( ftccache );
 
 
-    return FTC_INode_Weight( inode );
+  FT_EXPORT_DEF( FT_ULong )
+  FTC_INode_Weight( FTC_INode  inode )
+  {
+    return ftc_inode_weight( FTC_NODE(inode), NULL );
   }
 
 
diff --git a/src/cache/ftcmanag.c b/src/cache/ftcmanag.c
index 1f83a92..97d324c 100644
--- a/src/cache/ftcmanag.c
+++ b/src/cache/ftcmanag.c
@@ -92,7 +92,7 @@
   }
 
 
-  FT_CALLBACK_DEF( FT_Int )
+  FT_CALLBACK_DEF( FT_Bool )
   ftc_size_node_compare( FTC_MruNode  ftcnode,
                          FT_Pointer   ftcscaler )
   {
@@ -156,7 +156,7 @@
 
 
   /* helper function used by ftc_face_node_done */
-  static FT_Int
+  static FT_Bool
   ftc_size_node_compare_faceid( FTC_MruNode  ftcnode,
                                 FT_Pointer   ftcface_id )
   {
@@ -269,7 +269,7 @@
   }
 
 
-  FT_CALLBACK_DEF( FT_Int )
+  FT_CALLBACK_DEF( FT_Bool )
   ftc_face_node_compare( FTC_MruNode  ftcnode,
                          FT_Pointer   ftcface_id )
   {
diff --git a/src/cache/ftcsbits.c b/src/cache/ftcsbits.c
index 68bab08..a19d61f 100644
--- a/src/cache/ftcsbits.c
+++ b/src/cache/ftcsbits.c
@@ -58,10 +58,11 @@
   }
 
 
-  FT_EXPORT_DEF( void )
-  FTC_SNode_Free( FTC_SNode  snode,
+  FT_LOCAL_DEF( void )
+  ftc_snode_free( FTC_Node   ftcsnode,
                   FTC_Cache  cache )
   {
+    FTC_SNode  snode  = (FTC_SNode)ftcsnode;
     FTC_SBit   sbit   = snode->sbits;
     FT_UInt    count  = snode->count;
     FT_Memory  memory = cache->memory;
@@ -76,14 +77,13 @@
   }
 
 
-  FT_LOCAL_DEF( void )
-  ftc_snode_free( FTC_Node   ftcsnode,
-                  FTC_Cache  cache )
-  {
-    FTC_SNode  snode = (FTC_SNode)ftcsnode;
 
 
-    FTC_SNode_Free( snode, cache );
+  FT_EXPORT_DEF( void )
+  FTC_SNode_Free( FTC_SNode  snode,
+                  FTC_Cache  cache )
+  {
+    ftc_snode_free( FTC_NODE(snode), cache );
   }
 
 
@@ -255,14 +255,17 @@
   }
 
 
-  FT_EXPORT_DEF( FT_ULong )
-  FTC_SNode_Weight( FTC_SNode  snode )
+  FT_LOCAL_DEF( FT_ULong )
+  ftc_snode_weight( FTC_Node   ftcsnode,
+                    FTC_Cache  cache )
   {
+    FTC_SNode  snode = (FTC_SNode)ftcsnode;
     FT_UInt    count = snode->count;
     FTC_SBit   sbit  = snode->sbits;
     FT_Int     pitch;
     FT_ULong   size;
 
+    FT_UNUSED( cache );
 
     FT_ASSERT( snode->count <= FTC_SBIT_ITEMS_PER_NODE );
 
@@ -286,26 +289,23 @@
   }
 
 
-  FT_LOCAL_DEF( FT_ULong )
-  ftc_snode_weight( FTC_Node   ftcsnode,
-                    FTC_Cache  cache )
+  FT_EXPORT_DEF( FT_ULong )
+  FTC_SNode_Weight( FTC_SNode  snode )
   {
-    FTC_SNode  snode = (FTC_SNode)ftcsnode;
-    FT_UNUSED( cache );
-
-
-    return FTC_SNode_Weight( snode );
+    return ftc_snode_weight( FTC_NODE(snode), NULL );
   }
 
 
-  FT_EXPORT_DEF( FT_Bool )
-  FTC_SNode_Compare( FTC_SNode   snode,
-                     FTC_GQuery  gquery,
+  FT_LOCAL_DEF( FT_Bool )
+  ftc_snode_compare( FTC_Node    ftcsnode,
+                     FT_Pointer  ftcgquery,
                      FTC_Cache   cache )
   {
-    FTC_GNode  gnode  = FTC_GNODE( snode );
-    FT_UInt    gindex = gquery->gindex;
-    FT_Bool    result;
+    FTC_SNode   snode  = (FTC_SNode)ftcsnode;
+    FTC_GQuery  gquery = (FTC_GQuery)ftcgquery;
+    FTC_GNode   gnode  = FTC_GNODE( snode );
+    FT_UInt     gindex = gquery->gindex;
+    FT_Bool     result;
 
 
     result = FT_BOOL( gnode->family == gquery->family                    &&
@@ -333,16 +333,14 @@
   }
 
 
-  FT_LOCAL_DEF( FT_Bool )
-  ftc_snode_compare( FTC_Node    ftcsnode,
-                     FT_Pointer  ftcgquery,
-                     FTC_Cache   cache )
-  {
-    FTC_SNode   snode  = (FTC_SNode)ftcsnode;
-    FTC_GQuery  gquery = (FTC_GQuery)ftcgquery;
 
 
-    return FTC_SNode_Compare( snode, gquery, cache );
+  FT_EXPORT_DEF( FT_Bool )
+  FTC_SNode_Compare( FTC_SNode   snode,
+                     FTC_GQuery  gquery,
+                     FTC_Cache   cache )
+  {
+    return ftc_snode_compare( FTC_NODE(snode), gquery, cache );
   }