diff options
Diffstat (limited to 'src/freetype2/cache')
-rw-r--r-- | src/freetype2/cache/ftcbasic.c | 94 | ||||
-rw-r--r-- | src/freetype2/cache/ftccache.c | 23 | ||||
-rw-r--r-- | src/freetype2/cache/ftccache.h | 11 | ||||
-rw-r--r-- | src/freetype2/cache/ftccback.h | 4 | ||||
-rw-r--r-- | src/freetype2/cache/ftccmap.c | 52 | ||||
-rw-r--r-- | src/freetype2/cache/ftcglyph.c | 4 | ||||
-rw-r--r-- | src/freetype2/cache/ftcglyph.h | 9 | ||||
-rw-r--r-- | src/freetype2/cache/ftcimage.c | 6 | ||||
-rw-r--r-- | src/freetype2/cache/ftcmanag.c | 65 | ||||
-rw-r--r-- | src/freetype2/cache/ftcmru.c | 8 | ||||
-rw-r--r-- | src/freetype2/cache/ftcmru.h | 7 | ||||
-rw-r--r-- | src/freetype2/cache/ftcsbits.c | 17 |
12 files changed, 186 insertions, 114 deletions
diff --git a/src/freetype2/cache/ftcbasic.c b/src/freetype2/cache/ftcbasic.c index a568b97..ebc8871 100644 --- a/src/freetype2/cache/ftcbasic.c +++ b/src/freetype2/cache/ftcbasic.c @@ -4,7 +4,7 @@ /* */ /* The FreeType basic cache interface (body). */ /* */ -/* Copyright 2003, 2004, 2005, 2006, 2007 by */ +/* Copyright 2003, 2004, 2005, 2006, 2007, 2009 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -17,15 +17,17 @@ #include <ft2build.h> +#include FT_INTERNAL_DEBUG_H #include FT_CACHE_H #include "ftcglyph.h" #include "ftcimage.h" #include "ftcsbits.h" -#include FT_INTERNAL_MEMORY_H #include "ftccback.h" #include "ftcerror.h" +#define FT_COMPONENT trace_cache + #ifdef FT_CONFIG_OPTION_OLD_INTERNALS @@ -140,8 +142,18 @@ error = FTC_Manager_LookupFace( manager, family->attrs.scaler.face_id, &face ); + + if ( error || !face ) + return result; + + if ( (FT_ULong)face->num_glyphs > FT_UINT_MAX || 0 > face->num_glyphs ) + { + FT_TRACE1(( "ftc_basic_family_get_count: too large number of glyphs " )); + FT_TRACE1(( "in this face, truncated\n", face->num_glyphs )); + } + if ( !error ) - result = face->num_glyphs; + result = (FT_UInt)face->num_glyphs; return result; } @@ -304,7 +316,7 @@ FTC_Node *anode ) { FTC_BasicQueryRec query; - FTC_INode node = 0; /* make compiler happy */ + FTC_Node node = 0; /* make compiler happy */ FT_Error error; FT_UInt32 hash; @@ -320,13 +332,13 @@ if ( anode ) *anode = NULL; -#ifdef FT_CONFIG_OPTION_OLD_INTERNALS +#if defined( FT_CONFIG_OPTION_OLD_INTERNALS ) && ( FT_INT_MAX > 0xFFFFU ) /* * This one is a major hack used to detect whether we are passed a * regular FTC_ImageType handle, or a legacy FTC_OldImageDesc one. */ - if ( type->width >= 0x10000 ) + if ( (FT_ULong)type->width >= 0x10000L ) { FTC_OldImageDesc desc = (FTC_OldImageDesc)type; @@ -341,10 +353,16 @@ #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ { + if ( (FT_ULong)(type->flags - FT_INT_MIN) > FT_UINT_MAX ) + { + FT_TRACE1(( "FTC_ImageCache_Lookup: higher bits in load_flags" )); + FT_TRACE1(( "0x%x are dropped\n", (type->flags & ~((FT_ULong)FT_UINT_MAX)) )); + } + query.attrs.scaler.face_id = type->face_id; query.attrs.scaler.width = type->width; query.attrs.scaler.height = type->height; - query.attrs.load_flags = type->flags; + query.attrs.load_flags = (FT_UInt)type->flags; } query.attrs.scaler.pixel = 1; @@ -365,7 +383,7 @@ error = FTC_GCache_Lookup( FTC_GCACHE( cache ), hash, gindex, FTC_GQUERY( &query ), - (FTC_Node*) &node ); + &node ); #endif if ( !error ) { @@ -373,8 +391,8 @@ if ( anode ) { - *anode = FTC_NODE( node ); - FTC_NODE( node )->ref_count++; + *anode = node; + node->ref_count++; } } @@ -394,7 +412,7 @@ FTC_Node *anode ) { FTC_BasicQueryRec query; - FTC_INode node = 0; /* make compiler happy */ + FTC_Node node = 0; /* make compiler happy */ FT_Error error; FT_UInt32 hash; @@ -410,8 +428,15 @@ if ( anode ) *anode = NULL; + /* FT_Load_Glyph(), FT_Load_Char() take FT_UInt flags */ + if ( load_flags > FT_UINT_MAX ) + { + FT_TRACE1(( "FTC_ImageCache_LookupScaler: higher bits in load_flags" )); + FT_TRACE1(( "0x%x are dropped\n", (load_flags & ~((FT_ULong)FT_UINT_MAX)) )); + } + query.attrs.scaler = scaler[0]; - query.attrs.load_flags = load_flags; + query.attrs.load_flags = (FT_UInt)load_flags; hash = FTC_BASIC_ATTR_HASH( &query.attrs ) + gindex; @@ -428,8 +453,8 @@ if ( anode ) { - *anode = FTC_NODE( node ); - FTC_NODE( node )->ref_count++; + *anode = node; + node->ref_count++; } } @@ -630,7 +655,7 @@ { FT_Error error; FTC_BasicQueryRec query; - FTC_SNode node = 0; /* make compiler happy */ + FTC_Node node = 0; /* make compiler happy */ FT_UInt32 hash; @@ -643,12 +668,12 @@ *ansbit = NULL; -#ifdef FT_CONFIG_OPTION_OLD_INTERNALS +#if defined( FT_CONFIG_OPTION_OLD_INTERNALS ) && ( FT_INT_MAX > 0xFFFFU ) /* This one is a major hack used to detect whether we are passed a * regular FTC_ImageType handle, or a legacy FTC_OldImageDesc one. */ - if ( type->width >= 0x10000 ) + if ( (FT_ULong)type->width >= 0x10000L ) { FTC_OldImageDesc desc = (FTC_OldImageDesc)type; @@ -663,10 +688,16 @@ #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ { + if ( (FT_ULong)(type->flags - FT_INT_MIN) > FT_UINT_MAX ) + { + FT_TRACE1(( "FTC_ImageCache_Lookup: higher bits in load_flags" )); + FT_TRACE1(( "0x%x are dropped\n", (type->flags & ~((FT_ULong)FT_UINT_MAX)) )); + } + query.attrs.scaler.face_id = type->face_id; query.attrs.scaler.width = type->width; query.attrs.scaler.height = type->height; - query.attrs.load_flags = type->flags; + query.attrs.load_flags = (FT_UInt)type->flags; } query.attrs.scaler.pixel = 1; @@ -690,17 +721,18 @@ hash, gindex, FTC_GQUERY( &query ), - (FTC_Node*)&node ); + &node ); #endif if ( error ) goto Exit; - *ansbit = node->sbits + ( gindex - FTC_GNODE( node )->gindex ); + *ansbit = FTC_SNODE( node )->sbits + + ( gindex - FTC_GNODE( node )->gindex ); if ( anode ) { - *anode = FTC_NODE( node ); - FTC_NODE( node )->ref_count++; + *anode = node; + node->ref_count++; } Exit: @@ -720,7 +752,7 @@ { FT_Error error; FTC_BasicQueryRec query; - FTC_SNode node = 0; /* make compiler happy */ + FTC_Node node = 0; /* make compiler happy */ FT_UInt32 hash; @@ -733,8 +765,15 @@ *ansbit = NULL; + /* FT_Load_Glyph(), FT_Load_Char() take FT_UInt flags */ + if ( load_flags > FT_UINT_MAX ) + { + FT_TRACE1(( "FTC_ImageCache_LookupScaler: higher bits in load_flags" )); + FT_TRACE1(( "0x%x are dropped\n", (load_flags & ~((FT_ULong)FT_UINT_MAX)) )); + } + query.attrs.scaler = scaler[0]; - query.attrs.load_flags = load_flags; + query.attrs.load_flags = (FT_UInt)load_flags; /* beware, the hash must be the same for all glyph ranges! */ hash = FTC_BASIC_ATTR_HASH( &query.attrs ) + @@ -750,12 +789,13 @@ if ( error ) goto Exit; - *ansbit = node->sbits + ( gindex - FTC_GNODE( node )->gindex ); + *ansbit = FTC_SNODE( node )->sbits + + ( gindex - FTC_GNODE( node )->gindex ); if ( anode ) { - *anode = FTC_NODE( node ); - FTC_NODE( node )->ref_count++; + *anode = node; + node->ref_count++; } Exit: diff --git a/src/freetype2/cache/ftccache.c b/src/freetype2/cache/ftccache.c index f3e699c..463addd 100644 --- a/src/freetype2/cache/ftccache.c +++ b/src/freetype2/cache/ftccache.c @@ -4,7 +4,7 @@ /* */ /* The FreeType internal cache interface (body). */ /* */ -/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */ +/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -24,6 +24,9 @@ #include "ftccback.h" #include "ftcerror.h" +#undef FT_COMPONENT +#define FT_COMPONENT trace_cache + #define FTC_HASH_MAX_LOAD 2 #define FTC_HASH_MIN_LOAD 1 @@ -93,9 +96,9 @@ for (;;) { FTC_Node node, *pnode; - FT_UInt p = cache->p; - FT_UInt mask = cache->mask; - FT_UInt count = mask + p + 1; /* number of buckets */ + FT_UFast p = cache->p; + FT_UFast mask = cache->mask; + FT_UFast count = mask + p + 1; /* number of buckets */ /* do we need to shrink the buckets array? */ @@ -153,7 +156,7 @@ /* do we need to expand the buckets array? */ else if ( cache->slack > (FT_Long)count * FTC_HASH_SUB_LOAD ) { - FT_UInt old_index = p + mask; + FT_UFast old_index = p + mask; FTC_Node* pold; @@ -216,7 +219,7 @@ if ( node == NULL ) { - FT_ERROR(( "ftc_node_hash_unlink: unknown node!\n" )); + FT_TRACE0(( "ftc_node_hash_unlink: unknown node\n" )); return; } @@ -273,7 +276,7 @@ /* find node's cache */ if ( node->cache_index >= manager->num_caches ) { - FT_ERROR(( "ftc_node_destroy: invalid node handle\n" )); + FT_TRACE0(( "ftc_node_destroy: invalid node handle\n" )); return; } #endif @@ -283,7 +286,7 @@ #ifdef FT_DEBUG_ERROR if ( cache == NULL ) { - FT_ERROR(( "ftc_node_destroy: invalid node handle\n" )); + FT_TRACE0(( "ftc_node_destroy: invalid node handle\n" )); return; } #endif @@ -302,7 +305,7 @@ #if 0 /* check, just in case of general corruption :-) */ if ( manager->num_nodes == 0 ) - FT_ERROR(( "ftc_node_destroy: invalid cache node count! = %d\n", + FT_TRACE0(( "ftc_node_destroy: invalid cache node count (%d)\n", manager->num_nodes )); #endif } @@ -347,7 +350,7 @@ { FTC_Manager manager = cache->manager; FT_UFast i; - FT_UInt count; + FT_UFast count; count = cache->p + cache->mask + 1; diff --git a/src/freetype2/cache/ftccache.h b/src/freetype2/cache/ftccache.h index 8c0a7c9..2082bc4 100644 --- a/src/freetype2/cache/ftccache.h +++ b/src/freetype2/cache/ftccache.h @@ -4,7 +4,7 @@ /* */ /* FreeType internal cache interface (specification). */ /* */ -/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */ +/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -91,7 +91,7 @@ FT_BEGIN_HEADER FT_Pointer query, FTC_Cache cache ); - typedef FT_ULong + typedef FT_Offset (*FTC_Node_WeightFunc)( FTC_Node node, FTC_Cache cache ); @@ -121,7 +121,7 @@ FT_BEGIN_HEADER FTC_Node_CompareFunc node_remove_faceid; FTC_Node_FreeFunc node_free; - FT_UInt cache_size; + FT_Offset cache_size; FTC_Cache_InitFunc cache_init; FTC_Cache_DoneFunc cache_done; @@ -202,7 +202,7 @@ FT_BEGIN_HEADER FTC_Cache _cache = FTC_CACHE(cache); \ FT_UInt32 _hash = (FT_UInt32)(hash); \ FTC_Node_CompareFunc _nodcomp = (FTC_Node_CompareFunc)(nodecmp); \ - FT_UInt _idx; \ + FT_UFast _idx; \ \ \ error = 0; \ @@ -246,8 +246,7 @@ FT_BEGIN_HEADER error = FTC_Cache_NewNode( _cache, _hash, query, &_node ); \ \ _Ok: \ - _pnode = (FTC_Node*)(void*)&(node); \ - *_pnode = _node; \ + node = _node; \ FT_END_STMNT #else /* !FTC_INLINE */ diff --git a/src/freetype2/cache/ftccback.h b/src/freetype2/cache/ftccback.h index 86e72a7..4d0818d 100644 --- a/src/freetype2/cache/ftccback.h +++ b/src/freetype2/cache/ftccback.h @@ -36,7 +36,7 @@ FT_Pointer gquery, FTC_Cache cache ); - FT_LOCAL( FT_ULong ) + FT_LOCAL( FT_Offset ) ftc_inode_weight( FTC_Node inode, FTC_Cache cache ); @@ -50,7 +50,7 @@ FT_Pointer gquery, FTC_Cache cache ); - FT_LOCAL( FT_ULong ) + FT_LOCAL( FT_Offset ) ftc_snode_weight( FTC_Node snode, FTC_Cache cache ); diff --git a/src/freetype2/cache/ftccmap.c b/src/freetype2/cache/ftccmap.c index aa59307..a802b05 100644 --- a/src/freetype2/cache/ftccmap.c +++ b/src/freetype2/cache/ftccmap.c @@ -4,7 +4,7 @@ /* */ /* FreeType CharMap cache (body) */ /* */ -/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */ +/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -22,7 +22,6 @@ #include "ftcmanag.h" #include FT_INTERNAL_MEMORY_H #include FT_INTERNAL_DEBUG_H -#include FT_TRUETYPE_IDS_H #include "ftccback.h" #include "ftcerror.h" @@ -86,9 +85,9 @@ #define FTC_CMAP_INDICES_MAX 128 /* compute a query/node hash */ -#define FTC_CMAP_HASH( faceid, index, charcode ) \ - ( FTC_FACE_ID_HASH( faceid ) + 211 * ( index ) + \ - ( (char_code) / FTC_CMAP_INDICES_MAX ) ) +#define FTC_CMAP_HASH( faceid, index, charcode ) \ + ( FTC_FACE_ID_HASH( faceid ) + 211 * (index) + \ + ( (charcode) / FTC_CMAP_INDICES_MAX ) ) /* the charmap query */ typedef struct FTC_CMapQueryRec_ @@ -175,7 +174,7 @@ /* compute the weight of a given cmap node */ - FT_CALLBACK_DEF( FT_ULong ) + FT_CALLBACK_DEF( FT_Offset ) ftc_cmap_node_weight( FTC_Node cnode, FTC_Cache cache ) { @@ -284,15 +283,27 @@ { FTC_Cache cache = FTC_CACHE( cmap_cache ); FTC_CMapQueryRec query; - FTC_CMapNode node; + FTC_Node node; FT_Error error; FT_UInt gindex = 0; FT_UInt32 hash; + FT_Int no_cmap_change = 0; + if ( cmap_index < 0 ) + { + /* Treat a negative cmap index as a special value, meaning that you */ + /* don't want to change the FT_Face's character map through this */ + /* call. This can be useful if the face requester callback already */ + /* sets the face's charmap to the appropriate value. */ + + no_cmap_change = 1; + cmap_index = 0; + } + if ( !cache ) { - FT_ERROR(( "FTC_CMapCache_Lookup: bad arguments, returning 0!\n" )); + FT_TRACE0(( "FTC_CMapCache_Lookup: bad arguments, returning 0\n" )); return 0; } @@ -311,7 +322,7 @@ * Adobe Acrobat Reader Pack, named `KozMinProVI-Regular.otf', * which contains more than 5 charmaps. */ - if ( cmap_index >= 16 ) + if ( cmap_index >= 16 && !no_cmap_change ) { FTC_OldCMapDesc desc = (FTC_OldCMapDesc) face_id; @@ -362,18 +373,21 @@ FTC_CACHE_LOOKUP_CMP( cache, ftc_cmap_node_compare, hash, &query, node, error ); #else - error = FTC_Cache_Lookup( cache, hash, &query, (FTC_Node*) &node ); + error = FTC_Cache_Lookup( cache, hash, &query, &node ); #endif if ( error ) goto Exit; - FT_ASSERT( (FT_UInt)( char_code - node->first ) < FTC_CMAP_INDICES_MAX ); + FT_ASSERT( (FT_UInt)( char_code - FTC_CMAP_NODE( node )->first ) < + FTC_CMAP_INDICES_MAX ); /* something rotten can happen with rogue clients */ - if ( (FT_UInt)( char_code - node->first >= FTC_CMAP_INDICES_MAX ) ) + if ( (FT_UInt)( char_code - FTC_CMAP_NODE( node )->first >= + FTC_CMAP_INDICES_MAX ) ) return 0; - gindex = node->indices[char_code - node->first]; + gindex = FTC_CMAP_NODE( node )->indices[char_code - + FTC_CMAP_NODE( node )->first]; if ( gindex == FTC_CMAP_UNKNOWN ) { FT_Face face; @@ -381,7 +395,9 @@ gindex = 0; - error = FTC_Manager_LookupFace( cache->manager, node->face_id, &face ); + error = FTC_Manager_LookupFace( cache->manager, + FTC_CMAP_NODE( node )->face_id, + &face ); if ( error ) goto Exit; @@ -393,16 +409,18 @@ old = face->charmap; cmap = face->charmaps[cmap_index]; - if ( old != cmap ) + if ( old != cmap && !no_cmap_change ) FT_Set_Charmap( face, cmap ); gindex = FT_Get_Char_Index( face, char_code ); - if ( old != cmap ) + if ( old != cmap && !no_cmap_change ) FT_Set_Charmap( face, old ); } - node->indices[char_code - node->first] = (FT_UShort)gindex; + FTC_CMAP_NODE( node )->indices[char_code - + FTC_CMAP_NODE( node )->first] + = (FT_UShort)gindex; } Exit: diff --git a/src/freetype2/cache/ftcglyph.c b/src/freetype2/cache/ftcglyph.c index 5c03abe..2f462a2 100644 --- a/src/freetype2/cache/ftcglyph.c +++ b/src/freetype2/cache/ftcglyph.c @@ -4,7 +4,7 @@ /* */ /* FreeType Glyph Image (FT_Glyph) cache (body). */ /* */ -/* Copyright 2000-2001, 2003, 2004, 2006 by */ +/* Copyright 2000-2001, 2003, 2004, 2006, 2009 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -20,8 +20,6 @@ #include FT_CACHE_H #include "ftcglyph.h" #include FT_ERRORS_H -#include FT_INTERNAL_OBJECTS_H -#include FT_INTERNAL_DEBUG_H #include "ftccback.h" #include "ftcerror.h" diff --git a/src/freetype2/cache/ftcglyph.h b/src/freetype2/cache/ftcglyph.h index 87a4199..c18f9c3 100644 --- a/src/freetype2/cache/ftcglyph.h +++ b/src/freetype2/cache/ftcglyph.h @@ -277,12 +277,14 @@ FT_BEGIN_HEADER FTC_GCache _gcache = FTC_GCACHE( cache ); \ FTC_GQuery _gquery = (FTC_GQuery)( query ); \ FTC_MruNode_CompareFunc _fcompare = (FTC_MruNode_CompareFunc)(famcmp); \ + FTC_MruNode _mrunode; \ \ \ _gquery->gindex = (gindex); \ \ FTC_MRULIST_LOOKUP_CMP( &_gcache->families, _gquery, _fcompare, \ - _gquery->family, error ); \ + _mrunode, error ); \ + _gquery->family = FTC_FAMILY( _mrunode ); \ if ( !error ) \ { \ FTC_Family _gqfamily = _gquery->family; \ @@ -303,11 +305,10 @@ FT_BEGIN_HEADER #define FTC_GCACHE_LOOKUP_CMP( cache, famcmp, nodecmp, hash, \ gindex, query, node, error ) \ FT_BEGIN_STMNT \ - void* _n = &(node); \ - \ \ error = FTC_GCache_Lookup( FTC_GCACHE( cache ), hash, gindex, \ - FTC_GQUERY( query ), (FTC_Node*)_n ); \ + FTC_GQUERY( query ), node ); \ + \ FT_END_STMNT #endif /* !FTC_INLINE */ diff --git a/src/freetype2/cache/ftcimage.c b/src/freetype2/cache/ftcimage.c index 15d4e80..417daf2 100644 --- a/src/freetype2/cache/ftcimage.c +++ b/src/freetype2/cache/ftcimage.c @@ -103,12 +103,12 @@ } - FT_LOCAL_DEF( FT_ULong ) + FT_LOCAL_DEF( FT_Offset ) ftc_inode_weight( FTC_Node ftcinode, FTC_Cache ftccache ) { FTC_INode inode = (FTC_INode)ftcinode; - FT_ULong size = 0; + FT_Offset size = 0; FT_Glyph glyph = inode->glyph; FT_UNUSED( ftccache ); @@ -151,7 +151,7 @@ #if 0 - FT_LOCAL_DEF( FT_ULong ) + FT_LOCAL_DEF( FT_Offset ) FTC_INode_Weight( FTC_INode inode ) { return ftc_inode_weight( FTC_NODE( inode ), NULL ); diff --git a/src/freetype2/cache/ftcmanag.c b/src/freetype2/cache/ftcmanag.c index 9d7347c..f2a298e 100644 --- a/src/freetype2/cache/ftcmanag.c +++ b/src/freetype2/cache/ftcmanag.c @@ -4,7 +4,7 @@ /* */ /* FreeType Cache Manager (body). */ /* */ -/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006 by */ +/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -26,6 +26,10 @@ #include "ftccback.h" #include "ftcerror.h" +#ifdef FT_CONFIG_OPTION_PIC +#error "cache system does not support PIC yet" +#endif + #undef FT_COMPONENT #define FT_COMPONENT trace_cache @@ -78,6 +82,8 @@ } FTC_SizeNodeRec, *FTC_SizeNode; +#define FTC_SIZE_NODE( x ) ( (FTC_SizeNode)( x ) ) + FT_CALLBACK_DEF( void ) ftc_size_node_done( FTC_MruNode ftcnode, @@ -176,12 +182,12 @@ FTC_Scaler scaler, FT_Size *asize ) { - FT_Error error; - FTC_SizeNode node; + FT_Error error; + FTC_MruNode mrunode; if ( asize == NULL ) - return FTC_Err_Bad_Argument; + return FTC_Err_Invalid_Argument; *asize = NULL; @@ -191,14 +197,14 @@ #ifdef FTC_INLINE FTC_MRULIST_LOOKUP_CMP( &manager->sizes, scaler, ftc_size_node_compare, - node, error ); + mrunode, error ); #else - error = FTC_MruList_Lookup( &manager->sizes, scaler, (FTC_MruNode*)&node ); + error = FTC_MruList_Lookup( &manager->sizes, scaler, &mrunode ); #endif if ( !error ) - *asize = node->size; + *asize = FTC_SIZE_NODE( mrunode )->size; return error; } @@ -220,6 +226,8 @@ } FTC_FaceNodeRec, *FTC_FaceNode; +#define FTC_FACE_NODE( x ) ( ( FTC_FaceNode )( x ) ) + FT_CALLBACK_DEF( FT_Error ) ftc_face_node_init( FTC_MruNode ftcnode, @@ -301,12 +309,12 @@ FTC_FaceID face_id, FT_Face *aface ) { - FT_Error error; - FTC_FaceNode node; + FT_Error error; + FTC_MruNode mrunode; if ( aface == NULL ) - return FTC_Err_Bad_Argument; + return FTC_Err_Invalid_Argument; *aface = NULL; @@ -317,14 +325,14 @@ #ifdef FTC_INLINE FTC_MRULIST_LOOKUP_CMP( &manager->faces, face_id, ftc_face_node_compare, - node, error ); + mrunode, error ); #else - error = FTC_MruList_Lookup( &manager->faces, face_id, (FTC_MruNode*)&node ); + error = FTC_MruList_Lookup( &manager->faces, face_id, &mrunode ); #endif if ( !error ) - *aface = node->face; + *aface = FTC_FACE_NODE( mrunode )->face; return error; } @@ -476,8 +484,8 @@ if ( (FT_UInt)node->cache_index >= manager->num_caches ) - FT_ERROR(( "FTC_Manager_Check: invalid node (cache index = %ld\n", - node->cache_index )); + FT_TRACE0(( "FTC_Manager_Check: invalid node (cache index = %ld\n", + node->cache_index )); else weight += cache->clazz.node_weight( node, cache ); @@ -486,8 +494,8 @@ } while ( node != first ); if ( weight != manager->cur_weight ) - FT_ERROR(( "FTC_Manager_Check: invalid weight %ld instead of %ld\n", - manager->cur_weight, weight )); + FT_TRACE0(( "FTC_Manager_Check: invalid weight %ld instead of %ld\n", + manager->cur_weight, weight )); } /* check circular list */ @@ -505,9 +513,9 @@ } while ( node != first ); if ( count != manager->num_nodes ) - FT_ERROR(( - "FTC_Manager_Check: invalid cache node count %d instead of %d\n", - manager->num_nodes, count )); + FT_TRACE0(( "FTC_Manager_Check:" + " invalid cache node count %d instead of %d\n", + manager->num_nodes, count )); } } @@ -534,9 +542,9 @@ #ifdef FT_DEBUG_ERROR FTC_Manager_Check( manager ); - FT_ERROR(( "compressing, weight = %ld, max = %ld, nodes = %d\n", - manager->cur_weight, manager->max_weight, - manager->num_nodes )); + FT_TRACE0(( "compressing, weight = %ld, max = %ld, nodes = %d\n", + manager->cur_weight, manager->max_weight, + manager->num_nodes )); #endif if ( manager->cur_weight < manager->max_weight || first == NULL ) @@ -579,8 +587,8 @@ if ( manager->num_caches >= FTC_MAX_CACHES ) { error = FTC_Err_Too_Many_Caches; - FT_ERROR(( "%s: too many registered caches\n", - "FTC_Manager_Register_Cache" )); + FT_ERROR(( "FTC_Manager_RegisterCache:" + " too many registered caches\n" )); goto Exit; } @@ -608,7 +616,8 @@ } Exit: - *acache = cache; + if ( acache ) + *acache = cache; return error; } @@ -660,7 +669,9 @@ /* this will remove all FTC_SizeNode that correspond to * the face_id as well */ - FTC_MruList_RemoveSelection( &manager->faces, NULL, face_id ); + FTC_MruList_RemoveSelection( &manager->faces, + (FTC_MruNode_CompareFunc)NULL, + face_id ); for ( nn = 0; nn < manager->num_caches; nn++ ) FTC_Cache_RemoveFaceID( manager->caches[nn], face_id ); diff --git a/src/freetype2/cache/ftcmru.c b/src/freetype2/cache/ftcmru.c index 3a6c625..9944b58 100644 --- a/src/freetype2/cache/ftcmru.c +++ b/src/freetype2/cache/ftcmru.c @@ -4,7 +4,7 @@ /* */ /* FreeType MRU support (body). */ /* */ -/* Copyright 2003, 2004, 2006 by */ +/* Copyright 2003, 2004, 2006, 2009 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -46,7 +46,7 @@ { if ( cnode == node ) { - fprintf( stderr, "FTC_MruNode_Prepend: invalid action!\n" ); + fprintf( stderr, "FTC_MruNode_Prepend: invalid action\n" ); exit( 2 ); } cnode = cnode->next; @@ -94,7 +94,7 @@ } while ( cnode != first ); - fprintf( stderr, "FTC_MruNode_Up: invalid action!\n" ); + fprintf( stderr, "FTC_MruNode_Up: invalid action\n" ); exit( 2 ); Ok: } @@ -141,7 +141,7 @@ } while ( cnode != first ); - fprintf( stderr, "FTC_MruNode_Remove: invalid action!\n" ); + fprintf( stderr, "FTC_MruNode_Remove: invalid action\n" ); exit( 2 ); Ok: } diff --git a/src/freetype2/cache/ftcmru.h b/src/freetype2/cache/ftcmru.h index c8f0c6e..5739439 100644 --- a/src/freetype2/cache/ftcmru.h +++ b/src/freetype2/cache/ftcmru.h @@ -107,7 +107,7 @@ FT_BEGIN_HEADER typedef struct FTC_MruListClassRec_ { - FT_UInt node_size; + FT_Offset node_size; FTC_MruNode_CompareFunc node_compare; FTC_MruNode_InitFunc node_init; FTC_MruNode_ResetFunc node_reset; @@ -163,7 +163,7 @@ FT_BEGIN_HEADER FT_BEGIN_STMNT \ FTC_MruNode* _pfirst = &(list)->nodes; \ FTC_MruNode_CompareFunc _compare = (FTC_MruNode_CompareFunc)(compare); \ - FTC_MruNode _first, _node, *_pnode; \ + FTC_MruNode _first, _node; \ \ \ error = 0; \ @@ -180,8 +180,7 @@ FT_BEGIN_HEADER if ( _node != _first ) \ FTC_MruNode_Up( _pfirst, _node ); \ \ - _pnode = (FTC_MruNode*)(void*)&(node); \ - *_pnode = _node; \ + node = _node; \ goto _MruOk; \ } \ _node = _node->next; \ diff --git a/src/freetype2/cache/ftcsbits.c b/src/freetype2/cache/ftcsbits.c index 72f139d..60d46aa 100644 --- a/src/freetype2/cache/ftcsbits.c +++ b/src/freetype2/cache/ftcsbits.c @@ -4,7 +4,7 @@ /* */ /* FreeType sbits manager (body). */ /* */ -/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006 by */ +/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2009 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -26,6 +26,9 @@ #include "ftccback.h" #include "ftcerror.h" +#undef FT_COMPONENT +#define FT_COMPONENT trace_cache + /*************************************************************************/ /*************************************************************************/ @@ -129,13 +132,13 @@ FT_Int temp; FT_GlyphSlot slot = face->glyph; FT_Bitmap* bitmap = &slot->bitmap; - FT_Int xadvance, yadvance; + FT_Pos xadvance, yadvance; /* FT_GlyphSlot->advance.{x|y} */ if ( slot->format != FT_GLYPH_FORMAT_BITMAP ) { - FT_ERROR(( "%s: glyph loaded didn't return a bitmap!\n", - "ftc_snode_load" )); + FT_TRACE0(( "ftc_snode_load:" + " glyph loaded didn't return a bitmap\n" )); goto BadGlyph; } @@ -263,7 +266,7 @@ } - FT_LOCAL_DEF( FT_ULong ) + FT_LOCAL_DEF( FT_Offset ) ftc_snode_weight( FTC_Node ftcsnode, FTC_Cache cache ) { @@ -271,7 +274,7 @@ FT_UInt count = snode->count; FTC_SBit sbit = snode->sbits; FT_Int pitch; - FT_ULong size; + FT_Offset size; FT_UNUSED( cache ); @@ -300,7 +303,7 @@ #if 0 - FT_LOCAL_DEF( FT_ULong ) + FT_LOCAL_DEF( FT_Offset ) FTC_SNode_Weight( FTC_SNode snode ) { return ftc_snode_weight( FTC_NODE( snode ), NULL ); |