diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2010-03-25 20:49:56 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2010-03-25 20:49:56 +0000 |
commit | 22e5864923dac374d2128b5dc1ae31eb0d8df9b6 (patch) | |
tree | 4e2eae6237fc3be46bac3429b86e096b5651a2a2 /lib/freetype/src/cache | |
parent | 083c41a7a7c1c830598758a619a355c4e8f7f654 (diff) |
Update to freetpe 2.3.12. Tested against ports by naddy@.
Diffstat (limited to 'lib/freetype/src/cache')
-rw-r--r-- | lib/freetype/src/cache/ftcbasic.c | 187 | ||||
-rw-r--r-- | lib/freetype/src/cache/ftccache.c | 33 | ||||
-rw-r--r-- | lib/freetype/src/cache/ftccache.h | 14 | ||||
-rw-r--r-- | lib/freetype/src/cache/ftccback.h | 4 | ||||
-rw-r--r-- | lib/freetype/src/cache/ftccmap.c | 34 | ||||
-rw-r--r-- | lib/freetype/src/cache/ftcglyph.c | 8 | ||||
-rw-r--r-- | lib/freetype/src/cache/ftcglyph.h | 18 | ||||
-rw-r--r-- | lib/freetype/src/cache/ftcimage.c | 6 | ||||
-rw-r--r-- | lib/freetype/src/cache/ftcmanag.c | 56 | ||||
-rw-r--r-- | lib/freetype/src/cache/ftcmru.c | 8 | ||||
-rw-r--r-- | lib/freetype/src/cache/ftcmru.h | 7 | ||||
-rw-r--r-- | lib/freetype/src/cache/ftcsbits.c | 17 |
12 files changed, 286 insertions, 106 deletions
diff --git a/lib/freetype/src/cache/ftcbasic.c b/lib/freetype/src/cache/ftcbasic.c index e9e8135ae..ebc8871cc 100644 --- a/lib/freetype/src/cache/ftcbasic.c +++ b/lib/freetype/src/cache/ftcbasic.c @@ -4,7 +4,7 @@ /* */ /* The FreeType basic cache interface (body). */ /* */ -/* Copyright 2003, 2004, 2005, 2006 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,70 @@ if ( anode ) { - *anode = FTC_NODE( node ); - FTC_NODE( node )->ref_count++; + *anode = node; + node->ref_count++; + } + } + + Exit: + return error; + } + + + /* documentation is in ftcache.h */ + + FT_EXPORT_DEF( FT_Error ) + FTC_ImageCache_LookupScaler( FTC_ImageCache cache, + FTC_Scaler scaler, + FT_ULong load_flags, + FT_UInt gindex, + FT_Glyph *aglyph, + FTC_Node *anode ) + { + FTC_BasicQueryRec query; + FTC_Node node = 0; /* make compiler happy */ + FT_Error error; + FT_UInt32 hash; + + + /* some argument checks are delayed to FTC_Cache_Lookup */ + if ( !aglyph || !scaler ) + { + error = FTC_Err_Invalid_Argument; + goto Exit; + } + + *aglyph = NULL; + 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 = (FT_UInt)load_flags; + + hash = FTC_BASIC_ATTR_HASH( &query.attrs ) + gindex; + + FTC_GCACHE_LOOKUP_CMP( cache, + ftc_basic_family_compare, + FTC_GNode_Compare, + hash, gindex, + &query, + node, + error ); + if ( !error ) + { + *aglyph = FTC_INODE( node )->glyph; + + if ( anode ) + { + *anode = node; + node->ref_count++; } } @@ -383,6 +463,7 @@ } + #ifdef FT_CONFIG_OPTION_OLD_INTERNALS /* yet another backwards-legacy structure */ @@ -574,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; @@ -587,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; @@ -607,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; @@ -634,17 +721,81 @@ 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 = node; + node->ref_count++; + } + + Exit: + return error; + } + + + /* documentation is in ftcache.h */ + + FT_EXPORT_DEF( FT_Error ) + FTC_SBitCache_LookupScaler( FTC_SBitCache cache, + FTC_Scaler scaler, + FT_ULong load_flags, + FT_UInt gindex, + FTC_SBit *ansbit, + FTC_Node *anode ) + { + FT_Error error; + FTC_BasicQueryRec query; + FTC_Node node = 0; /* make compiler happy */ + FT_UInt32 hash; + + + if ( anode ) + *anode = NULL; + + /* other argument checks delayed to FTC_Cache_Lookup */ + if ( !ansbit || !scaler ) + return FTC_Err_Invalid_Argument; + + *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 = (FT_UInt)load_flags; + + /* beware, the hash must be the same for all glyph ranges! */ + hash = FTC_BASIC_ATTR_HASH( &query.attrs ) + + gindex / FTC_SBIT_ITEMS_PER_NODE; + + FTC_GCACHE_LOOKUP_CMP( cache, + ftc_basic_family_compare, + FTC_SNode_Compare, + hash, gindex, + &query, + node, + error ); + if ( error ) + goto Exit; + + *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/lib/freetype/src/cache/ftccache.c b/lib/freetype/src/cache/ftccache.c index 797d35f6d..463addd99 100644 --- a/lib/freetype/src/cache/ftccache.c +++ b/lib/freetype/src/cache/ftccache.c @@ -4,7 +4,7 @@ /* */ /* The FreeType internal cache interface (body). */ /* */ -/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006 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 @@ -46,7 +49,10 @@ ftc_node_mru_link( FTC_Node node, FTC_Manager manager ) { - FTC_MruNode_Prepend( (FTC_MruNode*)&manager->nodes_list, + void *nl = &manager->nodes_list; + + + FTC_MruNode_Prepend( (FTC_MruNode*)nl, (FTC_MruNode)node ); manager->num_nodes++; } @@ -57,7 +63,10 @@ ftc_node_mru_unlink( FTC_Node node, FTC_Manager manager ) { - FTC_MruNode_Remove( (FTC_MruNode*)&manager->nodes_list, + void *nl = &manager->nodes_list; + + + FTC_MruNode_Remove( (FTC_MruNode*)nl, (FTC_MruNode)node ); manager->num_nodes--; } @@ -87,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? */ @@ -147,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; @@ -210,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; } @@ -267,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 @@ -277,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 @@ -296,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 } @@ -341,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/lib/freetype/src/cache/ftccache.h b/lib/freetype/src/cache/ftccache.h index 6c9b9b9e8..2082bc4f4 100644 --- a/lib/freetype/src/cache/ftccache.h +++ b/lib/freetype/src/cache/ftccache.h @@ -4,7 +4,7 @@ /* */ /* FreeType internal cache interface (specification). */ /* */ -/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006 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; \ @@ -233,10 +233,11 @@ FT_BEGIN_HEADER \ { \ FTC_Manager _manager = _cache->manager; \ + void* _nl = &_manager->nodes_list; \ \ \ if ( _node != _manager->nodes_list ) \ - FTC_MruNode_Up( (FTC_MruNode*)&_manager->nodes_list, \ + FTC_MruNode_Up( (FTC_MruNode*)_nl, \ (FTC_MruNode)_node ); \ } \ goto _Ok; \ @@ -245,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/lib/freetype/src/cache/ftccback.h b/lib/freetype/src/cache/ftccback.h index 86e72a751..4d0818db2 100644 --- a/lib/freetype/src/cache/ftccback.h +++ b/lib/freetype/src/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/lib/freetype/src/cache/ftccmap.c b/lib/freetype/src/cache/ftccmap.c index 4c6a7fd96..a802b0557 100644 --- a/lib/freetype/src/cache/ftccmap.c +++ b/lib/freetype/src/cache/ftccmap.c @@ -4,7 +4,7 @@ /* */ /* FreeType CharMap cache (body) */ /* */ -/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 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,7 +283,7 @@ { 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; @@ -304,7 +303,7 @@ if ( !cache ) { - FT_ERROR(( "FTC_CMapCache_Lookup: bad arguments, returning 0!\n" )); + FT_TRACE0(( "FTC_CMapCache_Lookup: bad arguments, returning 0\n" )); return 0; } @@ -374,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; @@ -393,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; @@ -414,7 +418,9 @@ 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/lib/freetype/src/cache/ftcglyph.c b/lib/freetype/src/cache/ftcglyph.c index 5c03abe05..a9ab0c319 100644 --- a/lib/freetype/src/cache/ftcglyph.c +++ b/lib/freetype/src/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" @@ -73,8 +71,8 @@ FT_UNUSED( cache ); - return FT_BOOL( gnode->family == gquery->family && - gnode->gindex == gquery->gindex ); + return FT_BOOL( gnode->family == gquery->family && + gnode->gindex == gquery->gindex ); } diff --git a/lib/freetype/src/cache/ftcglyph.h b/lib/freetype/src/cache/ftcglyph.h index 1a5d12deb..c18f9c3af 100644 --- a/lib/freetype/src/cache/ftcglyph.h +++ b/lib/freetype/src/cache/ftcglyph.h @@ -4,7 +4,7 @@ /* */ /* FreeType abstract glyph cache (specification). */ /* */ -/* Copyright 2000-2001, 2003, 2004, 2006 by */ +/* Copyright 2000-2001, 2003, 2004, 2006, 2007 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -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; \ @@ -300,11 +302,13 @@ FT_BEGIN_HEADER #else /* !FTC_INLINE */ -#define FTC_GCACHE_LOOKUP_CMP( cache, famcmp, nodecmp, hash, \ - gindex, query, node, error ) \ - FT_BEGIN_STMNT \ - error = FTC_GCache_Lookup( FTC_GCACHE( cache ), hash, gindex, \ - FTC_GQUERY( query ), (FTC_Node*)&(node) ); \ +#define FTC_GCACHE_LOOKUP_CMP( cache, famcmp, nodecmp, hash, \ + gindex, query, node, error ) \ + FT_BEGIN_STMNT \ + \ + error = FTC_GCache_Lookup( FTC_GCACHE( cache ), hash, gindex, \ + FTC_GQUERY( query ), node ); \ + \ FT_END_STMNT #endif /* !FTC_INLINE */ diff --git a/lib/freetype/src/cache/ftcimage.c b/lib/freetype/src/cache/ftcimage.c index 15d4e80c8..417daf2aa 100644 --- a/lib/freetype/src/cache/ftcimage.c +++ b/lib/freetype/src/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/lib/freetype/src/cache/ftcmanag.c b/lib/freetype/src/cache/ftcmanag.c index 4d44094ce..f2a298e7d 100644 --- a/lib/freetype/src/cache/ftcmanag.c +++ b/lib/freetype/src/cache/ftcmanag.c @@ -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,8 +182,8 @@ FTC_Scaler scaler, FT_Size *asize ) { - FT_Error error; - FTC_SizeNode node; + FT_Error error; + FTC_MruNode mrunode; if ( 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,8 +309,8 @@ FTC_FaceID face_id, FT_Face *aface ) { - FT_Error error; - FTC_FaceNode node; + FT_Error error; + FTC_MruNode mrunode; if ( 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; } @@ -661,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/lib/freetype/src/cache/ftcmru.c b/lib/freetype/src/cache/ftcmru.c index 3a6c625af..9944b5898 100644 --- a/lib/freetype/src/cache/ftcmru.c +++ b/lib/freetype/src/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/lib/freetype/src/cache/ftcmru.h b/lib/freetype/src/cache/ftcmru.h index c8f0c6ef6..5739439f4 100644 --- a/lib/freetype/src/cache/ftcmru.h +++ b/lib/freetype/src/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/lib/freetype/src/cache/ftcsbits.c b/lib/freetype/src/cache/ftcsbits.c index 72f139d56..60d46aa7a 100644 --- a/lib/freetype/src/cache/ftcsbits.c +++ b/lib/freetype/src/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 ); |