ReactOS  0.4.14-dev-342-gdc047f9
ftccache.h File Reference
#include "ftcmru.h"
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;
Definition: cache.c:46
#define FTC_CACHE(x)
Definition: ftccache.h:161
#define for
Definition: utility.h:88

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 TRUE
Definition: types.h:120
#define error(str)
Definition: mkdosfs.c:1605
FTC_Manager_FlushN(FTC_Manager manager, FT_UInt count)
Definition: ftcmanag.c:632
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:108
smooth NULL
Definition: ftsmooth.c:416
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define FT_ERR_NEQ(x, e)
Definition: fttypes.h:593

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 ) ) )
Definition: cache.c:46
GLenum GLint GLuint mask
Definition: glext.h:6028
int hash
Definition: main.c:58
static IOleCache * cache
Definition: ole2.c:75
GLfloat GLfloat p
Definition: glext.h:8902
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 124 of file ftccache.h.

◆ FTC_Cache_InitFunc

typedef FT_Error(* FTC_Cache_InitFunc) (FTC_Cache cache)

Definition at line 121 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 110 of file ftccache.h.

◆ FTC_Node_FreeFunc

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

Definition at line 117 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 100 of file ftccache.h.

◆ FTC_Node_WeightFunc

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

Definition at line 105 of file ftccache.h.

◆ FTC_NodeRec

Function Documentation

◆ FTC_Cache_Done()

FTC_Cache_Done ( FTC_Cache  cache)

Definition at line 409 of file ftccache.c.

410  {
412  }
Definition: cache.c:46
ftc_cache_done(FTC_Cache cache)
Definition: ftccache.c:389

Referenced by ftc_gcache_done().

◆ FTC_Cache_Init()

FTC_Cache_Init ( FTC_Cache  cache)

Definition at line 328 of file ftccache.c.

329  {
330  return ftc_cache_init( cache );
331  }
Definition: cache.c:46
ftc_cache_init(FTC_Cache cache)
Definition: ftccache.c:335

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

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

◆ FTC_Cache_RemoveFaceID()

FTC_Cache_RemoveFaceID ( FTC_Cache  cache,
FTC_FaceID  face_id 
)

Definition at line 564 of file ftccache.c.

566  {
567  FT_UFast i, count;
568  FTC_Manager manager = cache->manager;
569  FTC_Node frees = NULL;
570 
571 
572  count = cache->p + cache->mask + 1;
573  for ( i = 0; i < count; i++ )
574  {
575  FTC_Node* bucket = cache->buckets + i;
576  FTC_Node* pnode = bucket;
577 
578 
579  for (;;)
580  {
581  FTC_Node node = *pnode;
582  FT_Bool list_changed = FALSE;
583 
584 
585  if ( !node )
586  break;
587 
588  if ( cache->clazz.node_remove_faceid( node, face_id,
589  cache, &list_changed ) )
590  {
591  *pnode = node->link;
592  node->link = frees;
593  frees = node;
594  }
595  else
596  pnode = &node->link;
597  }
598  }
599 
600  /* remove all nodes in the free list */
601  while ( frees )
602  {
603  FTC_Node node;
604 
605 
606  node = frees;
607  frees = node->link;
608 
609  manager->cur_weight -= cache->clazz.node_weight( node, cache );
610  ftc_node_mru_unlink( node, manager );
611 
612  cache->clazz.node_free( node, cache );
613 
614  cache->slack++;
615  }
616 
618  }
Definition: cache.c:46
GLuint GLuint GLsizei count
Definition: gl.h:1545
FT_Offset cur_weight
Definition: ftcmanag.h:98
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:108
struct node node
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
smooth NULL
Definition: ftsmooth.c:416
static void ftc_cache_resize(FTC_Cache cache)
Definition: ftccache.c:113
static void ftc_node_mru_unlink(FTC_Node node, FTC_Manager manager)
Definition: ftccache.c:63
Definition: dlist.c:348

Referenced by FTC_Manager_RemoveFaceID().