ReactOS 0.4.15-dev-8145-ga541a46
ftccback.h File Reference
#include <ft2build.h>
#include "ftcmru.h"
#include "ftcimage.h"
#include "ftcmanag.h"
#include "ftcglyph.h"
#include "ftcsbits.h"
Include dependency graph for ftccback.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 ftc_inode_free (FTC_Node inode, FTC_Cache cache)
 
 ftc_inode_new (FTC_Node *pinode, FT_Pointer gquery, FTC_Cache cache)
 
 ftc_inode_weight (FTC_Node inode, FTC_Cache cache)
 
 ftc_snode_free (FTC_Node snode, FTC_Cache cache)
 
 ftc_snode_new (FTC_Node *psnode, FT_Pointer gquery, FTC_Cache cache)
 
 ftc_snode_weight (FTC_Node snode, FTC_Cache cache)
 
 ftc_snode_compare (FTC_Node snode, FT_Pointer gquery, FTC_Cache cache, FT_Bool *list_changed)
 
 ftc_gnode_compare (FTC_Node gnode, FT_Pointer gquery, FTC_Cache cache, FT_Bool *list_changed)
 
 ftc_gcache_init (FTC_Cache cache)
 
 ftc_gcache_done (FTC_Cache cache)
 
 ftc_cache_init (FTC_Cache cache)
 
 ftc_cache_done (FTC_Cache cache)
 
 ftc_node_destroy (FTC_Node node, FTC_Manager manager)
 

Function Documentation

◆ ftc_cache_done()

ftc_cache_done ( FTC_Cache  cache)

Definition at line 389 of file ftccache.c.

390 {
391 if ( cache->memory )
392 {
393 FT_Memory memory = cache->memory;
394
395
397
398 FT_FREE( cache->buckets );
399 cache->mask = 0;
400 cache->p = 0;
401 cache->slack = 0;
402
403 cache->memory = NULL;
404 }
405 }
#define NULL
Definition: types.h:112
static void FTC_Cache_Clear(FTC_Cache cache)
Definition: ftccache.c:351
#define FT_FREE(ptr)
Definition: ftmemory.h:329
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
static char memory[1024 *256]
Definition: process.c:116
Definition: cache.c:49

Referenced by FTC_Cache_Done().

◆ ftc_cache_init()

ftc_cache_init ( FTC_Cache  cache)

Definition at line 335 of file ftccache.c.

336 {
337 FT_Memory memory = cache->memory;
339
340
341 cache->p = 0;
342 cache->mask = FTC_HASH_INITIAL_SIZE - 1;
344
346 return error;
347 }
#define FTC_HASH_INITIAL_SIZE
Definition: ftccache.c:36
#define FTC_HASH_MAX_LOAD
Definition: ftccache.c:31
#define FT_NEW_ARRAY(ptr, count)
Definition: ftmemory.h:333
int FT_Error
Definition: fttypes.h:300
#define error(str)
Definition: mkdosfs.c:1605

Referenced by FTC_Cache_Init().

◆ ftc_gcache_done()

ftc_gcache_done ( FTC_Cache  cache)

Definition at line 153 of file ftcglyph.c.

154 {
155 FTC_GCache cache = (FTC_GCache)ftccache;
156
157
159 FTC_MruList_Done( &cache->families );
160 }
FTC_Cache_Done(FTC_Cache cache)
Definition: ftccache.c:409
struct FTC_GCacheRec_ * FTC_GCache
FTC_MruList_Done(FTC_MruList list)
Definition: ftcmru.c:195

◆ ftc_gcache_init()

ftc_gcache_init ( FTC_Cache  cache)

Definition at line 119 of file ftcglyph.c.

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 }
FTC_Cache_Init(FTC_Cache cache)
Definition: ftccache.c:328
#define FTC_CACHE(x)
Definition: ftccache.h:161
const FTC_GCacheClassRec * FTC_GCacheClass
Definition: ftcglyph.h:244
FTC_MruList_Init(FTC_MruList list, FTC_MruListClass clazz, FT_UInt max_nodes, FT_Pointer data, FT_Memory memory)
Definition: ftcmru.c:169
FTC_MruListClass family_class
Definition: ftcglyph.h:240

◆ ftc_gnode_compare()

