ReactOS 0.4.16-dev-2354-g16de117
ftccback.h File Reference
#include <freetype/ftcache.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

FT_BEGIN_HEADER 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 388 of file ftccache.c.

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

Referenced by FTC_Cache_Done().

◆ ftc_cache_init()

ftc_cache_init ( FTC_Cache  cache)

Definition at line 334 of file ftccache.c.

335 {
336 FT_Memory memory = cache->memory;
338
339
340 cache->p = 0;
341 cache->mask = FTC_HASH_INITIAL_SIZE - 1;
343
345 return error;
346 }
#define FTC_HASH_INITIAL_SIZE
Definition: ftccache.c:35
#define FTC_HASH_MAX_LOAD
Definition: ftccache.c:30
#define FT_NEW_ARRAY(ptr, count)
Definition: ftmemory.h:341
int FT_Error
Definition: fttypes.h:299
#define error(str)
Definition: mkdosfs.c:1605

Referenced by FTC_Cache_Init().

◆ ftc_gcache_done()

ftc_gcache_done ( FTC_Cache  cache)

Definition at line 152 of file ftcglyph.c.

153 {
154 FTC_GCache cache = (FTC_GCache)ftccache;
155
156
158 FTC_MruList_Done( &cache->families );
159 }
FTC_Cache_Done(FTC_Cache cache)
Definition: ftccache.c:408
struct FTC_GCacheRec_ * FTC_GCache
FTC_MruList_Done(FTC_MruList list)
Definition: ftcmru.c:194

◆ ftc_gcache_init()

ftc_gcache_init ( FTC_Cache  cache)

Definition at line 118 of file ftcglyph.c.

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

◆ ftc_gnode_compare()

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

Definition at line 65 of file ftcglyph.c.

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

Referenced by FTC_GNode_Compare().

◆ ftc_inode_free()

FT_BEGIN_HEADER ftc_inode_free ( FTC_Node  inode,
FTC_Cache  cache 
)

Definition at line 30 of file ftcimage.c.

32 {
33 FTC_INode inode = (FTC_INode)ftcinode;
34 FT_Memory memory = cache->memory;
35
36
37 if ( inode->glyph )
38 {
39 FT_Done_Glyph( inode->glyph );
40 inode->glyph = NULL;
41 }
42
44 FT_FREE( inode );
45 }
FTC_GNode_Done(FTC_GNode gnode, FTC_Cache cache)
Definition: ftcglyph.c:54
#define FTC_GNODE(x)
Definition: ftcglyph.h:155
FT_BEGIN_HEADER struct FTC_INodeRec_ * FTC_INode
FT_Done_Glyph(FT_Glyph glyph)
Definition: ftglyph.c:641
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 94 of file ftcimage.c.

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

◆ ftc_inode_weight()

ftc_inode_weight ( FTC_Node  inode,
FTC_Cache  cache 
)

Definition at line 107 of file ftcimage.c.

109 {
110 FTC_INode inode = (FTC_INode)ftcinode;
111 FT_Offset size = 0;
112 FT_Glyph glyph = inode->glyph;
113
114 FT_UNUSED( ftccache );
115
116
117 switch ( glyph->format )
118 {
119 case FT_GLYPH_FORMAT_BITMAP:
120 {
121 FT_BitmapGlyph bitg;
122
123
124 bitg = (FT_BitmapGlyph)glyph;
125 size = bitg->bitmap.rows * (FT_Offset)FT_ABS( bitg->bitmap.pitch ) +
126 sizeof ( *bitg );
127 }
128 break;
129
130 case FT_GLYPH_FORMAT_OUTLINE:
131 {
132 FT_OutlineGlyph outg;
133
134
135 outg = (FT_OutlineGlyph)glyph;
136 size = (FT_Offset)outg->outline.n_points *
137 ( sizeof ( FT_Vector ) + sizeof ( FT_Byte ) ) +
139 sizeof ( *outg );
140 }
141 break;
142
143 default:
144 ;
145 }
146
147 size += sizeof ( *inode );
148 return size;
149 }
struct FT_BitmapGlyphRec_ * FT_BitmapGlyph
Definition: ftglyph.h:131
struct FT_OutlineGlyphRec_ * FT_OutlineGlyph
Definition: ftglyph.h:186
#define FT_ABS(a)
Definition: ftobjs.h:73
unsigned char FT_Byte
Definition: fttypes.h:154
signed short FT_Short
Definition: fttypes.h:198
size_t FT_Offset
Definition: fttypes.h:323
GLsizeiptr size
Definition: glext.h:5919
FT_Bitmap bitmap
Definition: ftglyph.h:172
unsigned int rows
Definition: ftimage.h:262
int pitch
Definition: ftimage.h:264
FT_Glyph_Format format
Definition: ftglyph.h:116
FT_Outline outline
Definition: ftglyph.h:220
short n_contours
Definition: ftimage.h:338
short n_points
Definition: ftimage.h:339
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList

◆ ftc_node_destroy()

ftc_node_destroy ( FTC_Node  node,
FTC_Manager  manager 
)

Definition at line 272 of file ftccache.c.

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

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

Referenced by FTC_SNode_Compare().

◆ ftc_snode_free()

ftc_snode_free ( FTC_Node  snode,
FTC_Cache  cache 
)

Definition at line 66 of file ftcsbits.c.

68 {
69 FTC_SNode snode = (FTC_SNode)ftcsnode;
70 FTC_SBit sbit = snode->sbits;
71 FT_UInt count = snode->count;
72 FT_Memory memory = cache->memory;
73
74
75 for ( ; count > 0; sbit++, count-- )
76 FT_FREE( sbit->buffer );
77
78 FTC_GNode_Done( FTC_GNODE( snode ), cache );
79
80 FT_FREE( snode );
81 }
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 267 of file ftcsbits.c.

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

◆ ftc_snode_weight()

ftc_snode_weight ( FTC_Node  snode,
FTC_Cache  cache 
)

Definition at line 280 of file ftcsbits.c.

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