ReactOS 0.4.16-dev-2357-g35d0dfe
ftccache.h File Reference
Include dependency graph for ftccache.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  FTC_NodeRec_
 
struct  FTC_CacheClassRec_
 
struct  FTC_CacheRec_
 

Macros

#define FTC_FACE_ID_HASH(i)    ( ( (FT_Offset)(i) >> 3 ) ^ ( (FT_Offset)(i) << 7 ) )
 
#define FTC_NODE(x)   ( (FTC_Node)(x) )
 
#define FTC_NODE_P(x)   ( (FTC_Node*)(x) )
 
#define FTC_NODE_NEXT(x)   FTC_NODE( (x)->mru.next )
 
#define FTC_NODE_PREV(x)   FTC_NODE( (x)->mru.prev )
 
#define FTC_NODE_TOP_FOR_HASH(cache, hash)
 
#define FTC_CACHE(x)   ( (FTC_Cache)(x) )
 
#define FTC_CACHE_P(x)   ( (FTC_Cache*)(x) )
 
#define FTC_CACHE_LOOKUP_CMP(cache, nodecmp, hash, query, node, error)
 
#define FTC_CACHE_TRYLOOP(cache)
 
#define FTC_CACHE_TRYLOOP_END(list_changed)
 

Typedefs

typedef struct FTC_CacheRec_FTC_Cache
 
typedef const struct FTC_CacheClassRec_FTC_CacheClass
 
typedef struct FTC_NodeRec_ FTC_NodeRec
 
typedef FT_Error(* FTC_Node_NewFunc) (FTC_Node *pnode, FT_Pointer query, FTC_Cache cache)
 
typedef FT_Offset(* FTC_Node_WeightFunc) (FTC_Node node, FTC_Cache cache)
 
typedef FT_Bool(* FTC_Node_CompareFunc) (FTC_Node node, FT_Pointer key, FTC_Cache cache, FT_Bool *list_changed)
 
typedef void(* FTC_Node_FreeFunc) (FTC_Node node, FTC_Cache cache)
 
typedef FT_Error(* FTC_Cache_InitFunc) (FTC_Cache cache)
 
typedef void(* FTC_Cache_DoneFunc) (FTC_Cache cache)
 
typedef struct FTC_CacheClassRec_ FTC_CacheClassRec
 
typedef struct FTC_CacheRec_ FTC_CacheRec
 

Functions

 FTC_Cache_Init (FTC_Cache cache)
 
 FTC_Cache_Done (FTC_Cache cache)
 
 FTC_Cache_NewNode (FTC_Cache cache, FT_Offset hash, FT_Pointer query, FTC_Node *anode)
 
 FTC_Cache_RemoveFaceID (FTC_Cache cache, FTC_FaceID face_id)
 

Macro Definition Documentation

◆ FTC_CACHE

#define FTC_CACHE (   x)    ( (FTC_Cache)(x) )

Definition at line 161 of file ftccache.h.

◆ FTC_CACHE_LOOKUP_CMP

#define FTC_CACHE_LOOKUP_CMP (   cache,
  nodecmp,
  hash,
  query,
  node,
  error 
)

Definition at line 210 of file ftccache.h.

◆ FTC_CACHE_P

#define FTC_CACHE_P (   x)    ( (FTC_Cache*)(x) )

Definition at line 162 of file ftccache.h.

◆ FTC_CACHE_TRYLOOP

#define FTC_CACHE_TRYLOOP (   cache)
Value:
{ \
FTC_Manager _try_manager = FTC_CACHE( cache )->manager; \
FT_UInt _try_count = 4; \
\
\
for (;;) \
{ \
FT_UInt _try_done;
#define FTC_CACHE(x)
Definition: ftccache.h:161
unsigned int FT_UInt
Definition: fttypes.h:231
Definition: cache.c:49

Definition at line 312 of file ftccache.h.

◆ FTC_CACHE_TRYLOOP_END

#define FTC_CACHE_TRYLOOP_END (   list_changed)
Value:
if ( !error || FT_ERR_NEQ( error, Out_Of_Memory ) ) \
break; \
\
_try_done = FTC_Manager_FlushN( _try_manager, _try_count ); \
if ( _try_done > 0 && list_changed != NULL ) \
*(FT_Bool*)( list_changed ) = TRUE; \
\
if ( _try_done == 0 ) \
break; \
\
if ( _try_done == _try_count ) \
{ \
_try_count *= 2; \
if ( _try_count < _try_done || \
_try_count > _try_manager->num_nodes ) \
_try_count = _try_manager->num_nodes; \
} \
} \
}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
FTC_Manager_FlushN(FTC_Manager manager, FT_UInt count)
Definition: ftcmanag.c:627
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:108
#define FT_ERR_NEQ(x, e)
Definition: fttypes.h:606
#define error(str)
Definition: mkdosfs.c:1605

Definition at line 323 of file ftccache.h.

◆ FTC_FACE_ID_HASH

#define FTC_FACE_ID_HASH (   i)     ( ( (FT_Offset)(i) >> 3 ) ^ ( (FT_Offset)(i) << 7 ) )

Definition at line 27 of file ftccache.h.

◆ FTC_NODE

#define FTC_NODE (   x)    ( (FTC_Node)(x) )

Definition at line 69 of file ftccache.h.

◆ FTC_NODE_NEXT

#define FTC_NODE_NEXT (   x)    FTC_NODE( (x)->mru.next )

Definition at line 72 of file ftccache.h.

◆ FTC_NODE_P

#define FTC_NODE_P (   x)    ( (FTC_Node*)(x) )

Definition at line 70 of file ftccache.h.

◆ FTC_NODE_PREV

#define FTC_NODE_PREV (   x)    FTC_NODE( (x)->mru.prev )