ftc_gnode_compare ( FTC_Node  gnode,
FT_Pointer  gquery,
FTC_Cache  cache,
FT_Bool list_changed 
)

Definition at line 66 of file ftcglyph.c.

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 }
#define FALSE
Definition: types.h:117
struct FTC_GNodeRec_ * FTC_GNode
struct FTC_GQueryRec_ * FTC_GQuery
#define FT_UNUSED(arg)
Definition: ftconfig.h:101
#define FT_BOOL(x)
Definition: fttypes.h:578
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

Referenced by FTC_GNode_Compare().

◆ ftc_inode_free()

ftc_inode_free ( FTC_Node  inode,
FTC_Cache  cache 
)

Definition at line 31 of file ftcimage.c.

33 {
34 FTC_INode inode = (FTC_INode)ftcinode;
35 FT_Memory memory = cache->memory;
36
37
38 if ( inode->glyph )
39 {
40 FT_Done_Glyph( inode->glyph );
41 inode->glyph = NULL;
42 }
43
45 FT_FREE( inode );
46 }
FTC_GNode_Done(FTC_GNode gnode, FTC_Cache cache)
Definition: ftcglyph.c:55
#define FTC_GNODE(x)
Definition: ftcglyph.h:156
FT_BEGIN_HEADER struct FTC_INodeRec_ * FTC_INode
FT_Done_Glyph(FT_Glyph glyph)
Definition: ftglyph.c:633
Definition: fs.h:78

Referenced by FTC_INode_Free().

◆ ftc_inode_new()

ftc_inode_new ( FTC_Node pinode,
FT_Pointer  gquery,
FTC_Cache  cache 
)

Definition at line 95 of file ftcimage.c.

98 {
99 FTC_INode *pinode = (FTC_INode*)ftcpinode;
100 FTC_GQuery gquery = (FTC_GQuery)ftcgquery;
101
102
103 return FTC_INode_New( pinode, gquery, cache );
104 }
FTC_INode_New(FTC_INode *pinode, FTC_GQuery gquery, FTC_Cache cache)
Definition: ftcimage.c:59

◆ ftc_inode_weight()

ftc_inode_weight ( FTC_Node  inode,
FTC_Cache  cache 
)

Definition at line 108 of file ftcimage.c.

110 {
111 FTC_INode inode = (FTC_INode)ftcinode;
112 FT_Offset size = 0;
113 FT_Glyph glyph = inode->glyph;
114
115 FT_UNUSED( ftccache );
116
117
118 switch ( glyph->format )
119 {
120 case FT_GLYPH_FORMAT_BITMAP:
121 {
122 FT_BitmapGlyph bitg;
123
124
125 bitg = (FT_BitmapGlyph)glyph;
126 size = bitg->bitmap.rows * (FT_Offset)FT_ABS( bitg->bitmap.pitch ) +
127 sizeof ( *bitg );
128 }
129 break;
130
132 {
133 FT_OutlineGlyph outg;
134
135
136 outg = (FT_OutlineGlyph)glyph;
137 size = (FT_Offset)outg->outline.n_points *
138 ( sizeof ( FT_Vector ) + sizeof ( FT_Byte ) ) +
140 sizeof ( *outg );
141 }
142 break;
143
144 default:
145 ;
146 }
147
148 size += sizeof ( *inode );
149 return size;
150 }
struct FT_BitmapGlyphRec_ * FT_BitmapGlyph
Definition: ftglyph.h:127
struct FT_OutlineGlyphRec_ * FT_OutlineGlyph
Definition: ftglyph.h:179
#define FT_ABS(a)
Definition: ftobjs.h:74
smooth FT_Module_Constructor FT_Module_Destructor FT_Module_Requester FT_GLYPH_FORMAT_OUTLINE
Definition: ftsmooth.c:426
unsigned char FT_Byte
Definition: fttypes.h:154
signed short FT_Short
Definition: fttypes.h:198
size_t FT_Offset
Definition: fttypes.h:324
GLsizeiptr size
Definition: glext.h:5919
FT_Bitmap bitmap
Definition: ftglyph.h:165
unsigned int rows
Definition: ftimage.h:263
int pitch
Definition: ftimage.h:265
FT_Glyph_Format format
Definition: ftglyph.h:112
FT_Outline outline
Definition: ftglyph.h:211
short n_contours
Definition: ftimage.h:336
short n_points
Definition: ftimage.h:337
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList

