parent
3dc4374f43
commit
dd33561ecb
|
@ -0,0 +1 @@
|
||||||
|
config.mk
|
|
@ -23,11 +23,11 @@
|
||||||
/* - Maintain a mapping between generic FTC_FaceIDs and live FT_Face */
|
/* - Maintain a mapping between generic FTC_FaceIDs and live FT_Face */
|
||||||
/* objects. The mapping itself is performed through a user-provided */
|
/* objects. The mapping itself is performed through a user-provided */
|
||||||
/* callback. However, the manager maintains a small cache of FT_Face */
|
/* callback. However, the manager maintains a small cache of FT_Face */
|
||||||
/* & FT_Size objects in order to speed things considerably. */
|
/* & FT_Size objects in order to speed up things considerably. */
|
||||||
/* */
|
/* */
|
||||||
/* - Manage one or more cache objects. Each cache is in charge of */
|
/* - Manage one or more cache objects. Each cache is in charge of */
|
||||||
/* holding a varying number of `cache nodes'. Each cache node */
|
/* holding a varying number of `cache nodes'. Each cache node */
|
||||||
/* represents a minimal amount of individually-accessible cached */
|
/* represents a minimal amount of individually accessible cached */
|
||||||
/* data. For example, a cache node can be an FT_Glyph image */
|
/* data. For example, a cache node can be an FT_Glyph image */
|
||||||
/* containing a vector outline, or some glyph metrics, or anything */
|
/* containing a vector outline, or some glyph metrics, or anything */
|
||||||
/* else. */
|
/* else. */
|
||||||
|
@ -81,40 +81,41 @@
|
||||||
#define FTC_MAX_CACHES 16
|
#define FTC_MAX_CACHES 16
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************
|
/*************************************************************************/
|
||||||
*
|
/* */
|
||||||
* <Struct> FTC_ManagerRec
|
/* <Struct> */
|
||||||
*
|
/* FTC_ManagerRec */
|
||||||
* <Description>
|
/* */
|
||||||
* the cache manager structure. Each cache manager is in
|
/* <Description> */
|
||||||
* charge of performing two tasks:
|
/* The cache manager structure. */
|
||||||
*
|
/* */
|
||||||
* <Fields>
|
/* <Fields> */
|
||||||
* library :: handle to FreeType library instance
|
/* library :: A handle to a FreeType library instance. */
|
||||||
* faces_lru :: lru list of FT_Face objects in cache
|
/* */
|
||||||
* sizes_lru :: lru list of FT_Size objects in cache
|
/* faces_lru :: The lru list of FT_Face objects in the cache. */
|
||||||
*
|
/* */
|
||||||
* max_bytes :: maximum number of bytes to be allocated
|
/* sizes_lru :: The lru list of FT_Size objects in the cache. */
|
||||||
* in the cache. this is only related to
|
/* */
|
||||||
* the byte size of the nodes cached by
|
/* max_bytes :: The maximum number of bytes to be allocated in the */
|
||||||
* the manager.
|
/* cache. This is only related to the byte size of */
|
||||||
*
|
/* the nodes cached by the manager. */
|
||||||
* num_bytes :: current number of bytes allocated in
|
/* */
|
||||||
* the cache. only related to the byte size
|
/* num_bytes :: The current number of bytes allocated in the */
|
||||||
* of cached nodes.
|
/* cache. Only related to the byte size of cached */
|
||||||
*
|
/* nodes. */
|
||||||
* num_nodes :: current number of nodes in the manager
|
/* */
|
||||||
*
|
/* num_nodes :: The current number of nodes in the manager. */
|
||||||
* global_lru :: the global lru list of all cache nodes
|
/* */
|
||||||
*
|
/* global_lru :: The global lru list of all cache nodes. */
|
||||||
* caches :: a table of installed/registered cache
|
/* */
|
||||||
* objects
|
/* caches :: A table of installed/registered cache objects. */
|
||||||
*
|
/* */
|
||||||
* request_data :: user-provided data passed to the requester
|
/* request_data :: User-provided data passed to the requester. */
|
||||||
* request_face :: user-provided function used to implement
|
/* */
|
||||||
* a mapping between abstract FTC_FaceIDs
|
/* request_face :: User-provided function used to implement a mapping */
|
||||||
* and real FT_Face objects..
|
/* between abstract FTC_FaceIDs and real FT_Face */
|
||||||
*/
|
/* objects. */
|
||||||
|
/* */
|
||||||
typedef struct FTC_ManagerRec_
|
typedef struct FTC_ManagerRec_
|
||||||
{
|
{
|
||||||
FT_Library library;
|
FT_Library library;
|
||||||
|
@ -133,28 +134,27 @@
|
||||||
} FTC_ManagerRec;
|
} FTC_ManagerRec;
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/*************************************************************************/
|
||||||
*
|
/* */
|
||||||
* <Function> FTC_Manager_Compress
|
/* <Function> */
|
||||||
*
|
/* FTC_Manager_Compress */
|
||||||
* <Description>
|
/* */
|
||||||
* this function is used to check the state of the cache manager
|
/* <Description> */
|
||||||
* if its "num_bytes" field is greater than its "max_bytes"
|
/* This function is used to check the state of the cache manager if */
|
||||||
* field, this function will flush as many old cache nodes as
|
/* its `num_bytes' field is greater than its `max_bytes' field. It */
|
||||||
* possible (ignoring cache nodes with a non-zero reference
|
/* will flush as many old cache nodes as possible (ignoring cache */
|
||||||
* count).
|
/* nodes with a non-zero reference count). */
|
||||||
*
|
/* */
|
||||||
* <input>
|
/* <Input> */
|
||||||
* manager :: handle to cache manager
|
/* manager :: A handle to the cache manager. */
|
||||||
*
|
/* */
|
||||||
* <note>
|
/* <Note> */
|
||||||
* client applications should not call this function directly.
|
/* Client applications should not call this function directly. It is */
|
||||||
* it is normally invoked by specific cache implementations.
|
/* normally invoked by specific cache implementations. */
|
||||||
*
|
/* */
|
||||||
* the reason this function is exported is to allow client-
|
/* The reason this function is exported is to allow client-specific */
|
||||||
* specific cache classes..
|
/* cache classes. */
|
||||||
*
|
/* */
|
||||||
*/
|
|
||||||
FT_EXPORT_DEF( void ) FTC_Manager_Compress( FTC_Manager manager );
|
FT_EXPORT_DEF( void ) FTC_Manager_Compress( FTC_Manager manager );
|
||||||
|
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@
|
||||||
typedef FTC_CacheNodeRec* FTC_CacheNode;
|
typedef FTC_CacheNodeRec* FTC_CacheNode;
|
||||||
|
|
||||||
|
|
||||||
/* the fields `cachenode.data' is typecasted to this type */
|
/* the field `cachenode.data' is typecast to this type */
|
||||||
typedef struct FTC_CacheNode_Data_
|
typedef struct FTC_CacheNode_Data_
|
||||||
{
|
{
|
||||||
FT_UShort cache_index;
|
FT_UShort cache_index;
|
||||||
|
@ -190,63 +190,73 @@
|
||||||
|
|
||||||
} FTC_CacheNode_Data;
|
} FTC_CacheNode_Data;
|
||||||
|
|
||||||
/* return a pointer to the FTC_CacheNode_Data contained in a */
|
|
||||||
/* CacheNode's `data' field */
|
/* return a pointer to FTC_CacheNode_Data contained in a */
|
||||||
|
/* CacheNode's `data' field */
|
||||||
#define FTC_CACHENODE_TO_DATA_P( n ) \
|
#define FTC_CACHENODE_TO_DATA_P( n ) \
|
||||||
( (FTC_CacheNode_Data*)&(n)->data )
|
( (FTC_CacheNode_Data*)&(n)->data )
|
||||||
|
|
||||||
#define FTC_LIST_TO_CACHENODE( n ) ( (FTC_CacheNode)(n) )
|
#define FTC_LIST_TO_CACHENODE( n ) ( (FTC_CacheNode)(n) )
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
*
|
/*************************************************************************/
|
||||||
* <FuncType> FTC_CacheNode_SizeFunc
|
/* */
|
||||||
*
|
/* <FuncType> */
|
||||||
* <Description>
|
/* FTC_CacheNode_SizeFunc */
|
||||||
* a function used to compute the total size in bytes of a given
|
/* */
|
||||||
* cache node. It is used by the cache manager to compute the
|
/* <Description> */
|
||||||
* number of old nodes to flush when the cache is full..
|
/* A function used to compute the total size in bytes of a given */
|
||||||
*
|
/* cache node. It is used by the cache manager to compute the number */
|
||||||
* <Input>
|
/* of old nodes to flush when the cache is full. */
|
||||||
* node :: handle to target cache node
|
/* */
|
||||||
* cache_data :: a generic pointer passed to the destructor.
|
/* <Input> */
|
||||||
*/
|
/* node :: A handle to the target cache node. */
|
||||||
|
/* */
|
||||||
|
/* cache_data :: A generic pointer passed to the destructor. */
|
||||||
|
/* */
|
||||||
typedef FT_ULong (*FTC_CacheNode_SizeFunc)( FTC_CacheNode node,
|
typedef FT_ULong (*FTC_CacheNode_SizeFunc)( FTC_CacheNode node,
|
||||||
FT_Pointer cache_data );
|
FT_Pointer cache_data );
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
*
|
/*************************************************************************/
|
||||||
* <FuncType> FTC_CacheNode_DestroyFunc
|
/* */
|
||||||
*
|
/* <FuncType> */
|
||||||
* <Description>
|
/* FTC_CacheNode_DestroyFunc */
|
||||||
* a function used to destroy a given cache node. It is called
|
/* */
|
||||||
* by the manager when the cache is full and old nodes need to
|
/* <Description> */
|
||||||
* be flushed out..
|
/* A function used to destroy a given cache node. It is called by */
|
||||||
*
|
/* the manager when the cache is full and old nodes need to be */
|
||||||
* <Input>
|
/* flushed out. */
|
||||||
* node :: handle to target cache node
|
/* */
|
||||||
* cache_data :: a generic pointer passed to the destructor.
|
/* <Input> */
|
||||||
*/
|
/* node :: A handle to the target cache node. */
|
||||||
|
/* */
|
||||||
|
/* cache_data :: A generic pointer passed to the destructor. */
|
||||||
|
/* */
|
||||||
typedef void (*FTC_CacheNode_DestroyFunc)( FTC_CacheNode node,
|
typedef void (*FTC_CacheNode_DestroyFunc)( FTC_CacheNode node,
|
||||||
FT_Pointer cache_data );
|
FT_Pointer cache_data );
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
*
|
/*************************************************************************/
|
||||||
* <Struct> FTC_CacheNode_Class
|
/* */
|
||||||
*
|
/* <Struct> */
|
||||||
* <Description>
|
/* FTC_CacheNode_Class */
|
||||||
* a very simple structure used to describe a cache node's class
|
/* */
|
||||||
* to the cache manager
|
/* <Description> */
|
||||||
*
|
/* A very simple structure used to describe a cache node's class to */
|
||||||
* <Fields>
|
/* the cache manager. */
|
||||||
* size_node :: a function used to size the node
|
/* */
|
||||||
* destroy_node :: a function used to destroy the node
|
/* <Fields> */
|
||||||
*
|
/* size_node :: A function used to size the node. */
|
||||||
* <Note>
|
/* */
|
||||||
* the cache node class doesn't include a "new_node" function
|
/* destroy_node :: A function used to destroy the node. */
|
||||||
* because the cache manager never allocates cache node directly,
|
/* */
|
||||||
* it delegates this task to its cache objects..
|
/* <Note> */
|
||||||
*
|
/* The cache node class doesn't include a `new_node' function because */
|
||||||
*/
|
/* the cache manager never allocates cache node directly; it */
|
||||||
|
/* delegates this task to its cache objects. */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
typedef struct FTC_CacheNode_Class_
|
typedef struct FTC_CacheNode_Class_
|
||||||
{
|
{
|
||||||
FTC_CacheNode_SizeFunc size_node;
|
FTC_CacheNode_SizeFunc size_node;
|
||||||
|
@ -264,45 +274,50 @@
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/*************************************************************************/
|
||||||
*
|
/* */
|
||||||
* <FuncType> FTC_Cache_InitFunc
|
/* <FuncType> */
|
||||||
*
|
/* FTC_Cache_InitFunc */
|
||||||
* <Description>
|
/* */
|
||||||
* a function used to initialize a given cache object
|
/* <Description> */
|
||||||
*
|
/* A function used to initialize a given cache object. */
|
||||||
* <Input>
|
/* */
|
||||||
* cache :: handle to new cache
|
/* <Input> */
|
||||||
*/
|
/* cache :: A handle to the new cache. */
|
||||||
|
/* */
|
||||||
typedef FT_Error (*FTC_Cache_InitFunc)( FTC_Cache cache );
|
typedef FT_Error (*FTC_Cache_InitFunc)( FTC_Cache cache );
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/*************************************************************************/
|
||||||
*
|
/* */
|
||||||
* <FuncType> FTC_Cache_DoneFunc
|
/* <FuncType> */
|
||||||
*
|
/* FTC_Cache_DoneFunc */
|
||||||
* <Description>
|
/* */
|
||||||
* a function used to finalize a given cache object
|
/* <Description> */
|
||||||
*
|
/* A function to finalize a given cache object. */
|
||||||
* <Input>
|
/* */
|
||||||
* cache :: handle to target cache
|
/* <Input> */
|
||||||
*/
|
/* cache :: A handle to the target cache. */
|
||||||
typedef void (*FTC_Cache_DoneFunc)( FTC_Cache cache );
|
/* */
|
||||||
|
typedef void (*FTC_Cache_DoneFunc)( FTC_Cache cache );
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/*************************************************************************/
|
||||||
*
|
/* */
|
||||||
* <Struct> FTC_Cache_Class
|
/* <Struct> */
|
||||||
*
|
/* FTC_Cache_Class */
|
||||||
* <Description>
|
/* */
|
||||||
* a structure used to describe a given cache object class to
|
/* <Description> */
|
||||||
* the cache manager.
|
/* A structure used to describe a given cache object class to the */
|
||||||
*
|
/* cache manager. */
|
||||||
* <Fields>
|
/* */
|
||||||
* cache_byte_size :: size of cache object in bytes
|
/* <Fields> */
|
||||||
* init_cache :: cache object initializer
|
/* cache_byte_size :: The size of the cache object in bytes. */
|
||||||
* done_cache :: cache object finalizer
|
/* */
|
||||||
*/
|
/* init_cache :: The cache object initializer. */
|
||||||
|
/* */
|
||||||
|
/* done_cache :: The cache object finalizer. */
|
||||||
|
/* */
|
||||||
struct FTC_Cache_Class_
|
struct FTC_Cache_Class_
|
||||||
{
|
{
|
||||||
FT_UInt cache_byte_size;
|
FT_UInt cache_byte_size;
|
||||||
|
@ -311,22 +326,28 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/*************************************************************************/
|
||||||
*
|
/* */
|
||||||
* <Struct> FTC_CacheRec
|
/* <Struct> */
|
||||||
*
|
/* FTC_CacheRec */
|
||||||
* <Description>
|
/* */
|
||||||
* a structure used to describe an abstract cache object
|
/* <Description> */
|
||||||
*
|
/* A structure used to describe an abstract cache object. */
|
||||||
* <Fields>
|
/* */
|
||||||
* manager :: handle to parent cache manager
|
/* <Fields> */
|
||||||
* memory :: handle to memory manager
|
/* manager :: A handle to the parent cache manager. */
|
||||||
* clazz :: pointer to cache clazz
|
/* */
|
||||||
* node_clazz :: pointer to cache's node clazz
|
/* memory :: A handle to the memory manager. */
|
||||||
*
|
/* */
|
||||||
* cache_index :: index of cache in manager's table
|
/* clazz :: A pointer to the cache class. */
|
||||||
* cache_data :: data passed to the cache node constructor/finalizer
|
/* */
|
||||||
*/
|
/* node_clazz :: A pointer to the cache's node class. */
|
||||||
|
/* */
|
||||||
|
/* cache_index :: An index of the cache in the manager's table. */
|
||||||
|
/* */
|
||||||
|
/* cache_data :: Data passed to the cache node */
|
||||||
|
/* constructor/finalizer. */
|
||||||
|
/* */
|
||||||
typedef struct FTC_CacheRec_
|
typedef struct FTC_CacheRec_
|
||||||
{
|
{
|
||||||
FTC_Manager manager;
|
FTC_Manager manager;
|
||||||
|
@ -340,7 +361,6 @@
|
||||||
} FTC_CacheRec;
|
} FTC_CacheRec;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/* */
|
/* */
|
||||||
/* ftcsbits.h */
|
/* ftcsbits.h */
|
||||||
/* */
|
/* */
|
||||||
/* a small-bitmaps cache (specification). */
|
/* A small-bitmap cache (specification). */
|
||||||
/* */
|
/* */
|
||||||
/* Copyright 2000 by */
|
/* Copyright 2000 by */
|
||||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||||
|
@ -15,25 +15,27 @@
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#ifndef FTCSBITS_H
|
#ifndef FTCSBITS_H
|
||||||
#define FTCSBITS_H
|
#define FTCSBITS_H
|
||||||
|
|
||||||
|
|
||||||
#include <freetype/cache/ftcchunk.h>
|
#include <freetype/cache/ftcchunk.h>
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* handle to small bitmap */
|
|
||||||
typedef struct FTC_SBitRec_* FTC_SBit;
|
|
||||||
|
|
||||||
|
/* handle to small bitmap */
|
||||||
|
typedef struct FTC_SBitRec_* FTC_SBit;
|
||||||
|
|
||||||
/* handle to small bitmap cache */
|
/* handle to small bitmap cache */
|
||||||
typedef struct FTC_SBit_CacheRec_* FTC_SBit_Cache;
|
typedef struct FTC_SBit_CacheRec_* FTC_SBit_Cache;
|
||||||
|
|
||||||
|
/* a compact structure used to hold a single small bitmap */
|
||||||
/* a compact structure used to hold a single small bitmap */
|
typedef struct FTC_SBitRec_
|
||||||
typedef struct FTC_SBitRec_
|
|
||||||
{
|
{
|
||||||
FT_Byte width;
|
FT_Byte width;
|
||||||
FT_Byte height;
|
FT_Byte height;
|
||||||
|
@ -50,16 +52,13 @@
|
||||||
} FTC_SBitRec;
|
} FTC_SBitRec;
|
||||||
|
|
||||||
|
|
||||||
FT_EXPORT_DEF( FT_Error )
|
FT_EXPORT_DEF( FT_Error ) FTC_SBit_Cache_New( FTC_Manager manager,
|
||||||
FTC_SBit_Cache_New( FTC_Manager manager,
|
FTC_SBit_Cache* acache );
|
||||||
FTC_SBit_Cache *acache );
|
|
||||||
|
|
||||||
|
FT_EXPORT_DEF( FT_Error ) FTC_SBit_Cache_Lookup( FTC_SBit_Cache cache,
|
||||||
FT_EXPORT_DEF( FT_Error )
|
FTC_Image_Desc* desc,
|
||||||
FTC_SBit_Cache_Lookup( FTC_SBit_Cache cache,
|
FT_UInt gindex,
|
||||||
FTC_Image_Desc* desc,
|
FTC_SBit *sbit );
|
||||||
FT_UInt gindex,
|
|
||||||
FTC_SBit *sbit );
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -69,5 +68,5 @@
|
||||||
|
|
||||||
#endif /* FTCSBITS_H */
|
#endif /* FTCSBITS_H */
|
||||||
|
|
||||||
/* END */
|
|
||||||
|
|
||||||
|
/* END */
|
||||||
|
|
Loading…
Reference in New Issue