ref: 21ddf945c3439f4d3feed27a991a6bcdd5316fb4
parent: 4e56c0d8e3c27b64d8d1b60714691a0199d37696
author: Werner Lemberg <[email protected]>
date: Thu Jun 24 02:56:06 EDT 2004
* include/freetype/internal/ftmemory.h [FT_DEBUG_MEMORY]: Declare FT_QAlloc_Debug and FT_QRealloc_Debug. * src/base/ftutil.c (FT_QAlloc): Fix error and debug messages. (FT_QRealloc): Call FT_QAlloc if original pointer is NULL. Fix error message.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,25 +1,43 @@
-2004-06-23 David Turner <[email protected]>
+2004-06-23 Werner Lemberg <[email protected]>
- * include/freetype/internal/ftmemory.h, src/base/ftutil.c,
- src/base/ftmemdbg.c: introducing the new FT_QAlloc and FT_QRealloc
- functions that do perform allocation without zero-ing out the
- corresponding blocks. Corresponding macros like FT_QALLOC, FT_QNEW,
- etc.. have been defined too
+ * include/freetype/internal/ftmemory.h [FT_DEBUG_MEMORY]: Declare
+ FT_QAlloc_Debug and FT_QRealloc_Debug.
- * include/freetype/config/ftmodule.h: changed the order of modules
- in order to _dramatically_ improve the performance of face open/close
- operations. For example, putting the TrueType driver first in the
- list results in a 5X speedup when opening Vera.ttf !!
+ * src/base/ftutil.c (FT_QAlloc): Fix error and debug messages.
+ (FT_QRealloc): Call FT_QAlloc if original pointer is NULL.
+ Fix error message.
- The problem is really that the PCF and/or BDF drivers are broken
- and do a lot more than necessary simply to detect that they
- cannot handle the font file.
+2004-06-23 David Turner <[email protected]>
- * src/sfnt/ttload.c: small optimization in the kerning table
- verifier, speeds up TrueType face opening by about 7%.
+ * include/freetype/internal/ftmemory.h, src/base/ftutil.c
+ (FT_QAlloc, FT_QRealloc), src/base/ftdbgmem.c (FT_QAlloc_Debug,
+ FT_QRealloc_Debug): New functions that perform allocation without
+ zero-ing out the corresponding blocks.
- Also changed code to use the new FT_QNEW_ARRAY call when
- appropriate to slightly improve performance.
+ * include/freetype/internal/ftmemory.h (FT_MEM_QALLOC,
+ FT_MEM_QREALLOC, FT_MEM_QNEW, FT_MEM_QNEW_ARRAY,
+ FT_MEM_QRENEW_ARRAY, FT_QALLOC, FT_QREALLOC, FT_QNEW, FT_QNEW_ARRAY,
+ FT_QRENEW_ARRAY): New macros.
+
+ * src/base/ftstream.c (FT_Stream_EnterFrame): Use FT_QALLOC.
+ * src/gzip/ftgzip.c (FT_Stream_OpenGzip): Use FT_QNEW_ARRAY.
+ * src/sfnt/sfobjs.c (tt_face_get_name): Use FT_QNEW_ARRAY.
+
+ * src/sfnt/ttload.c (tt_face_load_directory, tt_face_load_metrics,
+ tt_face_load_gasp): Use FT_QNEW_ARRAY.
+ (tt_face_load_kern): Use FT_QNEW_ARRAY.
+ Small optimization in the kerning table verifier; this speeds up
+ TrueType face opening by about 7%.
+ (tt_face_load_hdmx): Use FT_QNEW_ARRAY and FT_QALLOC.
+
+ * include/freetype/config/ftmodule.h: Changed the order of modules,
+ putting TrueType and Type 1 first. This dramatically improves the
+ performance of face open/close operations. For example, putting the
+ TrueType driver first in the list results in a 5x speedup when
+ opening `Vera.ttf'.
+
+ The very problem is that both the PCF and BDF drivers do a lot more
+ than necessary to detect that they cannot handle a font file.
2004-06-22 Werner Lemberg <[email protected]>
--- a/include/freetype/internal/ftmemory.h
+++ b/include/freetype/internal/ftmemory.h
@@ -65,6 +65,13 @@
FT_Long line_no );
FT_BASE( FT_Error )
+ FT_QAlloc_Debug( FT_Memory memory,
+ FT_Long size,
+ void* *P,
+ const char* file_name,
+ FT_Long line_no );
+
+ FT_BASE( FT_Error )
FT_Realloc_Debug( FT_Memory memory,
FT_Long current,
FT_Long size,
@@ -72,6 +79,14 @@
const char* file_name,
FT_Long line_no );
+ FT_BASE( FT_Error )
+ FT_QRealloc_Debug( FT_Memory memory,
+ FT_Long current,
+ FT_Long size,
+ void* *P,
+ const char* file_name,
+ FT_Long line_no );
+
FT_BASE( void )
FT_Free_Debug( FT_Memory memory,
FT_Pointer block,
@@ -108,12 +123,13 @@
FT_Long size,
void* *P );
-
+
FT_BASE( FT_Error )
FT_QAlloc( FT_Memory memory,
FT_Long size,
- void* *p );
+ void* *p );
+
/*************************************************************************/
/* */
/* <Function> */
@@ -148,13 +164,14 @@
FT_Long size,
void* *P );
-
+
FT_BASE( FT_Error )
FT_QRealloc( FT_Memory memory,
FT_Long current,
FT_Long size,
- void* *p );
+ void* *p );
+
/*************************************************************************/
/* */
/* <Function> */
@@ -217,11 +234,11 @@
#define FT_MEM_QALLOC( _pointer_, _size_ ) \
FT_QAlloc_Debug( memory, _size_, \
- (void**)&(_pointer_), __FILE__, __LINE__ )
+ (void**)&(_pointer_), __FILE__, __LINE__ )
#define FT_MEM_QREALLOC( _pointer_, _current_, _size_ ) \
FT_QRealloc_Debug( memory, _current_, _size_, \
- (void**)&(_pointer_), __FILE__, __LINE__ )
+ (void**)&(_pointer_), __FILE__, __LINE__ )
#define FT_MEM_FREE( _pointer_ ) \
FT_Free_Debug( memory, (void**)&(_pointer_), __FILE__, __LINE__ )
@@ -310,7 +327,7 @@
#define FT_QREALLOC( _pointer_, _current_, _size_ ) \
FT_SET_ERROR( FT_MEM_QREALLOC( _pointer_, _current_, _size_ ) )
-
+
#define FT_NEW( _pointer_ ) \
FT_SET_ERROR( FT_MEM_NEW( _pointer_ ) )
@@ -329,9 +346,7 @@
#define FT_QRENEW_ARRAY( _pointer_, _old_, _new_ ) \
FT_SET_ERROR( FT_MEM_QRENEW_ARRAY( _pointer_, _old_, _new_ ) )
-
-
-
+
#define FT_ALLOC_ARRAY( _pointer_, _count_, _type_ ) \
FT_SET_ERROR( FT_MEM_ALLOC( _pointer_, \
(_count_) * sizeof ( _type_ ) ) )
--- a/src/base/ftdbgmem.c
+++ b/src/base/ftdbgmem.c
@@ -696,10 +696,10 @@
FT_BASE_DEF( FT_Error )
FT_QAlloc_Debug( FT_Memory memory,
- FT_Long size,
- void* *P,
- const char* file_name,
- FT_Long line_no )
+ FT_Long size,
+ void* *P,
+ const char* file_name,
+ FT_Long line_no )
{
FT_MemTable table = (FT_MemTable)memory->user;
@@ -709,6 +709,7 @@
table->file_name = file_name;
table->line_no = line_no;
}
+
return FT_QAlloc( memory, size, P );
}
@@ -715,11 +716,11 @@
FT_BASE_DEF( FT_Error )
FT_QRealloc_Debug( FT_Memory memory,
- FT_Long current,
- FT_Long size,
- void* *P,
- const char* file_name,
- FT_Long line_no )
+ FT_Long current,
+ FT_Long size,
+ void* *P,
+ const char* file_name,
+ FT_Long line_no )
{
FT_MemTable table = (FT_MemTable)memory->user;
--- a/src/base/ftutil.c
+++ b/src/base/ftutil.c
@@ -4,7 +4,7 @@
/* */
/* FreeType utility file for memory and list management (body). */
/* */
-/* Copyright 2002 by */
+/* Copyright 2002, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -89,7 +89,7 @@
*P = memory->alloc( memory, size );
if ( !*P )
{
- FT_ERROR(( "FT_Alloc:" ));
+ FT_ERROR(( "FT_QAlloc:" ));
FT_ERROR(( " Out of memory? (%ld requested)\n",
size ));
@@ -99,7 +99,7 @@
else
*P = NULL;
- FT_TRACE7(( "FT_Alloc:" ));
+ FT_TRACE7(( "FT_QAlloc:" ));
FT_TRACE7(( " size = %ld, block = 0x%08p, ref = 0x%08p\n",
size, *P, P ));
@@ -106,7 +106,7 @@
return FT_Err_Ok;
}
-
+
/* documentation is in ftmemory.h */
FT_BASE_DEF( FT_Error )
@@ -160,9 +160,9 @@
FT_ASSERT( P != 0 );
- /* if the original pointer is NULL, call FT_Alloc() */
+ /* if the original pointer is NULL, call FT_QAlloc() */
if ( !*P )
- return FT_Alloc( memory, size, P );
+ return FT_QAlloc( memory, size, P );
/* if the new block if zero-sized, clear the current one */
if ( size <= 0 )
@@ -179,12 +179,13 @@
return FT_Err_Ok;
Fail:
- FT_ERROR(( "FT_Realloc:" ));
+ FT_ERROR(( "FT_QRealloc:" ));
FT_ERROR(( " Failed (current %ld, requested %ld)\n",
current, size ));
return FT_Err_Out_Of_Memory;
}
-
+
+
/* documentation is in ftmemory.h */
FT_BASE_DEF( void )
--- a/src/sfnt/ttload.c
+++ b/src/sfnt/ttload.c
@@ -1716,6 +1716,7 @@
/* ensure that the kerning pair table is sorted (yes, some */
/* fonts have unsorted tables!) */
+
#if 1
if ( num_pairs > 0 )
{
@@ -1722,10 +1723,12 @@
TT_Kern0_Pair pair0 = face->kern_pairs;
FT_ULong prev = TT_KERN_INDEX( pair0->left, pair0->right );
+
for ( pair0++; pair0 < limit; pair0++ )
{
FT_ULong next = TT_KERN_INDEX( pair0->left, pair0->right );
+
if ( next < prev )
goto SortIt;
@@ -1742,9 +1745,10 @@
TT_Kern0_Pair pair0 = face->kern_pairs;
FT_UInt i;
+
for ( i = 1; i < num_pairs; i++, pair0++ )
{
- if ( tt_kern_pair_compare( pair0, pair0+1 ) != -1 )
+ if ( tt_kern_pair_compare( pair0, pair0 + 1 ) != -1 )
{
ft_qsort( (void*)face->kern_pairs, (int)num_pairs,
sizeof ( TT_Kern0_PairRec ), tt_kern_pair_compare );
@@ -1753,6 +1757,7 @@
}
}
#endif
+
goto Exit;
}