Definition at line 73 of file ftccache.h.

◆ FTC_NODE_TOP_FOR_HASH

#define FTC_NODE_TOP_FOR_HASH (   cache,
  hash 
)
Value:
( ( cache )->buckets + \
( ( ( ( hash ) & ( cache )->mask ) < ( cache )->p ) \
? ( ( hash ) & ( ( cache )->mask * 2 + 1 ) ) \
: ( ( hash ) & ( cache )->mask ) ) )
GLenum GLint GLuint mask
Definition: glext.h:6028
GLfloat GLfloat p
Definition: glext.h:8902
struct list buckets
Definition: threadpool.c:324
Definition: _hash_fun.h:40

Definition at line 76 of file ftccache.h.

Typedef Documentation

◆ FTC_Cache

Definition at line 31 of file ftccache.h.

◆ FTC_Cache_DoneFunc

typedef void(* FTC_Cache_DoneFunc) (FTC_Cache cache)

Definition at line 123 of file ftccache.h.

◆ FTC_Cache_InitFunc

typedef FT_Error(* FTC_Cache_InitFunc) (FTC_Cache cache)

Definition at line 120 of file ftccache.h.

◆ FTC_CacheClass

Definition at line 34 of file ftccache.h.

◆ FTC_CacheClassRec

◆ FTC_CacheRec

◆ FTC_Node_CompareFunc

typedef FT_Bool(* FTC_Node_CompareFunc) (FTC_Node node, FT_Pointer key, FTC_Cache cache, FT_Bool *list_changed)

Definition at line 109 of file ftccache.h.

◆ FTC_Node_FreeFunc

typedef void(* FTC_Node_FreeFunc) (FTC_Node node, FTC_Cache cache)

Definition at line 116 of file ftccache.h.

◆ FTC_Node_NewFunc

typedef FT_Error(* FTC_Node_NewFunc) (FTC_Node *pnode, FT_Pointer query, FTC_Cache cache)

Definition at line 99 of file ftccache.h.

◆ FTC_Node_WeightFunc

typedef FT_Offset(* FTC_Node_WeightFunc) (FTC_Node node, FTC_Cache cache)

Definition at line 104 of file ftccache.h.

◆ FTC_NodeRec

Function Documentation

◆ FTC_Cache_Done()

FTC_Cache_Done ( FTC_Cache  cache)

Definition at line 408 of file ftccache.c.

409 {
411 }
ftc_cache_done(FTC_Cache cache)
Definition: ftccache.c:388

Referenced by ftc_gcache_done().

◆ FTC_Cache_Init()

FTC_Cache_Init ( FTC_Cache  cache)

Definition at line 327 of file ftccache.c.

328 {
329 return ftc_cache_init( cache );
330 }
ftc_cache_init(FTC_Cache cache)
Definition: ftccache.c:334

Referenced by ftc_gcache_init().

◆ FTC_Cache_NewNode()

FTC_Cache_NewNode ( FTC_Cache  cache,
FT_Offset  hash,
FT_Pointer  query,
FTC_Node anode 
)

Definition at line 443 of file ftccache.c.

447 {
450
451
452 /*
453 * We use the FTC_CACHE_TRYLOOP macros to support out-of-memory
454 * errors (OOM) correctly, i.e., by flushing the cache progressively
455 * in order to make more room.
456 */
457
459 {
460 error = cache->clazz.node_new( &node, query, cache );
461 }
463
464 if ( error )
465 node = NULL;
466 else
467 {
468 /* don't assume that the cache has the same number of buckets, since
469 * our allocation request might have triggered global cache flushing
470 */
472 }
473
474 *anode = node;
475 return error;
476 }
static void ftc_cache_add(FTC_Cache cache, FT_Offset hash, FTC_Node node)
Definition: ftccache.c:415
#define FTC_CACHE_TRYLOOP_END(list_changed)
Definition: ftccache.h:323
#define FTC_CACHE_TRYLOOP(cache)
Definition: ftccache.h:312
int FT_Error
Definition: fttypes.h:299
Definition: dlist.c:348

◆ FTC_Cache_RemoveFaceID()

FTC_Cache_RemoveFaceID ( FTC_Cache  cache,
FTC_FaceID  face_id 
)

Definition at line 563 of file ftccache.c.

565 {
566 FT_UFast i, count;
567 FTC_Manager manager = cache->manager;
568 FTC_Node frees = NULL;
569
570
571 count = cache->p + cache->mask + 1;
572 for ( i = 0; i < count; i++ )
573 {
574 FTC_Node* bucket = cache->buckets + i;
575 FTC_Node* pnode = bucket;
576
577
578 for (;;)
579 {
580 FTC_Node node = *pnode;
581 FT_Bool list_changed = FALSE;
582
583
584 if ( !node )
585 break;
586
587 if ( cache->clazz.node_remove_faceid( node, face_id,
588 cache, &list_changed ) )
589 {
590 *pnode = node->link;
591 node->link = frees;
592 frees = node;
593 }
594 else
595 pnode = &node->link;
596 }
597 }
598
599 /* remove all nodes in the free list */
600 while ( frees )
601 {
603
604
605 node = frees;
606 frees = node->link;
607
608 manager->cur_weight -= cache->clazz.node_weight( node, cache );
609 ftc_node_mru_unlink( node, manager );
610
611 cache->clazz.node_free( node, cache );
612
613 cache->slack++;
614 }
615
617 }
#define FALSE
Definition: types.h:117
static void ftc_cache_resize(FTC_Cache cache)
Definition: ftccache.c:112
static void ftc_node_mru_unlink(FTC_Node node, FTC_Manager manager)
Definition: ftccache.c:62
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
FT_Offset cur_weight
Definition: ftcmanag.h:97

Referenced by FTC_Manager_RemoveFaceID().