◆ ftc_node_destroy()

ftc_node_destroy ( FTC_Node  node,
FTC_Manager  manager 
)

Definition at line 273 of file ftccache.c.

275 {
277
278
279#ifdef FT_DEBUG_ERROR
280 /* find node's cache */
281 if ( node->cache_index >= manager->num_caches )
282 {
283 FT_TRACE0(( "ftc_node_destroy: invalid node handle\n" ));
284 return;
285 }
286#endif
287
288 cache = manager->caches[node->cache_index];
289
290#ifdef FT_DEBUG_ERROR
291 if ( !cache )
292 {
293 FT_TRACE0(( "ftc_node_destroy: invalid node handle\n" ));
294 return;
295 }
296#endif
297
298 manager->cur_weight -= cache->clazz.node_weight( node, cache );
299
300 /* remove node from mru list */
301 ftc_node_mru_unlink( node, manager );
302
303 /* remove node from cache's hash table */
305
306 /* now finalize it */
307 cache->clazz.node_free( node, cache );
308
309#if 0
310 /* check, just in case of general corruption :-) */
311 if ( manager->num_nodes == 0 )
312 FT_TRACE0(( "ftc_node_destroy: invalid cache node count (%d)\n",
313 manager->num_nodes ));
314#endif
315 }
static void ftc_node_mru_unlink(FTC_Node node, FTC_Manager manager)
Definition: ftccache.c:63
static void ftc_node_hash_unlink(FTC_Node node0, FTC_Cache cache)
Definition: ftccache.c:224
#define FT_TRACE0(varformat)
Definition: ftdebug.h:157
FT_UInt num_caches
Definition: ftcmanag.h:102
FTC_Cache caches[FTC_MAX_CACHES]
Definition: ftcmanag.h:101
FT_Offset cur_weight
Definition: ftcmanag.h:98
FT_UInt num_nodes
Definition: ftcmanag.h:99
Definition: dlist.c:348

Referenced by FTC_Manager_Compress(), and FTC_Manager_FlushN().

◆ ftc_snode_compare()

ftc_snode_compare ( FTC_Node  snode,
FT_Pointer  gquery,
FTC_Cache  cache,
FT_Bool list_changed 
)

Definition at line 327 of file ftcsbits.c.

331 {
332 FTC_SNode snode = (FTC_SNode)ftcsnode;
333 FTC_GQuery gquery = (FTC_GQuery)ftcgquery;
334 FTC_GNode gnode = FTC_GNODE( snode );
335 FT_UInt gindex = gquery->gindex;
337
338
339 if (list_changed)
340 *list_changed = FALSE;
341 result = FT_BOOL( gnode->family == gquery->family &&
342 (FT_UInt)( gindex - gnode->gindex ) < snode->count );
343 if ( result )
344 {
345 /* check if we need to load the glyph bitmap now */
346 FTC_SBit sbit = snode->sbits + ( gindex - gnode->gindex );
347
348
349 /*
350 * The following code illustrates what to do when you want to
351 * perform operations that may fail within a lookup function.
352 *
353 * Here, we want to load a small bitmap on-demand; we thus
354 * need to call the `ftc_snode_load' function which may return
355 * a non-zero error code only when we are out of memory (OOM).
356 *
357 * The correct thing to do is to use @FTC_CACHE_TRYLOOP and
358 * @FTC_CACHE_TRYLOOP_END in order to implement a retry loop
359 * that is capable of flushing the cache incrementally when
360 * an OOM errors occur.
361 *
362 * However, we need to `lock' the node before this operation to
363 * prevent it from being flushed within the loop.
364 *
365 * When we exit the loop, we unlock the node, then check the `error'
366 * variable. If it is non-zero, this means that the cache was
367 * completely flushed and that no usable memory was found to load
368 * the bitmap.
369 *
370 * We then prefer to return a value of 0 (i.e., NO MATCH). This
371 * ensures that the caller will try to allocate a new node.
372 * This operation consequently _fail_ and the lookup function
373 * returns the appropriate OOM error code.
374 *
375 * Note that `buffer == NULL && width == 255' is a hack used to
376 * tag `unavailable' bitmaps in the array. We should never try
377 * to load these.
378 *
379 */
380
381 if ( !sbit->buffer && sbit->width == 255 )
382 {
385
386
387 ftcsnode->ref_count++; /* lock node to prevent flushing */
388 /* in retry loop */
389
391 {
392 error = ftc_snode_load( snode, cache->manager, gindex, &size );
393 }
394 FTC_CACHE_TRYLOOP_END( list_changed );
395
396 ftcsnode->ref_count--; /* unlock the node */
397
398 if ( error )
399 result = 0;
400 else
401 cache->manager->cur_weight += size;
402 }
403 }
404
405 return result;
406 }
#define FTC_CACHE_TRYLOOP_END(list_changed)
Definition: ftccache.h:323
#define FTC_CACHE_TRYLOOP(cache)
Definition: ftccache.h:312
static FT_Error ftc_snode_load(FTC_SNode snode, FTC_Manager manager, FT_UInt gindex, FT_ULong *asize)
Definition: ftcsbits.c:104
struct FTC_SNodeRec_ * FTC_SNode
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:108
unsigned long FT_ULong
Definition: fttypes.h:253
unsigned int FT_UInt
Definition: fttypes.h:231
GLuint64EXT * result
Definition: glext.h:11304
FT_Byte width
Definition: ftcache.h:874
FT_Byte * buffer
Definition: ftcache.h:885
FTC_SBitRec sbits[FTC_SBIT_ITEMS_PER_NODE]
Definition: ftcsbits.h:36
FT_UInt count
Definition: ftcsbits.h:35

