ref: eb81e37825b8a5a62709f9505d1419e759123b1b
parent: 9a754ce32be316367ff55a1427804249a9fcbed8
author: Werner Lemberg <[email protected]>
date: Sat Jun 3 02:03:11 EDT 2000
More preparation for tracing. Formatting.
--- a/include/freetype/internal/ftdebug.h
+++ b/include/freetype/internal/ftdebug.h
@@ -41,19 +41,27 @@
#ifdef FT_DEBUG_LEVEL_TRACE
+ /* note that not all levels are used currently */
+
typedef enum FT_Trace_
{
/* the first level must always be `trace_any' */
trace_any = 0,
- /* we start with an enum for each common component */
- trace_io, /* i/o monitoring -- see ftsystem.c */
- trace_memory, /* memory manager -- see ftobjs.c */
- trace_stream, /* stream manager -- see ftstream.c */
- trace_calc, /* computations -- see ftcalc.c */
- trace_raster, /* raster -- see ftraster.c */
- trace_list, /* list manager -- see ftlist.c */
- trace_objs, /* base objects -- see ftobjs.c */
+ /* we start with an enum for each base component */
+ trace_aaraster, /* anti-aliasing raster (ftgrays.c) */
+ trace_calc, /* calculations (ftcalc.c) */
+ trace_extend, /* extension manager (ftextend.c) */
+ trace_glyph, /* glyph manager (ftglyph.c) */
+ trace_io, /* i/o monitoring (ftsystem.c) */
+ trace_init, /* initialization (ftinit.c) */
+ trace_list, /* list manager (ftlist.c) */
+ trace_memory, /* memory manager (ftobjs.c) */
+ trace_mm, /* MM interface (ftmm.c) */
+ trace_objs, /* base objects (ftobjs.c) */
+ trace_outline, /* outline management (ftoutln.c) */
+ trace_raster, /* raster (ftraster.c) */
+ trace_stream, /* stream manager (ftstream.c) */
/* then define an enum for each TrueType driver component */
trace_ttobjs,
@@ -64,7 +72,7 @@
trace_ttextend,
trace_ttdriver,
- /* define an enum for each Type1 driver component */
+ /* define an enum for each Type 1 driver component */
trace_t1objs,
trace_t1load,
trace_t1gload,
@@ -72,8 +80,6 @@
trace_t1driver,
/* other trace levels */
- trace_init,
- trace_extend,
/* the last level must always be `trace_max' */
trace_max
@@ -88,37 +94,37 @@
/* */
/* IMPORTANT! */
/* */
- /* Each component must define the macro FT_COMPONENT to a valid */
- /* Trace_Component value before using any TRACE macro. */
+ /* Each component must define the macro FT_COMPONENT to a valid FT_Trace */
+ /* value before using any TRACE macro. */
/* */
/*************************************************************************/
-#define FT_TRACE( level, varformat ) \
- do \
- { \
- if ( ft_trace_levels[FT_COMPONENT] >= level ) \
- FT_XCAT( FT_Message, varformat ); \
+#define FT_TRACE( level, varformat ) \
+ do \
+ { \
+ if ( ft_trace_levels[FT_COMPONENT] >= level ) \
+ FT_XCAT( FT_Message, varformat ); \
} while ( 0 )
- FT_EXPORT_DEF(void) FT_SetTraceLevel( FT_Trace component,
- char level );
+ FT_EXPORT_DEF( void ) FT_SetTraceLevel( FT_Trace component,
+ char level );
#elif defined( FT_DEBUG_LEVEL_ERROR )
-#define FT_TRACE( level, varformat ) while ( 0 ) { } /* nothing */
+#define FT_TRACE( level, varformat ) do ; while ( 0 ) /* nothing */
#else /* release mode */
-#define FT_Assert( condition ) while ( 0 ) { } /* nothing */
+#define FT_Assert( condition ) do ; while ( 0 ) /* nothing */
-#define FT_TRACE( level, varformat ) while ( 0 ) { } /* nothing */
-#define FT_ERROR( varformat ) while ( 0 ) { } /* nothing */
+#define FT_TRACE( level, varformat ) do ; while ( 0 ) /* nothing */
+#define FT_ERROR( varformat ) do ; while ( 0 ) /* nothing */
#endif /* FT_DEBUG_LEVEL_TRACE, FT_DEBUG_LEVEL_ERROR */
@@ -133,11 +139,13 @@
/* */
/*************************************************************************/
+
#if defined( FT_DEBUG_LEVEL_TRACE ) || defined( FT_DEBUG_LEVEL_ERROR )
#include "stdio.h" /* for vprintf() */
+
#define FT_Assert( condition ) \
do \
{ \
@@ -147,19 +155,24 @@
} while ( 0 )
/* print a message */
- FT_EXPORT_DEF(void) FT_Message( const char* fmt, ... );
+ FT_EXPORT_DEF( void ) FT_Message( const char* fmt, ... );
/* print a message and exit */
- FT_EXPORT_DEF(void) FT_Panic ( const char* fmt, ... );
+ FT_EXPORT_DEF( void ) FT_Panic ( const char* fmt, ... );
-#define FT_ERROR(varformat) do { FT_XCAT( FT_Message, varformat ); } while(0)
+#define FT_ERROR( varformat ) FT_XCAT( FT_Message, varformat )
#endif /* FT_DEBUG_LEVEL_TRACE || FT_DEBUG_LEVEL_ERROR */
-/* you need two opening resp. closing parentheses!
- Example: FT_TRACE0(( "Value is %i", foo )) */
+ /*************************************************************************/
+ /* */
+ /* You need two opening resp. closing parentheses! */
+ /* */
+ /* Example: FT_TRACE0(( "Value is %i", foo )) */
+ /* */
+ /*************************************************************************/
#define FT_TRACE0( varformat ) FT_TRACE( 0, varformat )
#define FT_TRACE1( varformat ) FT_TRACE( 1, varformat )
--- a/src/base/ftcalc.c
+++ b/src/base/ftcalc.c
@@ -36,6 +36,16 @@
#include <freetype/internal/ftobjs.h> /* for ABS() */
+ /*************************************************************************/
+ /* */
+ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
+ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
+ /* messages during execution. */
+ /* */
+#undef FT_COMPONENT
+#define FT_COMPONENT trace_calc
+
+
#ifdef FT_CONFIG_OPTION_OLD_CALCS
static const FT_Long ft_square_roots[63] =
--- a/src/base/ftglyph.c
+++ b/src/base/ftglyph.c
@@ -32,6 +32,16 @@
#include <freetype/internal/ftobjs.h>
+ /*************************************************************************/
+ /* */
+ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
+ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
+ /* messages during execution. */
+ /* */
+#undef FT_COMPONENT
+#define FT_COMPONENT trace_glyph
+
+
static
void ft_prepare_glyph( FT_Glyph glyph,
FT_Face face,
@@ -522,8 +532,8 @@
case ft_glyph_type_bitmap:
{
FT_BitmapGlyph bit = (FT_BitmapGlyph)glyph;
-
-
+
+
box->xMin = bit->left;
box->xMax = box->xMin + bit->bitmap.width;
box->yMax = bit->top;
--- a/src/base/ftgrays.c
+++ b/src/base/ftgrays.c
@@ -31,7 +31,7 @@
/* */
/* cc -c -D_STANDALONE_ ftgrays.c */
/* */
- /* The renderer can be initialised with a call to */
+ /* The renderer can be initialized with a call to */
/* `ft_grays_raster.grays_raster_new'; an anti-aliased bitmap can be */
/* generated with a call to `ft_grays_raster.grays_raster_render'. */
/* */
@@ -83,10 +83,23 @@
#include <string.h> /* for memcpy() */
+
+ /*************************************************************************/
+ /* */
+ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
+ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
+ /* messages during execution. */
+ /* */
+#undef FT_COMPONENT
+#define FT_COMPONENT trace_aaraster
+
+
#define ErrRaster_Invalid_Outline -1
+
#ifdef _STANDALONE_
+
#include "ftimage.h"
#include "ftgrays.h"
@@ -94,16 +107,31 @@
/* Its purpose is simply to reduce compiler warnings. Note also that */
/* simply defining it as `(void)x' doesn't avoid warnings with certain */
/* ANSI compilers (e.g. LCC). */
-#define UNUSED( x ) (x) = (x)
+#define UNUSED( x ) (x) = (x)
+ /* Disable the tracing mechanism for simplicity -- developers can */
+ /* activate it easily by redefining these two macros. */
+#ifndef FT_ERROR
+#define FT_ERROR( x ) do ; while ( 0 ) /* nothing */
+#endif
+
+#ifndef FT_TRACE
+#define FT_TRACE( x ) do ; while ( 0 ) /* nothing */
+#endif
+
+
#else /* _STANDALONE_ */
+
#include <freetype/ftgrays.h>
-#include <freetype/internal/ftobjs.h> /* for UNUSED() */
-#include <freetype/freetype.h> /* to link to FT_Outline_Decompose() */
+#include <freetype/internal/ftobjs.h> /* for UNUSED() */
+#include <freetype/internal/ftdebug.h> /* for FT_TRACE() and FT_ERROR() */
+#include <freetype/freetype.h> /* for FT_Outline_Decompose() */
+
#endif /* _STANDALONE_ */
+
/* define this to dump debugging information */
#define xxxDEBUG_GRAYS
@@ -111,6 +139,7 @@
#ifndef FT_STATIC_RASTER
+
#define RAS_ARG PRaster raster
#define RAS_ARG_ PRaster raster,
@@ -119,8 +148,10 @@
#define ras (*raster)
+
#else /* FT_STATIC_RASTER */
+
#define RAS_ARG /* empty */
#define RAS_ARG_ /* empty */
#define RAS_VAR /* empty */
@@ -128,8 +159,10 @@
static TRaster ras;
+
#endif /* FT_STATIC_RASTER */
+
/* must be at least 6 bits! */
#define PIXEL_BITS 8
@@ -1841,7 +1874,7 @@
UNUSED( memory );
-
+
*araster = (FT_Raster)&the_raster;
memset( &the_raster, 0, sizeof ( the_raster ) );
--- a/src/base/ftlist.c
+++ b/src/base/ftlist.c
@@ -30,6 +30,16 @@
/*************************************************************************/
/* */
+ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
+ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
+ /* messages during execution. */
+ /* */
+#undef FT_COMPONENT
+#define FT_COMPONENT trace_list
+
+
+ /*************************************************************************/
+ /* */
/* <Function> */
/* FT_List_Find */
/* */
--- a/src/base/ftmm.c
+++ b/src/base/ftmm.c
@@ -19,6 +19,17 @@
#include <freetype/ftmm.h>
#include <freetype/internal/ftobjs.h>
+
+ /*************************************************************************/
+ /* */
+ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
+ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
+ /* messages during execution. */
+ /* */
+#undef FT_COMPONENT
+#define FT_COMPONENT trace_mm
+
+
FT_EXPORT_FUNC( FT_Error ) FT_Get_Multi_Master( FT_Face face,
FT_Multi_Master* master )
{
@@ -27,7 +38,7 @@
if ( !face )
return FT_Err_Invalid_Face_Handle;
-
+
error = FT_Err_Invalid_Argument;
if ( FT_HAS_MULTIPLE_MASTERS( face ) )
@@ -41,9 +52,9 @@
if ( func )
error = func( face, master );
}
-
+
return error;
- }
+ }
FT_EXPORT_FUNC( FT_Error ) FT_Set_MM_Design_Coordinates(
@@ -53,7 +64,7 @@
{
FT_Error error;
-
+
if ( !face )
return FT_Err_Invalid_Face_Handle;
@@ -70,9 +81,9 @@
if ( func )
error = func( face, num_coords, coords );
}
-
+
return error;
- }
+ }
FT_EXPORT_FUNC( FT_Error ) FT_Set_MM_Blend_Coordinates(
@@ -79,10 +90,10 @@
FT_Face face,
FT_UInt num_coords,
FT_Fixed* coords )
- {
+ {
FT_Error error;
-
+
if ( !face )
return FT_Err_Invalid_Face_Handle;
@@ -98,7 +109,7 @@
if ( func )
error = func( face, num_coords, coords );
}
-
+
return error;
}
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -312,6 +312,11 @@
/*************************************************************************/
/*************************************************************************/
+
+#undef FT_COMPONENT
+#define FT_COMPONENT trace_objs
+
+
/* destructor for sizes list */
static
void destroy_size( FT_Memory memory,
@@ -1798,7 +1803,7 @@
pixel_width = pixel_height;
else if ( pixel_height == 0 )
pixel_height = pixel_width;
-
+
if ( pixel_width < 1 ) pixel_width = 1;
if ( pixel_height < 1 ) pixel_height = 1;
@@ -1978,7 +1983,7 @@
if ( glyph_index >= face->num_glyphs )
return FT_Err_Invalid_Argument;
-
+
driver = face->driver;
/* when the flag NO_RECURSE is set, we disable hinting and scaling */
--- a/src/base/ftoutln.c
+++ b/src/base/ftoutln.c
@@ -27,6 +27,17 @@
#include <freetype/config/ftconfig.h>
#include <freetype/internal/ftobjs.h>
+
+ /*************************************************************************/
+ /* */
+ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
+ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
+ /* messages during execution. */
+ /* */
+#undef FT_COMPONENT
+#define FT_COMPONENT trace_outline
+
+
static
const FT_Outline null_outline = { 0, 0, 0, 0, 0, 0 };
--- a/src/base/ftraster.c
+++ b/src/base/ftraster.c
@@ -128,12 +128,46 @@
/*************************************************************************/
/*************************************************************************/
-/* required by the tracing mode */
+ /*************************************************************************/
+ /* */
+ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
+ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
+ /* messages during execution. */
+ /* */
#undef FT_COMPONENT
#define FT_COMPONENT trace_raster
-#include <freetype/internal/ftdebug.h>
+#ifdef _STANDALONE_
+
+
+ /* This macro is used to indicate that a function parameter is unused. */
+ /* Its purpose is simply to reduce compiler warnings. Note also that */
+ /* simply defining it as `(void)x' doesn't avoid warnings with certain */
+ /* ANSI compilers (e.g. LCC). */
+#define UNUSED( x ) (x) = (x)
+
+ /* Disable the tracing mechanism for simplicity -- developers can */
+ /* activate it easily by redefining these two macros. */
+#ifndef FT_ERROR
+#define FT_ERROR( x ) do ; while ( 0 ) /* nothing */
+#endif
+
+#ifndef FT_TRACE
+#define FT_TRACE( x ) do ; while ( 0 ) /* nothing */
+#endif
+
+
+#else /* _STANDALONE_ */
+
+
+#include <freetype/internal/ftobjs.h>
+#include <freetype/internal/ftdebug.h> /* for FT_TRACE() and FT_ERROR() */
+
+
+#endif /* _STANDALONE_ */
+
+
#define Raster_Err_None 0
#define Raster_Err_Not_Ini -1
#define Raster_Err_Overflow -2
@@ -583,7 +617,7 @@
if ( h > 0 )
{
FT_TRACE1(( "Ending profile %lx, start = %ld, height = %ld\n",
- (long)ras.cProfile, ras.cProfile->start, h ));
+ (long)ras.cProfile, ras.cProfile->start, h ));
oldProfile = ras.cProfile;
ras.cProfile->height = h;
@@ -1557,7 +1591,7 @@
v_last.x = SCALED( points[last].x );
v_last.y = SCALED( points[last].y );
- if ( flipped )
+ if ( flipped )
{
SWAP_( v_start.x, v_start.y );
SWAP_( v_last.x, v_last.y );
@@ -3087,6 +3121,7 @@
#ifdef _STANDALONE_
+
static
int ft_black_new( void* memory,
FT_Raster *araster )
@@ -3109,9 +3144,9 @@
raster->init = 0;
}
+
#else /* _STANDALONE_ */
-#include <freetype/internal/ftobjs.h>
static
int ft_black_new( FT_Memory memory,
@@ -3140,6 +3175,7 @@
FT_Memory memory = (FT_Memory)raster->memory;
FREE( raster );
}
+
#endif /* _STANDALONE_ */
--- a/src/base/ftstream.c
+++ b/src/base/ftstream.c
@@ -154,12 +154,12 @@
{
FT_Error error;
-
+
error = FT_Access_Frame( stream, count );
if ( !error )
{
*pbytes = (FT_Byte*)stream->cursor;
-
+
/* equivalent to FT_Forget_Frame(), with no memory block release */
stream->cursor = 0;
stream->limit = 0;
@@ -166,7 +166,7 @@
}
return error;
- }
+ }
BASE_FUNC( void ) FT_Release_Frame( FT_Stream stream,