diff --git a/include/freetype/cache/ftcchunk.h b/include/freetype/cache/ftcchunk.h index c2ee555df..0a493cb1c 100644 --- a/include/freetype/cache/ftcchunk.h +++ b/include/freetype/cache/ftcchunk.h @@ -54,7 +54,7 @@ extern "C" { #endif -/* maximum number of chunk sets in a given chunk cache */ + /* maximum number of chunk sets in a given chunk cache */ #define FTC_MAX_CHUNK_SETS 16 @@ -62,32 +62,32 @@ typedef struct FTC_ChunkSetRec_* FTC_ChunkSet; typedef struct FTC_Chunk_CacheRec_* FTC_Chunk_Cache; - typedef struct FTC_ChunkNodeRec_ + typedef struct FTC_ChunkNodeRec_ { - FTC_CacheNodeRec root; - FTC_ChunkSet cset; - FT_UShort cset_index; - FT_UShort num_elements; - FT_Byte* elements; + FTC_CacheNodeRec root; + FTC_ChunkSet cset; + FT_UShort cset_index; + FT_UShort num_elements; + FT_Byte* elements; } FTC_ChunkNodeRec; -#define FTC_CHUNKNODE_TO_LRUNODE(x) ((FT_ListNode)(x)) -#define FTC_LRUNODE_TO_CHUNKNODE(x) ((FTC_ChunkNode)(x)) + +#define FTC_CHUNKNODE_TO_LRUNODE( x ) ((FT_ListNode)( x )) +#define FTC_LRUNODE_TO_CHUNKNODE( x ) ((FTC_ChunkNode)( x )) + /*************************************************************************/ /* */ /* chunk set methods */ /* */ - /* used to set "element_max", "element_count" and "element_size" */ - typedef FT_Error (*FTC_ChunkSet_SizesFunc) ( FTC_ChunkSet cset, - FT_Pointer type ); - - - typedef FT_Error (*FTC_ChunkSet_InitFunc) ( FTC_ChunkSet cset, - FT_Pointer type ); + /* used to set "element_max", "element_count" and "element_size" */ + typedef FT_Error (*FTC_ChunkSet_SizesFunc) ( FTC_ChunkSet cset, + FT_Pointer type ); + typedef FT_Error (*FTC_ChunkSet_InitFunc) ( FTC_ChunkSet cset, + FT_Pointer type ); typedef void (*FTC_ChunkSet_DoneFunc) ( FTC_ChunkSet cset ); @@ -95,14 +95,13 @@ FT_Pointer type ); + typedef FT_Error (*FTC_ChunkSet_NewNodeFunc) ( FTC_ChunkSet cset, + FT_UInt index, + FTC_ChunkNode* anode ); - typedef FT_Error (*FTC_ChunkSet_NewNodeFunc)( FTC_ChunkSet cset, - FT_UInt index, - FTC_ChunkNode* anode ); + typedef void (*FTC_ChunkSet_DestroyNodeFunc)( FTC_ChunkNode node ); - typedef void (*FTC_ChunkSet_DestroyNodeFunc)( FTC_ChunkNode node ); - - typedef FT_ULong (*FTC_ChunkSet_SizeNodeFunc) ( FTC_ChunkNode node ); + typedef FT_ULong (*FTC_ChunkSet_SizeNodeFunc) ( FTC_ChunkNode node ); typedef struct FTC_ChunkSet_Class_ @@ -151,24 +150,24 @@ /* the abstract chunk cache object */ typedef struct FTC_Chunk_CacheRec_ { - FTC_CacheRec root; - FT_Lru csets_lru; /* static chunk set lru list */ - FTC_ChunkSet last_cset; /* small cache :-) */ + FTC_CacheRec root; + FT_Lru csets_lru; /* static chunk set lru list */ + FTC_ChunkSet last_cset; /* small cache :-) */ } FTC_Chunk_CacheRec; + /*************************************************************************/ /* */ /* These functions are exported so that they can be called from */ - /* user-provided cache classes; otherwise, they are really parts of the */ + /* user-provided cache classes; otherwise, they are really part of the */ /* cache sub-system internals. */ /* */ - FT_EXPORT_FUNC( FT_Error ) - FTC_ChunkNode_Init( FTC_ChunkNode node, - FTC_ChunkSet cset, - FT_UInt index, - FT_Bool alloc ); + FT_EXPORT_FUNC( FT_Error ) FTC_ChunkNode_Init( FTC_ChunkNode node, + FTC_ChunkSet cset, + FT_UInt index, + FT_Bool alloc ); #define FTC_ChunkNode_Ref( n ) \ FTC_CACHENODE_TO_DATA_P( &(n)->root )->ref_count++ @@ -177,33 +176,24 @@ FTC_CACHENODE_TO_DATA_P( &(n)->root )->ref_count-- - FT_EXPORT_DEF( void ) - FTC_ChunkNode_Destroy( FTC_ChunkNode node ); + FT_EXPORT_DEF( void ) FTC_ChunkNode_Destroy( FTC_ChunkNode node ); + + FT_EXPORT_DEF( FT_Error ) FTC_Chunk_Cache_Init( FTC_Chunk_Cache cache ); + + FT_EXPORT_DEF( void ) FTC_Chunk_Cache_Done( FTC_Chunk_Cache cache ); + FT_EXPORT_DEF( FT_Error ) FTC_ChunkSet_New( FTC_Chunk_Cache cache, + FT_Pointer type, + FTC_ChunkSet* aset ); - FT_EXPORT_DEF( FT_Error ) - FTC_Chunk_Cache_Init( FTC_Chunk_Cache cache ); + FT_EXPORT_DEF( FT_Error ) FTC_ChunkSet_Lookup_Node( + FTC_ChunkSet cset, + FT_UInt glyph_index, + FTC_ChunkNode* anode, + FT_UInt* aindex ); - FT_EXPORT_DEF( void ) - FTC_Chunk_Cache_Done( FTC_Chunk_Cache cache ); - - - - - FT_EXPORT_DEF( FT_Error ) - FTC_ChunkSet_New( FTC_Chunk_Cache cache, - FT_Pointer type, - FTC_ChunkSet *aset ); - - - FT_EXPORT_DEF( FT_Error ) - FTC_ChunkSet_Lookup_Node( FTC_ChunkSet cset, - FT_UInt glyph_index, - FTC_ChunkNode *anode, - FT_UInt *aindex ); - #ifdef __cplusplus } #endif @@ -211,4 +201,5 @@ #endif /* FTCCHUNK_H */ + /* END */ diff --git a/include/freetype/cache/ftcglyph.h b/include/freetype/cache/ftcglyph.h index ca70492b1..8a0acbd88 100644 --- a/include/freetype/cache/ftcglyph.h +++ b/include/freetype/cache/ftcglyph.h @@ -24,13 +24,13 @@ /* For example, see `ftcimage.h' and `ftcimage.c' which */ /* implement a FT_Glyph cache based on this code. */ /* */ - /* NOTE: for now, each glyph set is implemented as a static hash table */ - /* it's be interesting to experiment with dynamic hashes to see */ - /* if this improves performance or not (I don't know why but */ - /* something tells me it won't ?!) */ + /* NOTE: For now, each glyph set is implemented as a static hash table. */ + /* It would be interesting to experiment with dynamic hashes to */ + /* see whether this improves performance or not (I don't know why */ + /* but something tells me it won't). */ /* */ - /* in all cases, this change should not affect any derived */ - /* glyph cache class.. */ + /* In all cases, this change should not affect any derived glyph */ + /* cache class. */ /* */ /*************************************************************************/ @@ -69,11 +69,12 @@ #define FTC_MAX_GLYPH_SETS 16 #define FTC_GSET_HASH_SIZE_DEFAULT 64 + typedef struct FTC_GlyphSetRec_* FTC_GlyphSet; typedef struct FTC_GlyphNodeRec_* FTC_GlyphNode; typedef struct FTC_Glyph_CacheRec_* FTC_Glyph_Cache; - typedef struct FTC_GlyphNodeRec_ + typedef struct FTC_GlyphNodeRec_ { FTC_CacheNodeRec root; FTC_GlyphNode gset_next; /* next in glyph set's bucket list */ @@ -83,9 +84,9 @@ } FTC_GlyphNodeRec; -#define FTC_GLYPHNODE(x) ( (FTC_GlyphNode)(x) ) -#define FTC_GLYPHNODE_TO_LRUNODE( n ) ( (FT_ListNode)(n) ) -#define FTC_LRUNODE_TO_GLYPHNODE( n ) ( (FTC_GlyphNode)(n) ) +#define FTC_GLYPHNODE( x ) ( (FTC_GlyphNode)( x ) ) +#define FTC_GLYPHNODE_TO_LRUNODE( n ) ( (FT_ListNode)( n ) ) +#define FTC_LRUNODE_TO_GLYPHNODE( n ) ( (FTC_GlyphNode)( n ) ) /*************************************************************************/ @@ -93,24 +94,24 @@ /* Glyph set methods. */ /* */ - typedef FT_Error (*FTC_GlyphSet_InitFunc) ( FTC_GlyphSet gset, - FT_Pointer type ); + typedef FT_Error (*FTC_GlyphSet_InitFunc) ( FTC_GlyphSet gset, + FT_Pointer type ); - typedef void (*FTC_GlyphSet_DoneFunc) ( FTC_GlyphSet gset ); + typedef void (*FTC_GlyphSet_DoneFunc) ( FTC_GlyphSet gset ); - typedef FT_Bool (*FTC_GlyphSet_CompareFunc)( FTC_GlyphSet gset, - FT_Pointer type ); + typedef FT_Bool (*FTC_GlyphSet_CompareFunc) ( FTC_GlyphSet gset, + FT_Pointer type ); - typedef FT_Error (*FTC_GlyphSet_NewNodeFunc)( FTC_GlyphSet gset, - FT_UInt gindex, - FTC_GlyphNode *anode ); + typedef FT_Error (*FTC_GlyphSet_NewNodeFunc) ( FTC_GlyphSet gset, + FT_UInt gindex, + FTC_GlyphNode* anode ); - typedef void (*FTC_GlyphSet_DestroyNodeFunc)( FTC_GlyphNode node, - FTC_GlyphSet gset ); + typedef void (*FTC_GlyphSet_DestroyNodeFunc)( FTC_GlyphNode node, + FTC_GlyphSet gset ); - typedef FT_ULong (*FTC_GlyphSet_SizeNodeFunc)( FTC_GlyphNode node, - FTC_GlyphSet gset ); + typedef FT_ULong (*FTC_GlyphSet_SizeNodeFunc) ( FTC_GlyphNode node, + FTC_GlyphSet gset ); typedef struct FTC_GlyphSet_Class_ @@ -154,8 +155,8 @@ typedef struct FTC_Glyph_CacheRec_ { FTC_CacheRec root; - FT_Lru gsets_lru; /* static sets lru list */ - FTC_GlyphSet last_gset; /* small cache :o) */ + FT_Lru gsets_lru; /* static sets lru list */ + FTC_GlyphSet last_gset; /* small cache :-) */ } FTC_Glyph_CacheRec; @@ -163,14 +164,13 @@ /*************************************************************************/ /* */ /* These functions are exported so that they can be called from */ - /* user-provided cache classes; otherwise, they are really parts of the */ + /* user-provided cache classes; otherwise, they are really part of the */ /* cache sub-system internals. */ /* */ - FT_EXPORT_FUNC( void ) - FTC_GlyphNode_Init( FTC_GlyphNode node, - FTC_GlyphSet gset, - FT_UInt gindex ); + FT_EXPORT_FUNC( void ) FTC_GlyphNode_Init( FTC_GlyphNode node, + FTC_GlyphSet gset, + FT_UInt gindex ); #define FTC_GlyphNode_Ref( n ) \ FTC_CACHENODE_TO_DATA_P( &(n)->root )->ref_count++ @@ -179,32 +179,22 @@ FTC_CACHENODE_TO_DATA_P( &(n)->root )->ref_count-- - FT_EXPORT_DEF( void ) - FTC_GlyphNode_Destroy( FTC_GlyphNode node, - FTC_Glyph_Cache cache ); + FT_EXPORT_DEF( void ) FTC_GlyphNode_Destroy( FTC_GlyphNode node, + FTC_Glyph_Cache cache ); + + FT_EXPORT_DEF( FT_Error ) FTC_Glyph_Cache_Init( FTC_Glyph_Cache cache ); + + FT_EXPORT_DEF( void ) FTC_Glyph_Cache_Done( FTC_Glyph_Cache cache ); + FT_EXPORT_DEF( FT_Error ) FTC_GlyphSet_New( FTC_Glyph_Cache cache, + FT_Pointer type, + FTC_GlyphSet* aset ); - FT_EXPORT_DEF( FT_Error ) - FTC_Glyph_Cache_Init( FTC_Glyph_Cache cache ); - - - FT_EXPORT_DEF( void ) - FTC_Glyph_Cache_Done( FTC_Glyph_Cache cache ); - - - - - FT_EXPORT_DEF( FT_Error ) - FTC_GlyphSet_New( FTC_Glyph_Cache cache, - FT_Pointer type, - FTC_GlyphSet *aset ); - - - FT_EXPORT_DEF( FT_Error ) - FTC_GlyphSet_Lookup_Node( FTC_GlyphSet gset, - FT_UInt glyph_index, - FTC_GlyphNode *anode ); + FT_EXPORT_DEF( FT_Error ) FTC_GlyphSet_Lookup_Node( + FTC_GlyphSet gset, + FT_UInt glyph_index, + FTC_GlyphNode* anode ); #ifdef __cplusplus @@ -214,4 +204,5 @@ #endif /* FTCGLYPH_H */ + /* END */ diff --git a/include/freetype/cache/ftcimage.h b/include/freetype/cache/ftcimage.h index f49333997..24febe754 100644 --- a/include/freetype/cache/ftcimage.h +++ b/include/freetype/cache/ftcimage.h @@ -4,9 +4,6 @@ /* */ /* FreeType Image cache (body). */ /* */ -/* Each image cache really manages FT_Glyph objects :-) */ -/* */ -/* */ /* Copyright 2000 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ @@ -19,6 +16,13 @@ /***************************************************************************/ + /*************************************************************************/ + /* */ + /* Each image cache really manages FT_Glyph objects. */ + /* */ + /*************************************************************************/ + + #ifndef FTCIMAGE_H #define FTCIMAGE_H @@ -44,44 +48,23 @@ #define FTC_IMAGE_FORMAT( x ) ( (x) & 7 ) - /*************************************************************************/ - /* */ - /* */ - /* FTC_Image_Type */ - /* */ - /* */ - /* An enumeration used to list the types of glyph images found in a */ - /* glyph image cache. */ - /* */ - /* */ - /* ftc_image_mono :: Monochrome bitmap glyphs. */ - /* */ - /* ftc_image_grays :: Anti-aliased bitmap glyphs. */ - /* */ - /* ftc_image_outline :: Scaled (and hinted) outline glyphs. */ - /* */ - /* ftc_master_outline :: Unscaled original outline glyphs. */ - /* */ - /* */ - /* Other types may be defined in the future. */ - /* */ - typedef enum FTC_Image_Type_ - { - ftc_image_format_bitmap = 0, - ftc_image_format_outline = 1, - ftc_image_flag_monochrome = 16, - ftc_image_flag_unhinted = 32, - ftc_image_flag_autohinted = 64, - ftc_image_flag_unscaled = 128, - ftc_image_flag_no_sbits = 256, +#define ftc_image_format_bitmap 0 +#define ftc_image_format_outline 1 - ftc_image_mono = ftc_image_format_bitmap | - ftc_image_flag_monochrome, /* monochrome bitmap */ - ftc_image_grays = ftc_image_format_bitmap, /* anti-aliased bitmap */ - ftc_image_outline = ftc_image_format_outline /* scaled outline */ +#define ftc_image_flag_monochrome 16 +#define ftc_image_flag_unhinted 32 +#define ftc_image_flag_autohinted 64 +#define ftc_image_flag_unscaled 128 +#define ftc_image_flag_no_sbits 256 - } FTC_Image_Type; + /* monochrome bitmap */ +#define ftc_image_mono ftc_image_format_bitmap | \ + ftc_image_flag_monochrome + /* anti-aliased bitmap */ +#define ftc_image_grays ftc_image_format_bitmap + /* scaled outline */ +#define ftc_image_outline ftc_image_format_outline /*************************************************************************/ @@ -128,10 +111,10 @@ /* Creates a new glyph image cache. */ /* */ /* */ - /* manager :: The parent manager for the image cache. */ + /* manager :: The parent manager for the image cache. */ /* */ /* */ - /* acache :: A handle to the new glyph image cache object. */ + /* acache :: A handle to the new glyph image cache object. */ /* */ /* */ /* FreeType error code. 0 means success. */ @@ -160,10 +143,10 @@ /* failure. */ /* */ /* */ - /* error code, 0 means success */ + /* FreeType error code. 0 means success. */ /* */ /* */ - /* the returned glyph is owned and manager by the glyph image cache. */ + /* The returned glyph is owned and managed by the glyph image cache. */ /* Never try to transform or discard it manually! You can however */ /* create a copy with FT_Glyph_Copy() and modify the new one. */ /* */ @@ -171,12 +154,10 @@ /* taken by the glyphs it holds, the returned glyph might disappear */ /* on a later invocation of this function! It's a cache after all... */ /* */ - FT_EXPORT_DEF( FT_Error ) - FTC_Image_Cache_Lookup( FTC_Image_Cache cache, - FTC_Image_Desc* desc, - FT_UInt gindex, - FT_Glyph* aglyph ); - + FT_EXPORT_DEF( FT_Error ) FTC_Image_Cache_Lookup( FTC_Image_Cache cache, + FTC_Image_Desc* desc, + FT_UInt gindex, + FT_Glyph* aglyph ); #ifdef __cplusplus diff --git a/include/freetype/ftcache.h b/include/freetype/ftcache.h index 565598b47..538740997 100644 --- a/include/freetype/ftcache.h +++ b/include/freetype/ftcache.h @@ -91,9 +91,9 @@ /* FreeType error code. 0 means success. */ /* */ /* */ - /* the face requester should not perform funny things on the returned */ + /* The face requester should not perform funny things on the returned */ /* face object, like creating a new FT_Size for it, or setting a */ - /* transform through FT_Set_Transform !! */ + /* transformation through FT_Set_Transform()! */ /* */ typedef FT_Error (*FTC_Face_Requester)( FTC_FaceID face_id, FT_Library library, diff --git a/src/cache/ftcimage.h b/src/cache/ftcimage.h deleted file mode 100644 index f49333997..000000000 --- a/src/cache/ftcimage.h +++ /dev/null @@ -1,190 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftcimage.c */ -/* */ -/* FreeType Image cache (body). */ -/* */ -/* Each image cache really manages FT_Glyph objects :-) */ -/* */ -/* */ -/* Copyright 2000 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTCIMAGE_H -#define FTCIMAGE_H - - -#include -#include - -#ifdef __cplusplus - extern "C" { -#endif - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** IMAGE CACHE OBJECT *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - -#define FTC_IMAGE_FORMAT( x ) ( (x) & 7 ) - - /*************************************************************************/ - /* */ - /* */ - /* FTC_Image_Type */ - /* */ - /* */ - /* An enumeration used to list the types of glyph images found in a */ - /* glyph image cache. */ - /* */ - /* */ - /* ftc_image_mono :: Monochrome bitmap glyphs. */ - /* */ - /* ftc_image_grays :: Anti-aliased bitmap glyphs. */ - /* */ - /* ftc_image_outline :: Scaled (and hinted) outline glyphs. */ - /* */ - /* ftc_master_outline :: Unscaled original outline glyphs. */ - /* */ - /* */ - /* Other types may be defined in the future. */ - /* */ - typedef enum FTC_Image_Type_ - { - ftc_image_format_bitmap = 0, - ftc_image_format_outline = 1, - - ftc_image_flag_monochrome = 16, - ftc_image_flag_unhinted = 32, - ftc_image_flag_autohinted = 64, - ftc_image_flag_unscaled = 128, - ftc_image_flag_no_sbits = 256, - - ftc_image_mono = ftc_image_format_bitmap | - ftc_image_flag_monochrome, /* monochrome bitmap */ - ftc_image_grays = ftc_image_format_bitmap, /* anti-aliased bitmap */ - ftc_image_outline = ftc_image_format_outline /* scaled outline */ - - } FTC_Image_Type; - - - /*************************************************************************/ - /* */ - /* */ - /* FTC_Image_Desc */ - /* */ - /* */ - /* A simple structure used to describe a given glyph image category. */ - /* */ - /* */ - /* size :: An FTC_SizeRec used to describe the glyph's face & */ - /* size. */ - /* */ - /* image_type :: The glyph image's type. */ - /* */ - typedef struct FTC_Image_Desc_ - { - FTC_FontRec font; - FT_UInt image_type; - - } FTC_Image_Desc; - - - /*************************************************************************/ - /* */ - /* */ - /* FTC_Image_Cache */ - /* */ - /* */ - /* A handle to an glyph image cache object. They are designed to */ - /* hold many distinct glyph images, while not exceeding a certain */ - /* memory threshold. */ - /* */ - typedef struct FTC_Image_CacheRec_* FTC_Image_Cache; - - - /*************************************************************************/ - /* */ - /* */ - /* FTC_Image_Cache_New */ - /* */ - /* */ - /* Creates a new glyph image cache. */ - /* */ - /* */ - /* manager :: The parent manager for the image cache. */ - /* */ - /* */ - /* acache :: A handle to the new glyph image cache object. */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - FT_EXPORT_DEF( FT_Error ) FTC_Image_Cache_New( FTC_Manager manager, - FTC_Image_Cache* acache ); - - - /*************************************************************************/ - /* */ - /* */ - /* FTC_Image_Cache_Lookup */ - /* */ - /* */ - /* Retrieves a given glyph image from a glyph image cache. */ - /* */ - /* */ - /* cache :: A handle to the source glyph image cache. */ - /* */ - /* desc :: A pointer to a glyph image descriptor. */ - /* */ - /* gindex :: The glyph index to retrieve. */ - /* */ - /* */ - /* aglyph :: The corresponding FT_Glyph object. 0 in case of */ - /* failure. */ - /* */ - /* */ - /* error code, 0 means success */ - /* */ - /* */ - /* the returned glyph is owned and manager by the glyph image cache. */ - /* Never try to transform or discard it manually! You can however */ - /* create a copy with FT_Glyph_Copy() and modify the new one. */ - /* */ - /* Because the glyph image cache limits the total amount of memory */ - /* taken by the glyphs it holds, the returned glyph might disappear */ - /* on a later invocation of this function! It's a cache after all... */ - /* */ - FT_EXPORT_DEF( FT_Error ) - FTC_Image_Cache_Lookup( FTC_Image_Cache cache, - FTC_Image_Desc* desc, - FT_UInt gindex, - FT_Glyph* aglyph ); - - - -#ifdef __cplusplus - } -#endif - - -#endif /* FTCIMAGE_H */ - - -/* END */ diff --git a/src/cache/rules.mk b/src/cache/rules.mk index 000dc95e8..086b0995d 100644 --- a/src/cache/rules.mk +++ b/src/cache/rules.mk @@ -40,7 +40,7 @@ Cache_DRV_SRC := $(CACHE_DIR_)ftlru.c \ Cache_DRV_H := $(CACHE_H_DIR_)ftlru.h \ $(CACHE_H_DIR_)ftcmanag.h \ $(CACHE_H_DIR_)ftcglyph.h \ - $(CACHE_DIR_)ftcimage.h + $(CACHE_H_DIR_)ftcimage.h # Cache driver object(s)