From 41bd254198b8b879a562a85f7dc868c3c0f7fbc1 Mon Sep 17 00:00:00 2001 From: marha Date: Mon, 12 Mar 2012 10:33:22 +0100 Subject: Updated to freetype-2.4.9 --- freetype/src/smooth/ftgrays.c | 100 +++++++++++++++++++++++------------------ freetype/src/smooth/ftsmerrs.h | 3 +- freetype/src/smooth/ftsmooth.c | 26 +++++------ freetype/src/smooth/ftspic.c | 49 +++++++++++--------- freetype/src/smooth/ftspic.h | 21 ++++++++- 5 files changed, 120 insertions(+), 79 deletions(-) (limited to 'freetype/src/smooth') diff --git a/freetype/src/smooth/ftgrays.c b/freetype/src/smooth/ftgrays.c index 895e74859..4c0eea596 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-2011 by */ +/* Copyright 2000-2003, 2005-2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -232,10 +232,15 @@ typedef ptrdiff_t FT_PtrDist; /* as usual, for the speed hungry :-) */ +#undef RAS_ARG +#undef RAS_ARG_ +#undef RAS_VAR +#undef RAS_VAR_ + #ifndef FT_STATIC_RASTER -#define RAS_ARG PWorker worker -#define RAS_ARG_ PWorker worker, +#define RAS_ARG gray_PWorker worker +#define RAS_ARG_ gray_PWorker worker, #define RAS_VAR worker #define RAS_VAR_ worker, @@ -253,6 +258,11 @@ typedef ptrdiff_t FT_PtrDist; /* must be at least 6 bits! */ #define PIXEL_BITS 8 +#undef FLOOR +#undef CEILING +#undef TRUNC +#undef SCALED + #define ONE_PIXEL ( 1L << PIXEL_BITS ) #define PIXEL_MASK ( -1L << PIXEL_BITS ) #define TRUNC( x ) ( (TCoord)( (x) >> PIXEL_BITS ) ) @@ -310,15 +320,15 @@ typedef ptrdiff_t FT_PtrDist; typedef struct TCell_ { - TPos x; /* same with TWorker.ex */ - TCoord cover; /* same with TWorker.cover */ - TArea area; - PCell next; + TPos x; /* same with gray_TWorker.ex */ + TCoord cover; /* same with gray_TWorker.cover */ + TArea area; + PCell next; } TCell; - typedef struct TWorker_ + typedef struct gray_TWorker_ { TCoord ex, ey; TPos min_ex, max_ex; @@ -329,7 +339,7 @@ typedef ptrdiff_t FT_PtrDist; TCoord cover; int invalid; - PCell cells; + PCell cells; FT_PtrDist max_cells; FT_PtrDist num_cells; @@ -363,25 +373,25 @@ typedef ptrdiff_t FT_PtrDist; PCell* ycells; TPos ycount; - } TWorker, *PWorker; + } gray_TWorker, *gray_PWorker; #ifndef FT_STATIC_RASTER #define ras (*worker) #else - static TWorker ras; + static gray_TWorker ras; #endif - typedef struct TRaster_ + typedef struct gray_TRaster_ { - void* buffer; - long buffer_size; - int band_size; - void* memory; - PWorker worker; + void* buffer; + long buffer_size; + int band_size; + void* memory; + gray_PWorker worker; - } TRaster, *PRaster; + } gray_TRaster, *gray_PRaster; @@ -878,6 +888,8 @@ typedef ptrdiff_t FT_PtrDist; FT_Vector* arc; + levels = ras.lev_stack; + arc = ras.bez_stack; arc[0].x = UPSCALE( to->x ); arc[0].y = UPSCALE( to->y ); @@ -916,7 +928,6 @@ typedef ptrdiff_t FT_PtrDist; level++; } while ( dx > ONE_PIXEL / 4 ); - levels = ras.lev_stack; levels[0] = level; do @@ -1109,7 +1120,7 @@ typedef ptrdiff_t FT_PtrDist; static int gray_move_to( const FT_Vector* to, - PWorker worker ) + gray_PWorker worker ) { TPos x, y; @@ -1131,7 +1142,7 @@ typedef ptrdiff_t FT_PtrDist; static int gray_line_to( const FT_Vector* to, - PWorker worker ) + gray_PWorker worker ) { gray_render_line( RAS_VAR_ UPSCALE( to->x ), UPSCALE( to->y ) ); return 0; @@ -1141,7 +1152,7 @@ typedef ptrdiff_t FT_PtrDist; static int gray_conic_to( const FT_Vector* control, const FT_Vector* to, - PWorker worker ) + gray_PWorker worker ) { gray_render_conic( RAS_VAR_ control, to ); return 0; @@ -1152,7 +1163,7 @@ typedef ptrdiff_t FT_PtrDist; gray_cubic_to( const FT_Vector* control1, const FT_Vector* control2, const FT_Vector* to, - PWorker worker ) + gray_PWorker worker ) { gray_render_cubic( RAS_VAR_ control1, control2, to ); return 0; @@ -1163,7 +1174,7 @@ typedef ptrdiff_t FT_PtrDist; gray_render_span( int y, int count, const FT_Span* spans, - PWorker worker ) + gray_PWorker worker ) { unsigned char* p; FT_Bitmap* map = &worker->target; @@ -1675,11 +1686,11 @@ typedef ptrdiff_t FT_PtrDist; #endif /* _STANDALONE_ */ - typedef struct TBand_ + typedef struct gray_TBand_ { TPos min, max; - } TBand; + } gray_TBand; FT_DEFINE_OUTLINE_FUNCS(func_interface, (FT_Outline_MoveTo_Func) gray_move_to, @@ -1716,11 +1727,11 @@ typedef ptrdiff_t FT_PtrDist; static int gray_convert_glyph( RAS_ARG ) { - TBand bands[40]; - TBand* volatile band; - int volatile n, num_bands; - TPos volatile min, max, max_y; - FT_BBox* clip; + gray_TBand bands[40]; + gray_TBand* volatile band; + int volatile n, num_bands; + TPos volatile min, max, max_y; + FT_BBox* clip; /* Set up state in the raster object */ @@ -1784,7 +1795,7 @@ typedef ptrdiff_t FT_PtrDist; cell_start += sizeof ( TCell ) - cell_mod; cell_end = ras.buffer_size; - cell_end -= cell_end % sizeof( TCell ); + cell_end -= cell_end % sizeof ( TCell ); cells_max = (PCell)( (char*)ras.buffer + cell_end ); ras.cells = (PCell)( (char*)ras.buffer + cell_start ); @@ -1851,12 +1862,12 @@ typedef ptrdiff_t FT_PtrDist; static int - gray_raster_render( PRaster raster, + gray_raster_render( gray_PRaster raster, const FT_Raster_Params* params ) { const FT_Outline* outline = (const FT_Outline*)params->source; const FT_Bitmap* target_map = params->target; - PWorker worker; + gray_PWorker worker; if ( !raster || !raster->buffer || !raster->buffer_size ) @@ -1948,7 +1959,7 @@ typedef ptrdiff_t FT_PtrDist; gray_raster_new( void* memory, FT_Raster* araster ) { - static TRaster the_raster; + static gray_TRaster the_raster; FT_UNUSED( memory ); @@ -1973,15 +1984,15 @@ typedef ptrdiff_t FT_PtrDist; gray_raster_new( FT_Memory memory, FT_Raster* araster ) { - FT_Error error; - PRaster raster = NULL; + FT_Error error; + gray_PRaster raster = NULL; *araster = 0; - if ( !FT_ALLOC( raster, sizeof ( TRaster ) ) ) + if ( !FT_ALLOC( raster, sizeof ( gray_TRaster ) ) ) { raster->memory = memory; - *araster = (FT_Raster)raster; + *araster = (FT_Raster)raster; } return error; @@ -1991,7 +2002,7 @@ typedef ptrdiff_t FT_PtrDist; static void gray_raster_done( FT_Raster raster ) { - FT_Memory memory = (FT_Memory)((PRaster)raster)->memory; + FT_Memory memory = (FT_Memory)((gray_PRaster)raster)->memory; FT_FREE( raster ); @@ -2005,19 +2016,20 @@ typedef ptrdiff_t FT_PtrDist; char* pool_base, long pool_size ) { - PRaster rast = (PRaster)raster; + gray_PRaster rast = (gray_PRaster)raster; if ( raster ) { - if ( pool_base && pool_size >= (long)sizeof ( TWorker ) + 2048 ) + if ( pool_base && pool_size >= (long)sizeof ( gray_TWorker ) + 2048 ) { - PWorker worker = (PWorker)pool_base; + gray_PWorker worker = (gray_PWorker)pool_base; rast->worker = worker; rast->buffer = pool_base + - ( ( sizeof ( TWorker ) + sizeof ( TCell ) - 1 ) & + ( ( sizeof ( gray_TWorker ) + + sizeof ( TCell ) - 1 ) & ~( sizeof ( TCell ) - 1 ) ); rast->buffer_size = (long)( ( pool_base + pool_size ) - (char*)rast->buffer ) & diff --git a/freetype/src/smooth/ftsmerrs.h b/freetype/src/smooth/ftsmerrs.h index 0c2a2ecd9..413d2f1f7 100644 --- a/freetype/src/smooth/ftsmerrs.h +++ b/freetype/src/smooth/ftsmerrs.h @@ -4,7 +4,7 @@ /* */ /* smooth renderer 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 Smooth_Err_ #define FT_ERR_BASE FT_Mod_Err_Smooth diff --git a/freetype/src/smooth/ftsmooth.c b/freetype/src/smooth/ftsmooth.c index 1350a5661..00499cc28 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-2011 by */ +/* Copyright 2000-2006, 2009-2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -105,9 +105,9 @@ FT_Error error; FT_Outline* outline = NULL; FT_BBox cbox; - FT_UInt width, height, pitch; + FT_Pos width, height, pitch; #ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING - FT_UInt height_org, width_org; + FT_Pos height_org, width_org; #endif FT_Bitmap* bitmap; FT_Memory memory; @@ -151,7 +151,7 @@ return Smooth_Err_Raster_Overflow; } else - width = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 ); + width = ( cbox.xMax - cbox.xMin ) >> 6; if ( cbox.yMin < 0 && cbox.yMax > FT_INT_MAX + cbox.yMin ) { @@ -161,7 +161,7 @@ return Smooth_Err_Raster_Overflow; } else - height = (FT_UInt)( ( cbox.yMax - cbox.yMin ) >> 6 ); + height = ( cbox.yMax - cbox.yMin ) >> 6; bitmap = &slot->bitmap; memory = render->root.memory; @@ -223,7 +223,7 @@ /* Required check is ( pitch * height < FT_ULONG_MAX ), */ /* but we care realistic cases only. Always pitch <= width. */ - if ( width > 0x7FFFU || height > 0x7FFFU ) + if ( width > 0x7FFF || height > 0x7FFF ) { FT_ERROR(( "ft_smooth_render_generic: glyph too large: %u x %u\n", width, height )); @@ -421,10 +421,10 @@ } - FT_DEFINE_RENDERER(ft_smooth_renderer_class, + FT_DEFINE_RENDERER( ft_smooth_renderer_class, FT_MODULE_RENDERER, - sizeof( FT_RendererRec ), + sizeof ( FT_RendererRec ), "smooth", 0x10000L, @@ -448,10 +448,10 @@ ) - FT_DEFINE_RENDERER(ft_smooth_lcd_renderer_class, - + FT_DEFINE_RENDERER( ft_smooth_lcd_renderer_class, + FT_MODULE_RENDERER, - sizeof( FT_RendererRec ), + sizeof ( FT_RendererRec ), "smooth-lcd", 0x10000L, @@ -474,10 +474,10 @@ (FT_Raster_Funcs*) &FT_GRAYS_RASTER_GET ) - FT_DEFINE_RENDERER(ft_smooth_lcdv_renderer_class, + FT_DEFINE_RENDERER( ft_smooth_lcdv_renderer_class, FT_MODULE_RENDERER, - sizeof( FT_RendererRec ), + sizeof ( FT_RendererRec ), "smooth-lcdv", 0x10000L, diff --git a/freetype/src/smooth/ftspic.c b/freetype/src/smooth/ftspic.c index 7adaab17d..601bcf98a 100644 --- a/freetype/src/smooth/ftspic.c +++ b/freetype/src/smooth/ftspic.c @@ -20,21 +20,27 @@ #include FT_FREETYPE_H #include FT_INTERNAL_OBJECTS_H #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*); + void + FT_Init_Class_ft_grays_raster( FT_Raster_Funcs* funcs ); void - ft_smooth_renderer_class_pic_free( FT_Library library ) + ft_smooth_renderer_class_pic_free( FT_Library library ) { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Memory memory = library->memory; + FT_PIC_Container* pic_container = &library->pic_container; + FT_Memory memory = library->memory; + + if ( pic_container->smooth ) { - SmoothPIC* container = (SmoothPIC*)pic_container->smooth; - if(--container->ref_count) + SmoothPIC* container = (SmoothPIC*)pic_container->smooth; + + + if ( --container->ref_count ) return; FT_FREE( container ); pic_container->smooth = NULL; @@ -51,9 +57,9 @@ FT_Memory memory = library->memory; - /* since this function also serve smooth_lcd and smooth_lcdv renderers, + /* since this function also serve smooth_lcd and smooth_lcdv renderers, it implements reference counting */ - if(pic_container->smooth) + if ( pic_container->smooth ) { ((SmoothPIC*)pic_container->smooth)->ref_count++; return error; @@ -62,34 +68,37 @@ /* allocate pointer, clear and set global container pointer */ if ( FT_ALLOC ( container, sizeof ( *container ) ) ) return error; - FT_MEM_SET( container, 0, sizeof(*container) ); + 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 */ - FT_Init_Class_ft_grays_raster(&container->ft_grays_raster); + FT_Init_Class_ft_grays_raster( &container->ft_grays_raster ); /*Exit:*/ - if(error) - ft_smooth_renderer_class_pic_free(library); + 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); + 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_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); + 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); + ft_smooth_renderer_class_pic_free( library ); } #endif /* FT_CONFIG_OPTION_PIC */ diff --git a/freetype/src/smooth/ftspic.h b/freetype/src/smooth/ftspic.h index c7e0ce9d8..4686f5e35 100644 --- a/freetype/src/smooth/ftspic.h +++ b/freetype/src/smooth/ftspic.h @@ -19,7 +19,7 @@ #ifndef __FTSPIC_H__ #define __FTSPIC_H__ - + FT_BEGIN_HEADER #include FT_INTERNAL_PIC_H @@ -38,6 +38,25 @@ FT_BEGIN_HEADER #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 + ft_smooth_renderer_class_pic_free( FT_Library library ); + + void + ft_smooth_lcd_renderer_class_pic_free( FT_Library library ); + + void + ft_smooth_lcdv_renderer_class_pic_free( FT_Library library ); + + FT_Error + ft_smooth_renderer_class_pic_init( FT_Library library ); + + FT_Error + ft_smooth_lcd_renderer_class_pic_init( FT_Library library ); + + FT_Error + ft_smooth_lcdv_renderer_class_pic_init( FT_Library library ); + #endif /* FT_CONFIG_OPTION_PIC */ /* */ -- cgit v1.2.3