Referenced by FTC_SNode_Compare().

◆ ftc_snode_free()

ftc_snode_free ( FTC_Node  snode,
FTC_Cache  cache 
)

Definition at line 67 of file ftcsbits.c.

69 {
70 FTC_SNode snode = (FTC_SNode)ftcsnode;
71 FTC_SBit sbit = snode->sbits;
72 FT_UInt count = snode->count;
73 FT_Memory memory = cache->memory;
74
75
76 for ( ; count > 0; sbit++, count-- )
77 FT_FREE( sbit->buffer );
78
79 FTC_GNode_Done( FTC_GNODE( snode ), cache );
80
81 FT_FREE( snode );
82 }
GLuint GLuint GLsizei count
Definition: gl.h:1545

Referenced by FTC_SNode_Free().

◆ ftc_snode_new()

ftc_snode_new ( FTC_Node psnode,
FT_Pointer  gquery,
FTC_Cache  cache 
)

Definition at line 268 of file ftcsbits.c.

271 {
272 FTC_SNode *psnode = (FTC_SNode*)ftcpsnode;
273 FTC_GQuery gquery = (FTC_GQuery)ftcgquery;
274
275
276 return FTC_SNode_New( psnode, gquery, cache );
277 }
FTC_SNode_New(FTC_SNode *psnode, FTC_GQuery gquery, FTC_Cache cache)
Definition: ftcsbits.c:210

◆ ftc_snode_weight()

ftc_snode_weight ( FTC_Node  snode,
FTC_Cache  cache 
)

Definition at line 281 of file ftcsbits.c.

283 {
284 FTC_SNode snode = (FTC_SNode)ftcsnode;
285 FT_UInt count = snode->count;
286 FTC_SBit sbit = snode->sbits;
287 FT_Int pitch;
289
290 FT_UNUSED( cache );
291
292
294
295 /* the node itself */
296 size = sizeof ( *snode );
297
298 for ( ; count > 0; count--, sbit++ )
299 {
300 if ( sbit->buffer )
301 {
302 pitch = sbit->pitch;
303 if ( pitch < 0 )
304 pitch = -pitch;
305
306 /* add the size of a given glyph image */
307 size += (FT_Offset)pitch * sbit->height;
308 }
309 }
310
311 return size;
312 }
#define FTC_SBIT_ITEMS_PER_NODE
Definition: ftcsbits.h:30
#define FT_ASSERT(condition)
Definition: ftdebug.h:211
signed int FT_Int
Definition: fttypes.h:220
FT_Short pitch
Definition: ftcache.h:881
FT_Byte height
Definition: ftcache.h:875