aboutsummaryrefslogtreecommitdiff
path: root/freetype/src/smooth
diff options
context:
space:
mode:
Diffstat (limited to 'freetype/src/smooth')
-rw-r--r--freetype/src/smooth/ftgrays.c85
-rw-r--r--freetype/src/smooth/ftsmooth.c35
-rw-r--r--freetype/src/smooth/ftspic.c35
-rw-r--r--freetype/src/smooth/ftspic.h17
4 files changed, 117 insertions, 55 deletions
diff --git a/freetype/src/smooth/ftgrays.c b/freetype/src/smooth/ftgrays.c
index f0db12380..7532a3582 100644
--- a/freetype/src/smooth/ftgrays.c
+++ b/freetype/src/smooth/ftgrays.c
@@ -4,7 +4,7 @@
/* */
/* A new `perfect' anti-aliasing renderer (body). */
/* */
-/* Copyright 2000-2003, 2005-2012 by */
+/* Copyright 2000-2003, 2005-2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -94,6 +94,11 @@
#ifdef _STANDALONE_
+ /* Auxiliary macros for token concatenation. */
+#define FT_ERR_XCAT( x, y ) x ## y
+#define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y )
+
+
/* define this to dump debugging information */
/* #define FT_DEBUG_LEVEL_TRACE */
@@ -154,6 +159,21 @@ typedef ptrdiff_t FT_PtrDist;
va_end( ap );
}
+
+ /* empty function useful for setting a breakpoint to catch errors */
+ int
+ FT_Throw( int error,
+ int line,
+ const char* file )
+ {
+ FT_UNUSED( error );
+ FT_UNUSED( line );
+ FT_UNUSED( file );
+
+ return 0;
+ }
+
+
/* we don't handle tracing levels in stand-alone mode; */
#ifndef FT_TRACE5
#define FT_TRACE5( varformat ) FT_Message varformat
@@ -165,11 +185,19 @@ typedef ptrdiff_t FT_PtrDist;
#define FT_ERROR( varformat ) FT_Message varformat
#endif
+#define FT_THROW( e ) \
+ ( FT_Throw( FT_ERR_CAT( ErrRaster, e ), \
+ __LINE__, \
+ __FILE__ ) | \
+ FT_ERR_CAT( ErrRaster, e ) )
+
#else /* !FT_DEBUG_LEVEL_TRACE */
#define FT_TRACE5( x ) do { } while ( 0 ) /* nothing */
#define FT_TRACE7( x ) do { } while ( 0 ) /* nothing */
#define FT_ERROR( x ) do { } while ( 0 ) /* nothing */
+#define FT_THROW( e ) FT_ERR_CAT( ErrRaster_, e )
+
#endif /* !FT_DEBUG_LEVEL_TRACE */
@@ -202,6 +230,7 @@ typedef ptrdiff_t FT_PtrDist;
raster_done_ \
};
+
#else /* !_STANDALONE_ */
@@ -215,13 +244,14 @@ typedef ptrdiff_t FT_PtrDist;
#include "ftspic.h"
-#define ErrRaster_Invalid_Mode Smooth_Err_Cannot_Render_Glyph
-#define ErrRaster_Invalid_Outline Smooth_Err_Invalid_Outline
+#define Smooth_Err_Invalid_Mode Smooth_Err_Cannot_Render_Glyph
+#define Smooth_Err_Memory_Overflow Smooth_Err_Out_Of_Memory
#define ErrRaster_Memory_Overflow Smooth_Err_Out_Of_Memory
-#define ErrRaster_Invalid_Argument Smooth_Err_Invalid_Argument
+
#endif /* !_STANDALONE_ */
+
#ifndef FT_MEM_SET
#define FT_MEM_SET( d, s, c ) ft_memset( d, s, c )
#endif
@@ -328,6 +358,14 @@ typedef ptrdiff_t FT_PtrDist;
} TCell;
+#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */
+ /* We disable the warning `structure was padded due to */
+ /* __declspec(align())' in order to compile cleanly with */
+ /* the maximum level of warnings. */
+#pragma warning( push )
+#pragma warning( disable : 4324 )
+#endif /* _MSC_VER */
+
typedef struct gray_TWorker_
{
TCoord ex, ey;
@@ -375,6 +413,10 @@ typedef ptrdiff_t FT_PtrDist;
} gray_TWorker, *gray_PWorker;
+#if defined( _MSC_VER )
+#pragma warning( pop )
+#endif
+
#ifndef FT_STATIC_RASTER
#define ras (*worker)
@@ -600,7 +642,7 @@ typedef ptrdiff_t FT_PtrDist;
TPos x2,
TCoord y2 )
{
- TCoord ex1, ex2, fx1, fx2, delta, mod, lift, rem;
+ TCoord ex1, ex2, fx1, fx2, delta, mod;
long p, first, dx;
int incr;
@@ -661,6 +703,9 @@ typedef ptrdiff_t FT_PtrDist;
if ( ex1 != ex2 )
{
+ TCoord lift, rem;
+
+
p = ONE_PIXEL * ( y2 - y1 + delta );
lift = (TCoord)( p / dx );
rem = (TCoord)( p % dx );
@@ -1092,7 +1137,7 @@ typedef ptrdiff_t FT_PtrDist;
goto Split;
/* Split super curvy segments where the off points are so far
- from the chord that the angles P0-P1-P3 or P0-P2-P3 become
+ from the chord that the angles P0-P1-P3 or P0-P2-P3 become
acute as detected by appropriate dot products. */
if ( dx1 * ( dx1 - dx ) + dy1 * ( dy1 - dy ) > 0 ||
dx2 * ( dx2 - dx ) + dy2 * ( dy2 - dy ) > 0 )
@@ -1227,9 +1272,7 @@ typedef ptrdiff_t FT_PtrDist;
TPos area,
TCoord acount )
{
- FT_Span* span;
- int count;
- int coverage;
+ int coverage;
/* compute the coverage line's coverage, depending on the */
@@ -1271,6 +1314,10 @@ typedef ptrdiff_t FT_PtrDist;
if ( coverage )
{
+ FT_Span* span;
+ int count;
+
+
/* see whether we can add this span to the current list */
count = ras.num_gray_spans;
span = ras.gray_spans + count - 1;
@@ -1486,7 +1533,7 @@ typedef ptrdiff_t FT_PtrDist;
if ( !outline || !func_interface )
- return ErrRaster_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
shift = func_interface->shift;
delta = func_interface->delta;
@@ -1699,7 +1746,7 @@ typedef ptrdiff_t FT_PtrDist;
return error;
Invalid_Outline:
- return ErrRaster_Invalid_Outline;
+ return FT_THROW( Invalid_Outline );
}
#endif /* _STANDALONE_ */
@@ -1737,7 +1784,7 @@ typedef ptrdiff_t FT_PtrDist;
gray_record_cell( RAS_VAR );
}
else
- error = ErrRaster_Memory_Overflow;
+ error = FT_THROW( Memory_Overflow );
return error;
}
@@ -1890,21 +1937,21 @@ typedef ptrdiff_t FT_PtrDist;
if ( !raster || !raster->buffer || !raster->buffer_size )
- return ErrRaster_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
if ( !outline )
- return ErrRaster_Invalid_Outline;
+ return FT_THROW( Invalid_Outline );
/* return immediately if the outline is empty */
if ( outline->n_points == 0 || outline->n_contours <= 0 )
return 0;
if ( !outline->contours || !outline->points )
- return ErrRaster_Invalid_Outline;
+ return FT_THROW( Invalid_Outline );
if ( outline->n_points !=
outline->contours[outline->n_contours - 1] + 1 )
- return ErrRaster_Invalid_Outline;
+ return FT_THROW( Invalid_Outline );
worker = raster->worker;
@@ -1912,19 +1959,19 @@ typedef ptrdiff_t FT_PtrDist;
if ( !( params->flags & FT_RASTER_FLAG_DIRECT ) )
{
if ( !target_map )
- return ErrRaster_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
/* nothing to do */
if ( !target_map->width || !target_map->rows )
return 0;
if ( !target_map->buffer )
- return ErrRaster_Invalid_Argument;
+ return FT_THROW( Invalid_Argument );
}
/* this version does not support monochrome rendering */
if ( !( params->flags & FT_RASTER_FLAG_AA ) )
- return ErrRaster_Invalid_Mode;
+ return FT_THROW( Invalid_Mode );
/* compute clipping box */
if ( !( params->flags & FT_RASTER_FLAG_DIRECT ) )
diff --git a/freetype/src/smooth/ftsmooth.c b/freetype/src/smooth/ftsmooth.c
index 8f5300dbb..89088cd09 100644
--- a/freetype/src/smooth/ftsmooth.c
+++ b/freetype/src/smooth/ftsmooth.c
@@ -4,7 +4,7 @@
/* */
/* Anti-aliasing renderer interface (body). */
/* */
-/* Copyright 2000-2006, 2009-2012 by */
+/* Copyright 2000-2006, 2009-2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -61,12 +61,12 @@
const FT_Matrix* matrix,
const FT_Vector* delta )
{
- FT_Error error = Smooth_Err_Ok;
+ FT_Error error = FT_Err_Ok;
if ( slot->format != render->glyph_format )
{
- error = Smooth_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -109,11 +109,13 @@
#ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
FT_Pos height_org, width_org;
#endif
- FT_Bitmap* bitmap;
- FT_Memory memory;
- FT_Int hmul = mode == FT_RENDER_MODE_LCD;
- FT_Int vmul = mode == FT_RENDER_MODE_LCD_V;
- FT_Pos x_shift, y_shift, x_left, y_top;
+ FT_Bitmap* bitmap = &slot->bitmap;
+ FT_Memory memory = render->root.memory;
+ FT_Int hmul = mode == FT_RENDER_MODE_LCD;
+ FT_Int vmul = mode == FT_RENDER_MODE_LCD_V;
+ FT_Pos x_shift = 0;
+ FT_Pos y_shift = 0;
+ FT_Pos x_left, y_top;
FT_Raster_Params params;
@@ -125,14 +127,14 @@
/* check glyph image format */
if ( slot->format != render->glyph_format )
{
- error = Smooth_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
/* check mode */
if ( mode != required_mode )
{
- error = Smooth_Err_Cannot_Render_Glyph;
+ error = FT_THROW( Cannot_Render_Glyph );
goto Exit;
}
@@ -158,7 +160,7 @@
FT_ERROR(( "ft_smooth_render_generic: glyph too large:"
" xMin = %d, xMax = %d\n",
cbox.xMin >> 6, cbox.xMax >> 6 ));
- error = Smooth_Err_Raster_Overflow;
+ error = FT_THROW( Raster_Overflow );
goto Exit;
}
else
@@ -169,15 +171,12 @@
FT_ERROR(( "ft_smooth_render_generic: glyph too large:"
" yMin = %d, yMax = %d\n",
cbox.yMin >> 6, cbox.yMax >> 6 ));
- error = Smooth_Err_Raster_Overflow;
+ error = FT_THROW( Raster_Overflow );
goto Exit;
}
else
height = ( cbox.yMax - cbox.yMin ) >> 6;
- bitmap = &slot->bitmap;
- memory = render->root.memory;
-
#ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
width_org = width;
height_org = height;
@@ -239,7 +238,7 @@
{
FT_ERROR(( "ft_smooth_render_generic: glyph too large: %u x %u\n",
width, height ));
- error = Smooth_Err_Raster_Overflow;
+ error = FT_THROW( Raster_Overflow );
goto Exit;
}
@@ -373,7 +372,7 @@
*/
if ( x_left > FT_INT_MAX || y_top > FT_INT_MAX )
{
- error = Smooth_Err_Invalid_Pixel_Size;
+ error = FT_THROW( Invalid_Pixel_Size );
goto Exit;
}
@@ -384,7 +383,7 @@
/* everything is fine; don't deallocate buffer */
have_buffer = FALSE;
- error = Smooth_Err_Ok;
+ error = FT_Err_Ok;
Exit:
if ( have_outline_shifted )
diff --git a/freetype/src/smooth/ftspic.c b/freetype/src/smooth/ftspic.c
index 4714828fc..67a2b8310 100644
--- a/freetype/src/smooth/ftspic.c
+++ b/freetype/src/smooth/ftspic.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for smooth module. */
/* */
-/* Copyright 2009, 2010, 2012 by */
+/* Copyright 2009, 2010, 2012, 2013 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -22,17 +22,19 @@
#include "ftspic.h"
#include "ftsmerrs.h"
+
#ifdef FT_CONFIG_OPTION_PIC
/* forward declaration of PIC init functions from ftgrays.c */
void
FT_Init_Class_ft_grays_raster( FT_Raster_Funcs* funcs );
+
void
ft_smooth_renderer_class_pic_free( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
- FT_Memory memory = library->memory;
+ FT_Memory memory = library->memory;
if ( pic_container->smooth )
@@ -42,6 +44,7 @@
if ( --container->ref_count )
return;
+
FT_FREE( container );
pic_container->smooth = NULL;
}
@@ -52,7 +55,7 @@
ft_smooth_renderer_class_pic_init( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
- FT_Error error = Smooth_Err_Ok;
+ FT_Error error = FT_Err_Ok;
SmoothPIC* container = NULL;
FT_Memory memory = library->memory;
@@ -66,37 +69,45 @@
}
/* allocate pointer, clear and set global container pointer */
- if ( FT_ALLOC ( container, sizeof ( *container ) ) )
+ if ( FT_ALLOC( container, sizeof ( *container ) ) )
return error;
FT_MEM_SET( container, 0, sizeof ( *container ) );
pic_container->smooth = container;
+
container->ref_count = 1;
- /* initialize pointer table - this is how the module usually expects this data */
+ /* initialize pointer table - */
+ /* this is how the module usually expects this data */
FT_Init_Class_ft_grays_raster( &container->ft_grays_raster );
-/*Exit:*/
- if ( error )
- ft_smooth_renderer_class_pic_free( library );
+
return error;
}
+
/* re-route these init and free functions to the above functions */
- FT_Error ft_smooth_lcd_renderer_class_pic_init( FT_Library library )
+ FT_Error
+ ft_smooth_lcd_renderer_class_pic_init( FT_Library library )
{
return ft_smooth_renderer_class_pic_init( library );
}
- void ft_smooth_lcd_renderer_class_pic_free( FT_Library library )
+
+ void
+ ft_smooth_lcd_renderer_class_pic_free( FT_Library library )
{
ft_smooth_renderer_class_pic_free( library );
}
- FT_Error ft_smooth_lcdv_renderer_class_pic_init( FT_Library library )
+
+ FT_Error
+ ft_smooth_lcdv_renderer_class_pic_init( FT_Library library )
{
return ft_smooth_renderer_class_pic_init( library );
}
- void ft_smooth_lcdv_renderer_class_pic_free( FT_Library library )
+
+ void
+ ft_smooth_lcdv_renderer_class_pic_free( FT_Library library )
{
ft_smooth_renderer_class_pic_free( library );
}
diff --git a/freetype/src/smooth/ftspic.h b/freetype/src/smooth/ftspic.h
index 4686f5e35..334b51c3f 100644
--- a/freetype/src/smooth/ftspic.h
+++ b/freetype/src/smooth/ftspic.h
@@ -25,18 +25,23 @@ FT_BEGIN_HEADER
#include FT_INTERNAL_PIC_H
#ifndef FT_CONFIG_OPTION_PIC
-#define FT_GRAYS_RASTER_GET ft_grays_raster
+
+#define FT_GRAYS_RASTER_GET ft_grays_raster
#else /* FT_CONFIG_OPTION_PIC */
- typedef struct SmoothPIC_
+ typedef struct SmoothPIC_
{
- int ref_count;
- FT_Raster_Funcs ft_grays_raster;
+ int ref_count;
+ FT_Raster_Funcs ft_grays_raster;
+
} SmoothPIC;
-#define GET_PIC(lib) ((SmoothPIC*)((lib)->pic_container.smooth))
-#define FT_GRAYS_RASTER_GET (GET_PIC(library)->ft_grays_raster)
+
+#define GET_PIC( lib ) \
+ ( (SmoothPIC*)( (lib)->pic_container.smooth ) )
+#define FT_GRAYS_RASTER_GET ( GET_PIC( library )->ft_grays_raster )
+
/* see ftspic.c for the implementation */
void