summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/freetype/src/cache
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2015-03-19 17:34:42 +0400
committerKonstantin Ritt <ritt.ks@gmail.com>2015-03-20 13:42:29 +0000
commit2eaf0cf8fd6e7c290497fedb08134a89e7b49b1d (patch)
tree0a4f7bf528e87d0b0a71ce7fccf702b87f4cdec1 /src/3rdparty/freetype/src/cache
parent77c518a50334d4dcf2476a4f39edc1e3990c7f0b (diff)
Update bundled FreeType to 2.5.5
Removed everything, imported with help of import_from_tarball.sh script, and then added a pre-generated builds/unix/ftconfig.h Task-number: QTBUG-44648 Change-Id: Iea948e41f7761f1580382b3763d04c7a61383382 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/3rdparty/freetype/src/cache')
-rw-r--r--src/3rdparty/freetype/src/cache/Jamfile4
-rw-r--r--src/3rdparty/freetype/src/cache/ftcbasic.c370
-rw-r--r--src/3rdparty/freetype/src/cache/ftccache.c116
-rw-r--r--src/3rdparty/freetype/src/cache/ftccache.h82
-rw-r--r--src/3rdparty/freetype/src/cache/ftccback.h11
-rw-r--r--src/3rdparty/freetype/src/cache/ftccmap.c141
-rw-r--r--src/3rdparty/freetype/src/cache/ftcerror.h3
-rw-r--r--src/3rdparty/freetype/src/cache/ftcglyph.c20
-rw-r--r--src/3rdparty/freetype/src/cache/ftcglyph.h14
-rw-r--r--src/3rdparty/freetype/src/cache/ftcimage.c4
-rw-r--r--src/3rdparty/freetype/src/cache/ftcmanag.c105
-rw-r--r--src/3rdparty/freetype/src/cache/ftcmanag.h8
-rw-r--r--src/3rdparty/freetype/src/cache/ftcmru.c12
-rw-r--r--src/3rdparty/freetype/src/cache/ftcmru.h4
-rw-r--r--src/3rdparty/freetype/src/cache/ftcsbits.c43
-rw-r--r--src/3rdparty/freetype/src/cache/ftcsbits.h9
16 files changed, 326 insertions, 620 deletions
diff --git a/src/3rdparty/freetype/src/cache/Jamfile b/src/3rdparty/freetype/src/cache/Jamfile
index 340cff7742..6563991375 100644
--- a/src/3rdparty/freetype/src/cache/Jamfile
+++ b/src/3rdparty/freetype/src/cache/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src/cache Jamfile
#
-# Copyright 2001, 2003, 2004 by
+# Copyright 2001, 2003, 2004, 2013 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -11,7 +11,7 @@
SubDir FT2_TOP $(FT2_SRC_DIR) cache ;
-# The file <freetype/ftcache.h> contains some macro definitions that are
+# The file <ftcache.h> contains some macro definitions that are
# later used in #include statements related to the cache sub-system. It
# needs to be parsed through a HDRMACRO rule for macro definitions.
#
diff --git a/src/3rdparty/freetype/src/cache/ftcbasic.c b/src/3rdparty/freetype/src/cache/ftcbasic.c
index ebc8871ccc..6bad39d912 100644
--- a/src/3rdparty/freetype/src/cache/ftcbasic.c
+++ b/src/3rdparty/freetype/src/cache/ftcbasic.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType basic cache interface (body). */
/* */
-/* Copyright 2003, 2004, 2005, 2006, 2007, 2009 by */
+/* Copyright 2003-2007, 2009-2011, 2013, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,6 +17,7 @@
#include <ft2build.h>
+#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_DEBUG_H
#include FT_CACHE_H
#include "ftcglyph.h"
@@ -29,44 +30,6 @@
#define FT_COMPONENT trace_cache
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
-
- /*
- * These structures correspond to the FTC_Font and FTC_ImageDesc types
- * that were defined in version 2.1.7.
- */
- typedef struct FTC_OldFontRec_
- {
- FTC_FaceID face_id;
- FT_UShort pix_width;
- FT_UShort pix_height;
-
- } FTC_OldFontRec, *FTC_OldFont;
-
-
- typedef struct FTC_OldImageDescRec_
- {
- FTC_OldFontRec font;
- FT_UInt32 flags;
-
- } FTC_OldImageDescRec, *FTC_OldImageDesc;
-
-
- /*
- * Notice that FTC_OldImageDescRec and FTC_ImageTypeRec are nearly
- * identical, bit-wise. The only difference is that the `width' and
- * `height' fields are expressed as 16-bit integers in the old structure,
- * and as normal `int' in the new one.
- *
- * We are going to perform a weird hack to detect which structure is
- * being passed to the image and sbit caches. If the new structure's
- * `width' is larger than 0x10000, we assume that we are really receiving
- * an FTC_OldImageDesc.
- */
-
-#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
-
-
/*
* Basic Families
*
@@ -147,10 +110,9 @@
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 ));
- }
+ FT_TRACE1(( "ftc_basic_family_get_count:"
+ " too large number of glyphs in this face, truncated\n",
+ face->num_glyphs ));
if ( !error )
result = (FT_UInt)face->num_glyphs;
@@ -225,7 +187,7 @@
}
}
else
- error = FTC_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
}
}
@@ -237,7 +199,8 @@
FT_CALLBACK_DEF( FT_Bool )
ftc_basic_gnode_compare_faceid( FTC_Node ftcgnode,
FT_Pointer ftcface_id,
- FTC_Cache cache )
+ FTC_Cache cache,
+ FT_Bool* list_changed )
{
FTC_GNode gnode = (FTC_GNode)ftcgnode;
FTC_FaceID face_id = (FTC_FaceID)ftcface_id;
@@ -245,6 +208,8 @@
FT_Bool result;
+ if ( list_changed )
+ *list_changed = FALSE;
result = FT_BOOL( family->attrs.scaler.face_id == face_id );
if ( result )
{
@@ -263,7 +228,7 @@
*
*/
- FT_CALLBACK_TABLE_DEF
+ static
const FTC_IFamilyClassRec ftc_basic_image_family_class =
{
{
@@ -277,7 +242,7 @@
};
- FT_CALLBACK_TABLE_DEF
+ static
const FTC_GCacheClassRec ftc_basic_image_cache_class =
{
{
@@ -318,13 +283,13 @@
FTC_BasicQueryRec query;
FTC_Node node = 0; /* make compiler happy */
FT_Error error;
- FT_UInt32 hash;
+ FT_PtrDist hash;
- /* some argument checks are delayed to FTC_Cache_Lookup */
+ /* some argument checks are delayed to `FTC_Cache_Lookup' */
if ( !aglyph )
{
- error = FTC_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -332,38 +297,15 @@
if ( anode )
*anode = NULL;
-#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 ( (FT_ULong)type->width >= 0x10000L )
- {
- FTC_OldImageDesc desc = (FTC_OldImageDesc)type;
-
-
- query.attrs.scaler.face_id = desc->font.face_id;
- query.attrs.scaler.width = desc->font.pix_width;
- query.attrs.scaler.height = desc->font.pix_height;
- query.attrs.load_flags = desc->flags;
- }
- else
-
-#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)) ));
- }
+ if ( (FT_ULong)( type->flags - FT_INT_MIN ) > FT_UINT_MAX )
+ FT_TRACE1(( "FTC_ImageCache_Lookup:"
+ " higher bits in load_flags 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 = (FT_UInt)type->flags;
- }
+ query.attrs.scaler.face_id = type->face_id;
+ query.attrs.scaler.width = type->width;
+ query.attrs.scaler.height = type->height;
+ query.attrs.load_flags = (FT_UInt)type->flags;
query.attrs.scaler.pixel = 1;
query.attrs.scaler.x_res = 0; /* make compilers happy */
@@ -414,13 +356,13 @@
FTC_BasicQueryRec query;
FTC_Node node = 0; /* make compiler happy */
FT_Error error;
- FT_UInt32 hash;
+ FT_PtrDist hash;
- /* some argument checks are delayed to FTC_Cache_Lookup */
+ /* some argument checks are delayed to `FTC_Cache_Lookup' */
if ( !aglyph || !scaler )
{
- error = FTC_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -428,12 +370,11 @@
if ( anode )
*anode = NULL;
- /* FT_Load_Glyph(), FT_Load_Char() take FT_UInt flags */
+ /* `FT_Load_Glyph' and `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)) ));
- }
+ FT_TRACE1(( "FTC_ImageCache_LookupScaler:"
+ " higher bits in load_flags 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;
@@ -463,148 +404,17 @@
}
-
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
-
- /* yet another backwards-legacy structure */
- typedef struct FTC_OldImage_Desc_
- {
- FTC_FontRec font;
- FT_UInt image_type;
-
- } FTC_OldImage_Desc;
-
-
-#define FTC_OLD_IMAGE_FORMAT( x ) ( (x) & 7 )
-
-
-#define ftc_old_image_format_bitmap 0x0000
-#define ftc_old_image_format_outline 0x0001
-
-#define ftc_old_image_format_mask 0x000F
-
-#define ftc_old_image_flag_monochrome 0x0010
-#define ftc_old_image_flag_unhinted 0x0020
-#define ftc_old_image_flag_autohinted 0x0040
-#define ftc_old_image_flag_unscaled 0x0080
-#define ftc_old_image_flag_no_sbits 0x0100
-
- /* monochrome bitmap */
-#define ftc_old_image_mono ftc_old_image_format_bitmap | \
- ftc_old_image_flag_monochrome
-
- /* anti-aliased bitmap */
-#define ftc_old_image_grays ftc_old_image_format_bitmap
-
- /* scaled outline */
-#define ftc_old_image_outline ftc_old_image_format_outline
-
-
- static void
- ftc_image_type_from_old_desc( FTC_ImageType typ,
- FTC_OldImage_Desc* desc )
- {
- typ->face_id = desc->font.face_id;
- typ->width = desc->font.pix_width;
- typ->height = desc->font.pix_height;
-
- /* convert image type flags to load flags */
- {
- FT_UInt load_flags = FT_LOAD_DEFAULT;
- FT_UInt type = desc->image_type;
-
-
- /* determine load flags, depending on the font description's */
- /* image type */
-
- if ( FTC_OLD_IMAGE_FORMAT( type ) == ftc_old_image_format_bitmap )
- {
- if ( type & ftc_old_image_flag_monochrome )
- load_flags |= FT_LOAD_MONOCHROME;
-
- /* disable embedded bitmaps loading if necessary */
- if ( type & ftc_old_image_flag_no_sbits )
- load_flags |= FT_LOAD_NO_BITMAP;
- }
- else
- {
- /* we want an outline, don't load embedded bitmaps */
- load_flags |= FT_LOAD_NO_BITMAP;
-
- if ( type & ftc_old_image_flag_unscaled )
- load_flags |= FT_LOAD_NO_SCALE;
- }
-
- /* always render glyphs to bitmaps */
- load_flags |= FT_LOAD_RENDER;
-
- if ( type & ftc_old_image_flag_unhinted )
- load_flags |= FT_LOAD_NO_HINTING;
-
- if ( type & ftc_old_image_flag_autohinted )
- load_flags |= FT_LOAD_FORCE_AUTOHINT;
-
- typ->flags = load_flags;
- }
- }
-
-
- FT_EXPORT( FT_Error )
- FTC_Image_Cache_New( FTC_Manager manager,
- FTC_ImageCache *acache );
-
- FT_EXPORT( FT_Error )
- FTC_Image_Cache_Lookup( FTC_ImageCache icache,
- FTC_OldImage_Desc* desc,
- FT_UInt gindex,
- FT_Glyph *aglyph );
-
-
- FT_EXPORT_DEF( FT_Error )
- FTC_Image_Cache_New( FTC_Manager manager,
- FTC_ImageCache *acache )
- {
- return FTC_ImageCache_New( manager, (FTC_ImageCache*)acache );
- }
-
-
-
- FT_EXPORT_DEF( FT_Error )
- FTC_Image_Cache_Lookup( FTC_ImageCache icache,
- FTC_OldImage_Desc* desc,
- FT_UInt gindex,
- FT_Glyph *aglyph )
- {
- FTC_ImageTypeRec type0;
-
-
- if ( !desc )
- return FTC_Err_Invalid_Argument;
-
- ftc_image_type_from_old_desc( &type0, desc );
-
- return FTC_ImageCache_Lookup( (FTC_ImageCache)icache,
- &type0,
- gindex,
- aglyph,
- NULL );
- }
-
-#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
-
-
- /*
- *
- * basic small bitmap cache
- *
- */
-
+ /*
+ *
+ * basic small bitmap cache
+ *
+ */
- FT_CALLBACK_TABLE_DEF
+ static
const FTC_SFamilyClassRec ftc_basic_sbit_family_class =
{
{
- sizeof( FTC_BasicFamilyRec ),
+ sizeof ( FTC_BasicFamilyRec ),
ftc_basic_family_compare,
ftc_basic_family_init,
0, /* FTC_MruNode_ResetFunc */
@@ -615,7 +425,7 @@
};
- FT_CALLBACK_TABLE_DEF
+ static
const FTC_GCacheClassRec ftc_basic_sbit_cache_class =
{
{
@@ -656,49 +466,27 @@
FT_Error error;
FTC_BasicQueryRec query;
FTC_Node node = 0; /* make compiler happy */
- FT_UInt32 hash;
+ FT_PtrDist hash;
if ( anode )
*anode = NULL;
- /* other argument checks delayed to FTC_Cache_Lookup */
+ /* other argument checks delayed to `FTC_Cache_Lookup' */
if ( !ansbit )
- return FTC_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
*ansbit = NULL;
-#if defined( FT_CONFIG_OPTION_OLD_INTERNALS ) && ( FT_INT_MAX > 0xFFFFU )
+ if ( (FT_ULong)( type->flags - FT_INT_MIN ) > FT_UINT_MAX )
+ FT_TRACE1(( "FTC_ImageCache_Lookup:"
+ " higher bits in load_flags 0x%x are dropped\n",
+ type->flags & ~((FT_ULong)FT_UINT_MAX) ));
- /* 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 ( (FT_ULong)type->width >= 0x10000L )
- {
- FTC_OldImageDesc desc = (FTC_OldImageDesc)type;
-
-
- query.attrs.scaler.face_id = desc->font.face_id;
- query.attrs.scaler.width = desc->font.pix_width;
- query.attrs.scaler.height = desc->font.pix_height;
- query.attrs.load_flags = desc->flags;
- }
- else
-
-#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 = (FT_UInt)type->flags;
- }
+ query.attrs.scaler.face_id = type->face_id;
+ query.attrs.scaler.width = type->width;
+ query.attrs.scaler.height = type->height;
+ query.attrs.load_flags = (FT_UInt)type->flags;
query.attrs.scaler.pixel = 1;
query.attrs.scaler.x_res = 0; /* make compilers happy */
@@ -753,24 +541,23 @@
FT_Error error;
FTC_BasicQueryRec query;
FTC_Node node = 0; /* make compiler happy */
- FT_UInt32 hash;
+ FT_PtrDist hash;
if ( anode )
*anode = NULL;
- /* other argument checks delayed to FTC_Cache_Lookup */
+ /* other argument checks delayed to `FTC_Cache_Lookup' */
if ( !ansbit || !scaler )
- return FTC_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
*ansbit = NULL;
- /* FT_Load_Glyph(), FT_Load_Char() take FT_UInt flags */
+ /* `FT_Load_Glyph' and `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)) ));
- }
+ FT_TRACE1(( "FTC_ImageCache_LookupScaler:"
+ " higher bits in load_flags 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;
@@ -803,49 +590,4 @@
}
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
-
- FT_EXPORT( FT_Error )
- FTC_SBit_Cache_New( FTC_Manager manager,
- FTC_SBitCache *acache );
-
- FT_EXPORT( FT_Error )
- FTC_SBit_Cache_Lookup( FTC_SBitCache cache,
- FTC_OldImage_Desc* desc,
- FT_UInt gindex,
- FTC_SBit *ansbit );
-
-
- FT_EXPORT_DEF( FT_Error )
- FTC_SBit_Cache_New( FTC_Manager manager,
- FTC_SBitCache *acache )
- {
- return FTC_SBitCache_New( manager, (FTC_SBitCache*)acache );
- }
-
-
- FT_EXPORT_DEF( FT_Error )
- FTC_SBit_Cache_Lookup( FTC_SBitCache cache,
- FTC_OldImage_Desc* desc,
- FT_UInt gindex,
- FTC_SBit *ansbit )
- {
- FTC_ImageTypeRec type0;
-
-
- if ( !desc )
- return FT_Err_Invalid_Argument;
-
- ftc_image_type_from_old_desc( &type0, desc );
-
- return FTC_SBitCache_Lookup( (FTC_SBitCache)cache,
- &type0,
- gindex,
- ansbit,
- NULL );
- }
-
-#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
-
-
/* END */
diff --git a/src/3rdparty/freetype/src/cache/ftccache.c b/src/3rdparty/freetype/src/cache/ftccache.c
index 463addd99b..f20dd4502c 100644
--- a/src/3rdparty/freetype/src/cache/ftccache.c
+++ b/src/3rdparty/freetype/src/cache/ftccache.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType internal cache interface (body). */
/* */
-/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 by */
+/* Copyright 2000-2007, 2009-2011, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -32,7 +32,7 @@
#define FTC_HASH_MIN_LOAD 1
#define FTC_HASH_SUB_LOAD ( FTC_HASH_MAX_LOAD - FTC_HASH_MIN_LOAD )
-/* this one _must_ be a power of 2! */
+ /* this one _must_ be a power of 2! */
#define FTC_HASH_INITIAL_SIZE 8
@@ -83,6 +83,25 @@
(FTC_MruNode)node );
}
+
+ /* get a top bucket for specified hash from cache,
+ * body for FTC_NODE__TOP_FOR_HASH( cache, hash )
+ */
+ FT_LOCAL_DEF( FTC_Node* )
+ ftc_get_top_node_for_hash( FTC_Cache cache,
+ FT_PtrDist hash )
+ {
+ FTC_Node* pnode;
+ FT_UInt idx;
+
+
+ idx = (FT_UInt)( hash & cache->mask );
+ if ( idx < cache->p )
+ idx = (FT_UInt)( hash & ( 2 * cache->mask + 1 ) );
+ pnode = cache->buckets + idx;
+ return pnode;
+ }
+
#endif /* !FTC_INLINE */
@@ -96,9 +115,9 @@
for (;;)
{
FTC_Node node, *pnode;
- FT_UFast p = cache->p;
- FT_UFast mask = cache->mask;
- FT_UFast 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? */
@@ -117,7 +136,8 @@
/* if we can't expand the array, leave immediately */
- if ( FT_RENEW_ARRAY( cache->buckets, (mask+1)*2, (mask+1)*4 ) )
+ if ( FT_RENEW_ARRAY( cache->buckets,
+ ( mask + 1 ) * 2, ( mask + 1 ) * 4 ) )
break;
}
@@ -191,7 +211,9 @@
cache->slack -= FTC_HASH_MAX_LOAD;
cache->p = p;
}
- else /* the hash table is balanced */
+
+ /* otherwise, the hash table is balanced */
+ else
break;
}
}
@@ -202,16 +224,9 @@
ftc_node_hash_unlink( FTC_Node node0,
FTC_Cache cache )
{
- FTC_Node *pnode;
- FT_UInt idx;
+ FTC_Node *pnode = FTC_NODE__TOP_FOR_HASH( cache, node0->hash );
- idx = (FT_UInt)( node0->hash & cache->mask );
- if ( idx < cache->p )
- idx = (FT_UInt)( node0->hash & ( 2 * cache->mask + 1 ) );
-
- pnode = cache->buckets + idx;
-
for (;;)
{
FTC_Node node = *pnode;
@@ -242,15 +257,8 @@
ftc_node_hash_link( FTC_Node node,
FTC_Cache cache )
{
- FTC_Node *pnode;
- FT_UInt idx;
-
+ FTC_Node *pnode = FTC_NODE__TOP_FOR_HASH( cache, node->hash );
- idx = (FT_UInt)( node->hash & cache->mask );
- if ( idx < cache->p )
- idx = (FT_UInt)( node->hash & (2 * cache->mask + 1 ) );
-
- pnode = cache->buckets + idx;
node->link = *pnode;
*pnode = node;
@@ -261,11 +269,7 @@
/* remove a node from the cache manager */
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
- FT_BASE_DEF( void )
-#else
FT_LOCAL_DEF( void )
-#endif
ftc_node_destroy( FTC_Node node,
FTC_Manager manager )
{
@@ -346,7 +350,7 @@
static void
FTC_Cache_Clear( FTC_Cache cache )
{
- if ( cache )
+ if ( cache && cache->buckets )
{
FTC_Manager manager = cache->manager;
FT_UFast i;
@@ -410,11 +414,11 @@
static void
ftc_cache_add( FTC_Cache cache,
- FT_UInt32 hash,
+ FT_PtrDist hash,
FTC_Node node )
{
- node->hash = hash;
- node->cache_index = (FT_UInt16) cache->index;
+ node->hash = hash;
+ node->cache_index = (FT_UInt16)cache->index;
node->ref_count = 0;
ftc_node_hash_link( node, cache );
@@ -438,7 +442,7 @@
FT_LOCAL_DEF( FT_Error )
FTC_Cache_NewNode( FTC_Cache cache,
- FT_UInt32 hash,
+ FT_PtrDist hash,
FT_Pointer query,
FTC_Node *anode )
{
@@ -456,7 +460,7 @@
{
error = cache->clazz.node_new( &node, query, cache );
}
- FTC_CACHE_TRYLOOP_END();
+ FTC_CACHE_TRYLOOP_END( NULL );
if ( error )
node = NULL;
@@ -477,40 +481,59 @@
FT_LOCAL_DEF( FT_Error )
FTC_Cache_Lookup( FTC_Cache cache,
- FT_UInt32 hash,
+ FT_PtrDist hash,
FT_Pointer query,
FTC_Node *anode )
{
- FT_UFast idx;
FTC_Node* bucket;
FTC_Node* pnode;
FTC_Node node;
- FT_Error error = 0;
+ FT_Error error = FT_Err_Ok;
+ FT_Bool list_changed = FALSE;
FTC_Node_CompareFunc compare = cache->clazz.node_compare;
if ( cache == NULL || anode == NULL )
- return FT_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
- idx = hash & cache->mask;
- if ( idx < cache->p )
- idx = hash & ( cache->mask * 2 + 1 );
+ /* Go to the `top' node of the list sharing same masked hash */
+ bucket = pnode = FTC_NODE__TOP_FOR_HASH( cache, hash );
- bucket = cache->buckets + idx;
- pnode = bucket;
+ /* Lookup a node with exactly same hash and queried properties. */
+ /* NOTE: _nodcomp() may change the linked list to reduce memory. */
for (;;)
{
node = *pnode;
if ( node == NULL )
goto NewNode;
- if ( node->hash == hash && compare( node, query, cache ) )
+ if ( node->hash == hash &&
+ compare( node, query, cache, &list_changed ) )
break;
pnode = &node->link;
}
+ if ( list_changed )
+ {
+ /* Update bucket by modified linked list */
+ bucket = pnode = FTC_NODE__TOP_FOR_HASH( cache, hash );
+
+ /* Update pnode by modified linked list */
+ while ( *pnode != node )
+ {
+ if ( *pnode == NULL )
+ {
+ FT_ERROR(( "FTC_Cache_Lookup: oops!!! node missing\n" ));
+ goto NewNode;
+ }
+ else
+ pnode = &((*pnode)->link);
+ }
+ }
+
+ /* Reorder the list to move the found node to the `top' */
if ( node != *bucket )
{
*pnode = node->link;
@@ -527,6 +550,7 @@
ftc_node_mru_up( node, manager );
}
*anode = node;
+
return error;
NewNode:
@@ -545,7 +569,7 @@
FTC_Node frees = NULL;
- count = cache->p + cache->mask;
+ count = cache->p + cache->mask + 1;
for ( i = 0; i < count; i++ )
{
FTC_Node* bucket = cache->buckets + i;
@@ -555,12 +579,14 @@
for ( ;; )
{
FTC_Node node = *pnode;
+ FT_Bool list_changed = FALSE;
if ( node == NULL )
break;
- if ( cache->clazz.node_remove_faceid( node, face_id, cache ) )
+ if ( cache->clazz.node_remove_faceid( node, face_id,
+ cache, &list_changed ) )
{
*pnode = node->link;
node->link = frees;
diff --git a/src/3rdparty/freetype/src/cache/ftccache.h b/src/3rdparty/freetype/src/cache/ftccache.h
index 2082bc4f4f..4155f320e0 100644
--- a/src/3rdparty/freetype/src/cache/ftccache.h
+++ b/src/3rdparty/freetype/src/cache/ftccache.h
@@ -4,7 +4,7 @@
/* */
/* FreeType internal cache interface (specification). */
/* */
-/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 by */
+/* Copyright 2000-2007, 2009-2011, 2013 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 @@
FT_BEGIN_HEADER
+#define _FTC_FACE_ID_HASH( i ) \
+ ((FT_PtrDist)(( (FT_PtrDist)(i) >> 3 ) ^ ( (FT_PtrDist)(i) << 7 )))
+
/* handle to cache object */
typedef struct FTC_CacheRec_* FTC_Cache;
@@ -56,7 +59,7 @@ FT_BEGIN_HEADER
{
FTC_MruNodeRec mru; /* circular mru list pointer */
FTC_Node link; /* used for hashing */
- FT_UInt32 hash; /* used for hashing too */
+ FT_PtrDist hash; /* used for hashing too */
FT_UShort cache_index; /* index of cache the node belongs to */
FT_Short ref_count; /* reference count for this node */
@@ -69,11 +72,18 @@ FT_BEGIN_HEADER
#define FTC_NODE__NEXT( x ) FTC_NODE( (x)->mru.next )
#define FTC_NODE__PREV( x ) FTC_NODE( (x)->mru.prev )
-
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
- FT_BASE( void )
- ftc_node_destroy( FTC_Node node,
- FTC_Manager manager );
+#ifdef FTC_INLINE
+#define FTC_NODE__TOP_FOR_HASH( cache, hash ) \
+ ( ( cache )->buckets + \
+ ( ( ( ( hash ) & ( cache )->mask ) < ( cache )->p ) \
+ ? ( ( hash ) & ( ( cache )->mask * 2 + 1 ) ) \
+ : ( ( hash ) & ( cache )->mask ) ) )
+#else
+ FT_LOCAL( FTC_Node* )
+ ftc_get_top_node_for_hash( FTC_Cache cache,
+ FT_PtrDist hash );
+#define FTC_NODE__TOP_FOR_HASH( cache, hash ) \
+ ftc_get_top_node_for_hash( ( cache ), ( hash ) )
#endif
@@ -99,7 +109,8 @@ FT_BEGIN_HEADER
typedef FT_Bool
(*FTC_Node_CompareFunc)( FTC_Node node,
FT_Pointer key,
- FTC_Cache cache );
+ FTC_Cache cache,
+ FT_Bool* list_changed );
typedef void
@@ -159,7 +170,7 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
FTC_Cache_Done( FTC_Cache cache );
- /* Call this function to lookup the cache. If no corresponding
+ /* Call this function to look up the cache. If no corresponding
* node is found, a new one is automatically created. This function
* is capable of flushing the cache adequately to make room for the
* new cache object.
@@ -168,20 +179,20 @@ FT_BEGIN_HEADER
#ifndef FTC_INLINE
FT_LOCAL( FT_Error )
FTC_Cache_Lookup( FTC_Cache cache,
- FT_UInt32 hash,
+ FT_PtrDist hash,
FT_Pointer query,
FTC_Node *anode );
#endif
FT_LOCAL( FT_Error )
FTC_Cache_NewNode( FTC_Cache cache,
- FT_UInt32 hash,
+ FT_PtrDist hash,
FT_Pointer query,
FTC_Node *anode );
/* Remove all nodes that relate to a given face_id. This is useful
* when un-installing fonts. Note that if a cache node relates to
- * the face_id, but is locked (i.e., has `ref_count > 0'), the node
+ * the face_id but is locked (i.e., has `ref_count > 0'), the node
* will _not_ be destroyed, but its internal face_id reference will
* be modified.
*
@@ -200,30 +211,51 @@ FT_BEGIN_HEADER
FT_BEGIN_STMNT \
FTC_Node *_bucket, *_pnode, _node; \
FTC_Cache _cache = FTC_CACHE(cache); \
- FT_UInt32 _hash = (FT_UInt32)(hash); \
+ FT_PtrDist _hash = (FT_PtrDist)(hash); \
FTC_Node_CompareFunc _nodcomp = (FTC_Node_CompareFunc)(nodecmp); \
- FT_UFast _idx; \
+ FT_Bool _list_changed = FALSE; \
\
\
- error = 0; \
+ error = FT_Err_Ok; \
node = NULL; \
- _idx = _hash & _cache->mask; \
- if ( _idx < _cache->p ) \
- _idx = _hash & ( _cache->mask*2 + 1 ); \
\
- _bucket = _pnode = _cache->buckets + _idx; \
+ /* Go to the `top' node of the list sharing same masked hash */ \
+ _bucket = _pnode = FTC_NODE__TOP_FOR_HASH( _cache, _hash ); \
+ \
+ /* Look up a node with identical hash and queried properties. */ \
+ /* NOTE: _nodcomp() may change the linked list to reduce memory. */ \
for (;;) \
{ \
_node = *_pnode; \
if ( _node == NULL ) \
goto _NewNode; \
\
- if ( _node->hash == _hash && _nodcomp( _node, query, _cache ) ) \
+ if ( _node->hash == _hash && \
+ _nodcomp( _node, query, _cache, &_list_changed ) ) \
break; \
\
_pnode = &_node->link; \
} \
\
+ if ( _list_changed ) \
+ { \
+ /* Update _bucket by possibly modified linked list */ \
+ _bucket = _pnode = FTC_NODE__TOP_FOR_HASH( _cache, _hash ); \
+ \
+ /* Update _pnode by possibly modified linked list */ \
+ while ( *_pnode != _node ) \
+ { \
+ if ( *_pnode == NULL ) \
+ { \
+ FT_ERROR(( "FTC_CACHE_LOOKUP_CMP: oops!!! node missing\n" )); \
+ goto _NewNode; \
+ } \
+ else \
+ _pnode = &((*_pnode)->link); \
+ } \
+ } \
+ \
+ /* Reorder the list to move the found node to the `top' */ \
if ( _node != *_bucket ) \
{ \
*_pnode = _node->link; \
@@ -231,6 +263,7 @@ FT_BEGIN_HEADER
*_bucket = _node; \
} \
\
+ /* Update MRU list */ \
{ \
FTC_Manager _manager = _cache->manager; \
void* _nl = &_manager->nodes_list; \
@@ -265,7 +298,7 @@ FT_BEGIN_HEADER
* loop to flush the cache repeatedly in case of memory overflows.
*
* It is used when creating a new cache node, or within a lookup
- * that needs to allocate data (e.g., the sbit cache lookup).
+ * that needs to allocate data (e.g. the sbit cache lookup).
*
* Example:
*
@@ -287,11 +320,14 @@ FT_BEGIN_HEADER
FT_UInt _try_done;
-#define FTC_CACHE_TRYLOOP_END() \
- if ( !error || error != FT_Err_Out_Of_Memory ) \
+#define FTC_CACHE_TRYLOOP_END( list_changed ) \
+ 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 ) ) \
+ *(FT_Bool*)( list_changed ) = TRUE; \
+ \
if ( _try_done == 0 ) \
break; \
\
diff --git a/src/3rdparty/freetype/src/cache/ftccback.h b/src/3rdparty/freetype/src/cache/ftccback.h
index 4d0818db27..9528279273 100644
--- a/src/3rdparty/freetype/src/cache/ftccback.h
+++ b/src/3rdparty/freetype/src/cache/ftccback.h
@@ -4,7 +4,7 @@
/* */
/* Callback functions of the caching sub-system (specification only). */
/* */
-/* Copyright 2004, 2005, 2006 by */
+/* Copyright 2004-2006, 2011, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -57,13 +57,15 @@
FT_LOCAL( FT_Bool )
ftc_snode_compare( FTC_Node snode,
FT_Pointer gquery,
- FTC_Cache cache );
+ FTC_Cache cache,
+ FT_Bool* list_changed );
FT_LOCAL( FT_Bool )
ftc_gnode_compare( FTC_Node gnode,
FT_Pointer gquery,
- FTC_Cache cache );
+ FTC_Cache cache,
+ FT_Bool* list_changed );
FT_LOCAL( FT_Error )
@@ -79,11 +81,10 @@
FT_LOCAL( void )
ftc_cache_done( FTC_Cache cache );
-#ifndef FT_CONFIG_OPTION_OLD_INTERNALS
FT_LOCAL( void )
ftc_node_destroy( FTC_Node node,
FTC_Manager manager );
-#endif
+
#endif /* __FTCCBACK_H__ */
diff --git a/src/3rdparty/freetype/src/cache/ftccmap.c b/src/3rdparty/freetype/src/cache/ftccmap.c
index a802b0557c..ab223663bb 100644
--- a/src/3rdparty/freetype/src/cache/ftccmap.c
+++ b/src/3rdparty/freetype/src/cache/ftccmap.c
@@ -4,7 +4,7 @@
/* */
/* FreeType CharMap cache (body) */
/* */
-/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2000-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -21,6 +21,7 @@
#include FT_CACHE_H
#include "ftcmanag.h"
#include FT_INTERNAL_MEMORY_H
+#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_DEBUG_H
#include "ftccback.h"
@@ -30,43 +31,6 @@
#define FT_COMPONENT trace_cache
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
-
- typedef enum FTC_OldCMapType_
- {
- FTC_OLD_CMAP_BY_INDEX = 0,
- FTC_OLD_CMAP_BY_ENCODING = 1,
- FTC_OLD_CMAP_BY_ID = 2
-
- } FTC_OldCMapType;
-
-
- typedef struct FTC_OldCMapIdRec_
- {
- FT_UInt platform;
- FT_UInt encoding;
-
- } FTC_OldCMapIdRec, *FTC_OldCMapId;
-
-
- typedef struct FTC_OldCMapDescRec_
- {
- FTC_FaceID face_id;
- FTC_OldCMapType type;
-
- union
- {
- FT_UInt index;
- FT_Encoding encoding;
- FTC_OldCMapIdRec id;
-
- } u;
-
- } FTC_OldCMapDescRec, *FTC_OldCMapDesc;
-
-#endif /* FT_CONFIG_OLD_INTERNALS */
-
-
/*************************************************************************/
/* */
/* Each FTC_CMapNode contains a simple array to map a range of character */
@@ -86,7 +50,7 @@
/* compute a query/node hash */
#define FTC_CMAP_HASH( faceid, index, charcode ) \
- ( FTC_FACE_ID_HASH( faceid ) + 211 * (index) + \
+ ( _FTC_FACE_ID_HASH( faceid ) + 211 * (index) + \
( (charcode) / FTC_CMAP_INDICES_MAX ) )
/* the charmap query */
@@ -119,7 +83,7 @@
/* if (indices[n] == FTC_CMAP_UNKNOWN), we assume that the corresponding */
/* glyph indices haven't been queried through FT_Get_Glyph_Index() yet */
-#define FTC_CMAP_UNKNOWN ( (FT_UInt16)-1 )
+#define FTC_CMAP_UNKNOWN (FT_UInt16)~0
/*************************************************************************/
@@ -153,7 +117,7 @@
FTC_CMapQuery query = (FTC_CMapQuery)ftcquery;
FT_Error error;
FT_Memory memory = cache->memory;
- FTC_CMapNode node;
+ FTC_CMapNode node = NULL;
FT_UInt nn;
@@ -189,13 +153,16 @@
FT_CALLBACK_DEF( FT_Bool )
ftc_cmap_node_compare( FTC_Node ftcnode,
FT_Pointer ftcquery,
- FTC_Cache cache )
+ FTC_Cache cache,
+ FT_Bool* list_changed )
{
FTC_CMapNode node = (FTC_CMapNode)ftcnode;
FTC_CMapQuery query = (FTC_CMapQuery)ftcquery;
FT_UNUSED( cache );
+ if ( list_changed )
+ *list_changed = FALSE;
if ( node->face_id == query->face_id &&
node->cmap_index == query->cmap_index )
{
@@ -212,12 +179,16 @@
FT_CALLBACK_DEF( FT_Bool )
ftc_cmap_node_remove_faceid( FTC_Node ftcnode,
FT_Pointer ftcface_id,
- FTC_Cache cache )
+ FTC_Cache cache,
+ FT_Bool* list_changed )
{
FTC_CMapNode node = (FTC_CMapNode)ftcnode;
FTC_FaceID face_id = (FTC_FaceID)ftcface_id;
FT_UNUSED( cache );
+
+ if ( list_changed )
+ *list_changed = FALSE;
return FT_BOOL( node->face_id == face_id );
}
@@ -231,7 +202,7 @@
/*************************************************************************/
- FT_CALLBACK_TABLE_DEF
+ static
const FTC_CacheClassRec ftc_cmap_cache_class =
{
ftc_cmap_node_new,
@@ -258,21 +229,6 @@
}
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
-
- /*
- * Unfortunately, it is not possible to support binary backwards
- * compatibility in the cmap cache. The FTC_CMapCache_Lookup signature
- * changes were too deep, and there is no clever hackish way to detect
- * what kind of structure we are being passed.
- *
- * On the other hand it seems that no production code is using this
- * function on Unix distributions.
- */
-
-#endif
-
-
/* documentation is in ftcache.h */
FT_EXPORT_DEF( FT_UInt )
@@ -286,7 +242,7 @@
FTC_Node node;
FT_Error error;
FT_UInt gindex = 0;
- FT_UInt32 hash;
+ FT_PtrDist hash;
FT_Int no_cmap_change = 0;
@@ -307,65 +263,12 @@
return 0;
}
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
-
- /*
- * Detect a call from a rogue client that thinks it is linking
- * to FreeType 2.1.7. This is possible because the third parameter
- * is then a character code, and we have never seen any font with
- * more than a few charmaps, so if the index is very large...
- *
- * It is also very unlikely that a rogue client is interested
- * in Unicode values 0 to 15.
- *
- * NOTE: The original threshold was 4, but we found a font from the
- * Adobe Acrobat Reader Pack, named `KozMinProVI-Regular.otf',
- * which contains more than 5 charmaps.
- */
- if ( cmap_index >= 16 && !no_cmap_change )
- {
- FTC_OldCMapDesc desc = (FTC_OldCMapDesc) face_id;
-
-
- char_code = (FT_UInt32)cmap_index;
- query.face_id = desc->face_id;
-
-
- switch ( desc->type )
- {
- case FTC_OLD_CMAP_BY_INDEX:
- query.cmap_index = desc->u.index;
- query.char_code = (FT_UInt32)cmap_index;
- break;
-
- case FTC_OLD_CMAP_BY_ENCODING:
- {
- FT_Face face;
-
-
- error = FTC_Manager_LookupFace( cache->manager, desc->face_id,
- &face );
- if ( error )
- return 0;
-
- FT_Select_Charmap( face, desc->u.encoding );
-
- return FT_Get_Char_Index( face, char_code );
- }
-
- default:
- return 0;
- }
- }
- else
+ if ( !face_id )
+ return 0;
-#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
-
- {
- query.face_id = face_id;
- query.cmap_index = (FT_UInt)cmap_index;
- query.char_code = char_code;
- }
+ query.face_id = face_id;
+ query.cmap_index = (FT_UInt)cmap_index;
+ query.char_code = char_code;
hash = FTC_CMAP_HASH( face_id, cmap_index, char_code );
@@ -384,7 +287,7 @@
/* something rotten can happen with rogue clients */
if ( (FT_UInt)( char_code - FTC_CMAP_NODE( node )->first >=
FTC_CMAP_INDICES_MAX ) )
- return 0;
+ return 0; /* XXX: should return appropriate error */
gindex = FTC_CMAP_NODE( node )->indices[char_code -
FTC_CMAP_NODE( node )->first];
diff --git a/src/3rdparty/freetype/src/cache/ftcerror.h b/src/3rdparty/freetype/src/cache/ftcerror.h
index 5998d42daf..0e055709bb 100644
--- a/src/3rdparty/freetype/src/cache/ftcerror.h
+++ b/src/3rdparty/freetype/src/cache/ftcerror.h
@@ -4,7 +4,7 @@
/* */
/* Caching sub-system error codes (specification only). */
/* */
-/* Copyright 2001 by */
+/* Copyright 2001, 2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -30,6 +30,7 @@
#undef __FTERRORS_H__
+#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX FTC_Err_
#define FT_ERR_BASE FT_Mod_Err_Cache
diff --git a/src/3rdparty/freetype/src/cache/ftcglyph.c b/src/3rdparty/freetype/src/cache/ftcglyph.c
index a9ab0c319f..441e177238 100644
--- a/src/3rdparty/freetype/src/cache/ftcglyph.c
+++ b/src/3rdparty/freetype/src/cache/ftcglyph.c
@@ -4,7 +4,7 @@
/* */
/* FreeType Glyph Image (FT_Glyph) cache (body). */
/* */
-/* Copyright 2000-2001, 2003, 2004, 2006, 2009 by */
+/* Copyright 2000-2001, 2003, 2004, 2006, 2009, 2011 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,6 +17,7 @@
#include <ft2build.h>
+#include FT_INTERNAL_OBJECTS_H
#include FT_CACHE_H
#include "ftcglyph.h"
#include FT_ERRORS_H
@@ -64,25 +65,34 @@
FT_LOCAL_DEF( FT_Bool )
ftc_gnode_compare( FTC_Node ftcgnode,
FT_Pointer ftcgquery,
- FTC_Cache cache )
+ FTC_Cache cache,
+ FT_Bool* list_changed )
{
FTC_GNode gnode = (FTC_GNode)ftcgnode;
FTC_GQuery gquery = (FTC_GQuery)ftcgquery;
FT_UNUSED( cache );
+ if ( list_changed )
+ *list_changed = FALSE;
return FT_BOOL( gnode->family == gquery->family &&
gnode->gindex == gquery->gindex );
}
+#ifdef FTC_INLINE
+
FT_LOCAL_DEF( FT_Bool )
FTC_GNode_Compare( FTC_GNode gnode,
- FTC_GQuery gquery )
+ FTC_GQuery gquery,
+ FTC_Cache cache,
+ FT_Bool* list_changed )
{
- return ftc_gnode_compare( FTC_NODE( gnode ), gquery, NULL );
+ return ftc_gnode_compare( FTC_NODE( gnode ), gquery,
+ cache, list_changed );
}
+#endif
/*************************************************************************/
/*************************************************************************/
@@ -175,7 +185,7 @@
FT_LOCAL_DEF( FT_Error )
FTC_GCache_Lookup( FTC_GCache cache,
- FT_UInt32 hash,
+ FT_PtrDist hash,
FT_UInt gindex,
FTC_GQuery query,
FTC_Node *anode )
diff --git a/src/3rdparty/freetype/src/cache/ftcglyph.h b/src/3rdparty/freetype/src/cache/ftcglyph.h
index c18f9c3af3..5fed19cb8f 100644
--- a/src/3rdparty/freetype/src/cache/ftcglyph.h
+++ b/src/3rdparty/freetype/src/cache/ftcglyph.h
@@ -4,7 +4,7 @@
/* */
/* FreeType abstract glyph cache (specification). */
/* */
-/* Copyright 2000-2001, 2003, 2004, 2006, 2007 by */
+/* Copyright 2000-2001, 2003, 2004, 2006, 2007, 2011 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -180,12 +180,18 @@ FT_BEGIN_HEADER
FT_UInt gindex, /* glyph index for node */
FTC_Family family );
+#ifdef FTC_INLINE
+
/* returns TRUE iff the query's glyph index correspond to the node; */
/* this assumes that the `family' and `hash' fields of the query are */
/* already correctly set */
FT_LOCAL( FT_Bool )
FTC_GNode_Compare( FTC_GNode gnode,
- FTC_GQuery gquery );
+ FTC_GQuery gquery,
+ FTC_Cache cache,
+ FT_Bool* list_changed );
+
+#endif
/* call this function to clear a node's family -- this is necessary */
/* to implement the `node_remove_faceid' cache method correctly */
@@ -254,7 +260,7 @@ FT_BEGIN_HEADER
#ifndef FTC_INLINE
FT_LOCAL( FT_Error )
FTC_GCache_Lookup( FTC_GCache cache,
- FT_UInt32 hash,
+ FT_PtrDist hash,
FT_UInt gindex,
FTC_GQuery query,
FTC_Node *anode );
@@ -307,7 +313,7 @@ FT_BEGIN_HEADER
FT_BEGIN_STMNT \
\
error = FTC_GCache_Lookup( FTC_GCACHE( cache ), hash, gindex, \
- FTC_GQUERY( query ), node ); \
+ FTC_GQUERY( query ), &node ); \
\
FT_END_STMNT
diff --git a/src/3rdparty/freetype/src/cache/ftcimage.c b/src/3rdparty/freetype/src/cache/ftcimage.c
index 417daf2aae..c242ece021 100644
--- a/src/3rdparty/freetype/src/cache/ftcimage.c
+++ b/src/3rdparty/freetype/src/cache/ftcimage.c
@@ -4,7 +4,7 @@
/* */
/* FreeType Image cache (body). */
/* */
-/* Copyright 2000-2001, 2003, 2004, 2006 by */
+/* Copyright 2000-2001, 2003, 2004, 2006, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -61,7 +61,7 @@
{
FT_Memory memory = cache->memory;
FT_Error error;
- FTC_INode inode;
+ FTC_INode inode = NULL;
if ( !FT_NEW( inode ) )
diff --git a/src/3rdparty/freetype/src/cache/ftcmanag.c b/src/3rdparty/freetype/src/cache/ftcmanag.c
index f2a298e7d9..fff7a08827 100644
--- a/src/3rdparty/freetype/src/cache/ftcmanag.c
+++ b/src/3rdparty/freetype/src/cache/ftcmanag.c
@@ -4,7 +4,7 @@
/* */
/* FreeType Cache Manager (body). */
/* */
-/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 by */
+/* Copyright 2000-2006, 2008-2010, 2013, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -28,7 +28,7 @@
#ifdef FT_CONFIG_OPTION_PIC
#error "cache system does not support PIC yet"
-#endif
+#endif
#undef FT_COMPONENT
@@ -151,7 +151,7 @@
}
- FT_CALLBACK_TABLE_DEF
+ static
const FTC_MruListClassRec ftc_size_list_class =
{
sizeof ( FTC_SizeNodeRec ),
@@ -186,13 +186,13 @@
FTC_MruNode mrunode;
- if ( asize == NULL )
- return FTC_Err_Invalid_Argument;
+ if ( !asize || !scaler )
+ return FT_THROW( Invalid_Argument );
*asize = NULL;
if ( !manager )
- return FTC_Err_Invalid_Cache_Handle;
+ return FT_THROW( Invalid_Cache_Handle );
#ifdef FTC_INLINE
@@ -290,7 +290,7 @@
}
- FT_CALLBACK_TABLE_DEF
+ static
const FTC_MruListClassRec ftc_face_list_class =
{
sizeof ( FTC_FaceNodeRec),
@@ -313,13 +313,13 @@
FTC_MruNode mrunode;
- if ( aface == NULL )
- return FTC_Err_Invalid_Argument;
+ if ( !aface || !face_id )
+ return FT_THROW( Invalid_Argument );
*aface = NULL;
if ( !manager )
- return FTC_Err_Invalid_Cache_Handle;
+ return FT_THROW( Invalid_Cache_Handle );
/* we break encapsulation for the sake of speed */
#ifdef FTC_INLINE
@@ -364,7 +364,10 @@
if ( !library )
- return FTC_Err_Invalid_Library_Handle;
+ return FT_THROW( Invalid_Library_Handle );
+
+ if ( !amanager || !requester )
+ return FT_THROW( Invalid_Argument );
memory = library->memory;
@@ -451,12 +454,13 @@
FT_EXPORT_DEF( void )
FTC_Manager_Reset( FTC_Manager manager )
{
- if ( manager )
- {
- FTC_MruList_Reset( &manager->sizes );
- FTC_MruList_Reset( &manager->faces );
- }
- /* XXX: FIXME: flush the caches? */
+ if ( !manager )
+ return;
+
+ FTC_MruList_Reset( &manager->sizes );
+ FTC_MruList_Reset( &manager->faces );
+
+ FTC_Manager_FlushN( manager, manager->num_nodes );
}
@@ -473,7 +477,7 @@
/* check node weights */
if ( first )
{
- FT_ULong weight = 0;
+ FT_Offset weight = 0;
node = first;
@@ -575,7 +579,7 @@
FTC_CacheClass clazz,
FTC_Cache *acache )
{
- FT_Error error = FTC_Err_Invalid_Argument;
+ FT_Error error = FT_ERR( Invalid_Argument );
FTC_Cache cache = NULL;
@@ -586,7 +590,7 @@
if ( manager->num_caches >= FTC_MAX_CACHES )
{
- error = FTC_Err_Too_Many_Caches;
+ error = FT_THROW( Too_Many_Caches );
FT_ERROR(( "FTC_Manager_RegisterCache:"
" too many registered caches\n" ));
goto Exit;
@@ -666,11 +670,15 @@
{
FT_UInt nn;
+
+ if ( !manager || !face_id )
+ return;
+
/* this will remove all FTC_SizeNode that correspond to
* the face_id as well
*/
FTC_MruList_RemoveSelection( &manager->faces,
- (FTC_MruNode_CompareFunc)NULL,
+ ftc_face_node_compare,
face_id );
for ( nn = 0; nn < manager->num_caches; nn++ )
@@ -684,60 +692,11 @@
FTC_Node_Unref( FTC_Node node,
FTC_Manager manager )
{
- if ( node && (FT_UInt)node->cache_index < manager->num_caches )
+ if ( node &&
+ manager &&
+ (FT_UInt)node->cache_index < manager->num_caches )
node->ref_count--;
}
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
-
- FT_EXPORT_DEF( FT_Error )
- FTC_Manager_Lookup_Face( FTC_Manager manager,
- FTC_FaceID face_id,
- FT_Face *aface )
- {
- return FTC_Manager_LookupFace( manager, face_id, aface );
- }
-
-
- FT_EXPORT( FT_Error )
- FTC_Manager_Lookup_Size( FTC_Manager manager,
- FTC_Font font,
- FT_Face *aface,
- FT_Size *asize )
- {
- FTC_ScalerRec scaler;
- FT_Error error;
- FT_Size size;
- FT_Face face;
-
-
- scaler.face_id = font->face_id;
- scaler.width = font->pix_width;
- scaler.height = font->pix_height;
- scaler.pixel = TRUE;
- scaler.x_res = 0;
- scaler.y_res = 0;
-
- error = FTC_Manager_LookupSize( manager, &scaler, &size );
- if ( error )
- {
- face = NULL;
- size = NULL;
- }
- else
- face = size->face;
-
- if ( aface )
- *aface = face;
-
- if ( asize )
- *asize = size;
-
- return error;
- }
-
-#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
-
-
/* END */
diff --git a/src/3rdparty/freetype/src/cache/ftcmanag.h b/src/3rdparty/freetype/src/cache/ftcmanag.h
index 3fdc2c773b..0aec33c584 100644
--- a/src/3rdparty/freetype/src/cache/ftcmanag.h
+++ b/src/3rdparty/freetype/src/cache/ftcmanag.h
@@ -4,7 +4,7 @@
/* */
/* FreeType Cache Manager (specification). */
/* */
-/* Copyright 2000-2001, 2003, 2004, 2006 by */
+/* Copyright 2000-2001, 2003, 2004, 2006, 2010, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -94,8 +94,8 @@ FT_BEGIN_HEADER
FT_Memory memory;
FTC_Node nodes_list;
- FT_ULong max_weight;
- FT_ULong cur_weight;
+ FT_Offset max_weight;
+ FT_Offset cur_weight;
FT_UInt num_nodes;
FTC_Cache caches[FTC_MAX_CACHES];
@@ -161,7 +161,7 @@ FT_BEGIN_HEADER
(a)->y_res == (b)->y_res ) ) )
#define FTC_SCALER_HASH( q ) \
- ( FTC_FACE_ID_HASH( (q)->face_id ) + \
+ ( _FTC_FACE_ID_HASH( (q)->face_id ) + \
(q)->width + (q)->height*7 + \
( (q)->pixel ? 0 : ( (q)->x_res*33 ^ (q)->y_res*61 ) ) )
diff --git a/src/3rdparty/freetype/src/cache/ftcmru.c b/src/3rdparty/freetype/src/cache/ftcmru.c
index 9944b58980..dc8b4cc397 100644
--- a/src/3rdparty/freetype/src/cache/ftcmru.c
+++ b/src/3rdparty/freetype/src/cache/ftcmru.c
@@ -161,7 +161,7 @@
*plist = NULL;
}
else if ( node == first )
- *plist = next;
+ *plist = next;
}
@@ -238,7 +238,7 @@
FTC_MruNode *anode )
{
FT_Error error;
- FTC_MruNode node;
+ FTC_MruNode node = NULL;
FT_Memory memory = list->memory;
@@ -264,14 +264,14 @@
list->clazz.node_done( node, list->data );
}
else if ( FT_ALLOC( node, list->clazz.node_size ) )
- goto Exit;
+ goto Exit;
error = list->clazz.node_init( node, key, list->data );
if ( error )
goto Fail;
- FTC_MruNode_Prepend( &list->nodes, node );
- list->num_nodes++;
+ FTC_MruNode_Prepend( &list->nodes, node );
+ list->num_nodes++;
Exit:
*anode = node;
@@ -316,7 +316,7 @@
if ( list->clazz.node_done )
- list->clazz.node_done( node, list->data );
+ list->clazz.node_done( node, list->data );
FT_FREE( node );
}
diff --git a/src/3rdparty/freetype/src/cache/ftcmru.h b/src/3rdparty/freetype/src/cache/ftcmru.h
index 5739439f45..6fccf11781 100644
--- a/src/3rdparty/freetype/src/cache/ftcmru.h
+++ b/src/3rdparty/freetype/src/cache/ftcmru.h
@@ -4,7 +4,7 @@
/* */
/* Simple MRU list-cache (specification). */
/* */
-/* Copyright 2000-2001, 2003, 2004, 2005, 2006 by */
+/* Copyright 2000-2001, 2003-2006, 2010, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -166,7 +166,7 @@ FT_BEGIN_HEADER
FTC_MruNode _first, _node; \
\
\
- error = 0; \
+ error = FT_Err_Ok; \
_first = *(_pfirst); \
_node = NULL; \
\
diff --git a/src/3rdparty/freetype/src/cache/ftcsbits.c b/src/3rdparty/freetype/src/cache/ftcsbits.c
index 60d46aa7a0..59727d16e2 100644
--- a/src/3rdparty/freetype/src/cache/ftcsbits.c
+++ b/src/3rdparty/freetype/src/cache/ftcsbits.c
@@ -4,7 +4,7 @@
/* */
/* FreeType sbits manager (body). */
/* */
-/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2009 by */
+/* Copyright 2000-2006, 2009-2011, 2013, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -116,7 +116,7 @@
if ( (FT_UInt)(gindex - gnode->gindex) >= snode->count )
{
FT_ERROR(( "ftc_snode_load: invalid glyph index" ));
- return FTC_Err_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
}
sbit = snode->sbits + ( gindex - gnode->gindex );
@@ -142,12 +142,12 @@
goto BadGlyph;
}
- /* Check that our values fit into 8-bit containers! */
+ /* Check whether our values fit into 8-bit containers! */
/* If this is not the case, our bitmap is too large */
/* and we will leave it as `missing' with sbit.buffer = 0 */
-#define CHECK_CHAR( d ) ( temp = (FT_Char)d, temp == d )
-#define CHECK_BYTE( d ) ( temp = (FT_Byte)d, temp == d )
+#define CHECK_CHAR( d ) ( temp = (FT_Char)d, (FT_Int) temp == (FT_Int) d )
+#define CHECK_BYTE( d ) ( temp = (FT_Byte)d, (FT_UInt)temp == (FT_UInt)d )
/* horizontal advance in pixels */
xadvance = ( slot->advance.x + 32 ) >> 6;
@@ -160,7 +160,11 @@
!CHECK_CHAR( slot->bitmap_top ) ||
!CHECK_CHAR( xadvance ) ||
!CHECK_CHAR( yadvance ) )
+ {
+ FT_TRACE2(( "ftc_snode_load:"
+ " glyph too large for small bitmap cache\n"));
goto BadGlyph;
+ }
sbit->width = (FT_Byte)bitmap->width;
sbit->height = (FT_Byte)bitmap->rows;
@@ -185,13 +189,13 @@
/* we mark unloaded glyphs with `sbit.buffer == 0' */
/* and `width == 255', `height == 0' */
/* */
- if ( error && error != FTC_Err_Out_Of_Memory )
+ if ( error && FT_ERR_NEQ( error, Out_Of_Memory ) )
{
BadGlyph:
sbit->width = 255;
sbit->height = 0;
sbit->buffer = NULL;
- error = 0;
+ error = FT_Err_Ok;
if ( asize )
*asize = 0;
}
@@ -213,12 +217,13 @@
FTC_SFamilyClass clazz = FTC_CACHE__SFAMILY_CLASS( cache );
FT_UInt total;
+ FT_UInt node_count;
total = clazz->family_get_count( family, cache->manager );
if ( total == 0 || gindex >= total )
{
- error = FT_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -235,6 +240,10 @@
FTC_GNode_Init( FTC_GNODE( snode ), start, family );
snode->count = count;
+ for ( node_count = 0; node_count < count; node_count++ )
+ {
+ snode->sbits[node_count].width = 255;
+ }
error = ftc_snode_load( snode,
cache->manager,
@@ -315,7 +324,8 @@
FT_LOCAL_DEF( FT_Bool )
ftc_snode_compare( FTC_Node ftcsnode,
FT_Pointer ftcgquery,
- FTC_Cache cache )
+ FTC_Cache cache,
+ FT_Bool* list_changed )
{
FTC_SNode snode = (FTC_SNode)ftcsnode;
FTC_GQuery gquery = (FTC_GQuery)ftcgquery;
@@ -324,6 +334,8 @@
FT_Bool result;
+ if (list_changed)
+ *list_changed = FALSE;
result = FT_BOOL( gnode->family == gquery->family &&
(FT_UInt)( gindex - gnode->gindex ) < snode->count );
if ( result )
@@ -364,7 +376,7 @@
*
*/
- if ( sbit->buffer == NULL && sbit->width != 255 )
+ if ( sbit->buffer == NULL && sbit->width == 255 )
{
FT_ULong size;
FT_Error error;
@@ -377,7 +389,7 @@
{
error = ftc_snode_load( snode, cache->manager, gindex, &size );
}
- FTC_CACHE_TRYLOOP_END();
+ FTC_CACHE_TRYLOOP_END( list_changed );
ftcsnode->ref_count--; /* unlock the node */
@@ -392,13 +404,18 @@
}
+#ifdef FTC_INLINE
+
FT_LOCAL_DEF( FT_Bool )
FTC_SNode_Compare( FTC_SNode snode,
FTC_GQuery gquery,
- FTC_Cache cache )
+ FTC_Cache cache,
+ FT_Bool* list_changed )
{
- return ftc_snode_compare( FTC_NODE( snode ), gquery, cache );
+ return ftc_snode_compare( FTC_NODE( snode ), gquery,
+ cache, list_changed );
}
+#endif
/* END */
diff --git a/src/3rdparty/freetype/src/cache/ftcsbits.h b/src/3rdparty/freetype/src/cache/ftcsbits.h
index 6261745f1e..df55dca806 100644
--- a/src/3rdparty/freetype/src/cache/ftcsbits.h
+++ b/src/3rdparty/freetype/src/cache/ftcsbits.h
@@ -4,7 +4,7 @@
/* */
/* A small-bitmap cache (specification). */
/* */
-/* Copyright 2000-2001, 2002, 2003, 2006 by */
+/* Copyright 2000-2001, 2002, 2003, 2006, 2011 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -83,10 +83,15 @@ FT_BEGIN_HEADER
#endif
+#ifdef FTC_INLINE
+
FT_LOCAL( FT_Bool )
FTC_SNode_Compare( FTC_SNode snode,
FTC_GQuery gquery,
- FTC_Cache cache );
+ FTC_Cache cache,
+ FT_Bool* list_changed);
+
+#endif
/* */