From 1ee02cd0419021c3d4950af2619da39c6e9c47f0 Mon Sep 17 00:00:00 2001 From: marha Date: Mon, 21 Dec 2009 15:22:51 +0000 Subject: Updated to freetype-2.3.11 --- freetype/src/smooth/ftgrays.c | 137 ++++++++++++++++++++++++++---------------- 1 file changed, 85 insertions(+), 52 deletions(-) (limited to 'freetype/src/smooth/ftgrays.c') diff --git a/freetype/src/smooth/ftgrays.c b/freetype/src/smooth/ftgrays.c index 10fa2ae72..846e454e6 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-2001, 2002, 2003, 2005, 2006, 2007, 2008 by */ +/* Copyright 2000-2001, 2002, 2003, 2005, 2006, 2007, 2008, 2009 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -170,6 +170,34 @@ #endif /* !FT_DEBUG_LEVEL_TRACE */ +#define FT_DEFINE_OUTLINE_FUNCS( class_, \ + move_to_, line_to_, \ + conic_to_, cubic_to_, \ + shift_, delta_ ) \ + static const FT_Outline_Funcs class_ = \ + { \ + move_to_, \ + line_to_, \ + conic_to_, \ + cubic_to_, \ + shift_, \ + delta_ \ + }; + +#define FT_DEFINE_RASTER_FUNCS( class_, glyph_format_, \ + raster_new_, raster_reset_, \ + raster_set_mode_, raster_render_, \ + raster_done_ ) \ + const FT_Raster_Funcs class_ = \ + { \ + glyph_format_, \ + raster_new_, \ + raster_reset_, \ + raster_set_mode_, \ + raster_render_, \ + raster_done_ \ + }; + #else /* !_STANDALONE_ */ @@ -181,6 +209,8 @@ #include "ftsmerrs.h" +#include "ftspic.h" + #define ErrRaster_Invalid_Mode Smooth_Err_Cannot_Render_Glyph #define ErrRaster_Invalid_Outline Smooth_Err_Invalid_Outline #define ErrRaster_Memory_Overflow Smooth_Err_Out_Of_Memory @@ -188,7 +218,6 @@ #endif /* !_STANDALONE_ */ - #ifndef FT_MEM_SET #define FT_MEM_SET( d, s, c ) ft_memset( d, s, c ) #endif @@ -201,27 +230,19 @@ #ifndef FT_STATIC_RASTER - #define RAS_ARG PWorker worker #define RAS_ARG_ PWorker worker, #define RAS_VAR worker #define RAS_VAR_ worker, -#define ras (*worker) - - #else /* FT_STATIC_RASTER */ - #define RAS_ARG /* empty */ #define RAS_ARG_ /* empty */ #define RAS_VAR /* empty */ #define RAS_VAR_ /* empty */ - static TWorker ras; - - #endif /* FT_STATIC_RASTER */ @@ -254,7 +275,7 @@ /* need to define them to "float" or "double" when experimenting with */ /* new algorithms */ - typedef int TCoord; /* integer scanline/pixel coordinate */ + typedef long TCoord; /* integer scanline/pixel coordinate */ typedef long TPos; /* sub-pixel coordinate */ /* determine the type used to store cell areas. This normally takes at */ @@ -285,8 +306,8 @@ typedef struct TCell_ { - int x; - int cover; + TPos x; /* same with TWorker.ex */ + TCoord cover; /* same with TWorker.cover */ TArea area; PCell next; @@ -301,12 +322,12 @@ TPos count_ex, count_ey; TArea area; - int cover; + TCoord cover; int invalid; PCell cells; - int max_cells; - int num_cells; + FT_PtrDist max_cells; + FT_PtrDist num_cells; TCoord cx, cy; TPos x, y; @@ -338,11 +359,18 @@ long buffer_size; PCell* ycells; - int ycount; + TPos ycount; } TWorker, *PWorker; +#ifndef FT_STATIC_RASTER +#define ras (*worker) +#else + static TWorker ras; +#endif + + typedef struct TRaster_ { void* buffer; @@ -428,7 +456,7 @@ gray_find_cell( RAS_ARG ) { PCell *pcell, cell; - int x = ras.ex; + TPos x = ras.ex; if ( x > ras.count_ex ) @@ -560,9 +588,9 @@ TPos x2, TCoord y2 ) { - TCoord ex1, ex2, fx1, fx2, delta; + TCoord ex1, ex2, fx1, fx2, delta, mod, lift, rem; long p, first, dx; - int incr, lift, mod, rem; + int incr; dx = x2 - x1; @@ -584,7 +612,7 @@ if ( ex1 == ex2 ) { delta = y2 - y1; - ras.area += (TArea)( fx1 + fx2 ) * delta; + ras.area += (TArea)(( fx1 + fx2 ) * delta); ras.cover += delta; return; } @@ -612,7 +640,7 @@ mod += (TCoord)dx; } - ras.area += (TArea)( fx1 + first ) * delta; + ras.area += (TArea)(( fx1 + first ) * delta); ras.cover += delta; ex1 += incr; @@ -642,7 +670,7 @@ delta++; } - ras.area += (TArea)ONE_PIXEL * delta; + ras.area += (TArea)(ONE_PIXEL * delta); ras.cover += delta; y1 += delta; ex1 += incr; @@ -651,7 +679,7 @@ } delta = y2 - y1; - ras.area += (TArea)( fx2 + ONE_PIXEL - first ) * delta; + ras.area += (TArea)(( fx2 + ONE_PIXEL - first ) * delta); ras.cover += delta; } @@ -664,10 +692,10 @@ gray_render_line( RAS_ARG_ TPos to_x, TPos to_y ) { - TCoord ey1, ey2, fy1, fy2; + TCoord ey1, ey2, fy1, fy2, mod; TPos dx, dy, x, x2; long p, first; - int delta, rem, mod, lift, incr; + int delta, rem, lift, incr; ey1 = TRUNC( ras.last_ey ); @@ -711,7 +739,7 @@ { TCoord ex = TRUNC( ras.x ); TCoord two_fx = (TCoord)( ( ras.x - SUBPIXELS( ex ) ) << 1 ); - TPos area; + TArea area; first = ONE_PIXEL; @@ -726,7 +754,7 @@ ras.cover += delta; ey1 += incr; - gray_set_cell( &ras, ex, ey1 ); + gray_set_cell( RAS_VAR_ ex, ey1 ); delta = (int)( first + first - ONE_PIXEL ); area = (TArea)two_fx * delta; @@ -736,7 +764,7 @@ ras.cover += delta; ey1 += incr; - gray_set_cell( &ras, ex, ey1 ); + gray_set_cell( RAS_VAR_ ex, ey1 ); } delta = (int)( fy2 - ONE_PIXEL + first ); @@ -1104,13 +1132,13 @@ /* record current cell, if any */ - gray_record_cell( worker ); + gray_record_cell( RAS_VAR ); /* start to a new position */ x = UPSCALE( to->x ); y = UPSCALE( to->y ); - gray_start_cell( worker, TRUNC( x ), TRUNC( y ) ); + gray_start_cell( RAS_VAR_ TRUNC( x ), TRUNC( y ) ); worker->x = x; worker->y = y; @@ -1122,7 +1150,7 @@ gray_line_to( const FT_Vector* to, PWorker worker ) { - gray_render_line( worker, UPSCALE( to->x ), UPSCALE( to->y ) ); + gray_render_line( RAS_VAR_ UPSCALE( to->x ), UPSCALE( to->y ) ); return 0; } @@ -1132,7 +1160,7 @@ const FT_Vector* to, PWorker worker ) { - gray_render_conic( worker, control, to ); + gray_render_conic( RAS_VAR_ control, to ); return 0; } @@ -1143,7 +1171,7 @@ const FT_Vector* to, PWorker worker ) { - gray_render_cubic( worker, control1, control2, to ); + gray_render_cubic( RAS_VAR_ control1, control2, to ); return 0; } @@ -1203,7 +1231,7 @@ gray_hline( RAS_ARG_ TCoord x, TCoord y, TPos area, - int acount ) + TCoord acount ) { FT_Span* span; int count; @@ -1243,6 +1271,10 @@ if ( x >= 32767 ) x = 32767; + /* FT_Span.y is an integer, so limit our coordinates appropriately */ + if ( y >= FT_INT_MAX ) + y = FT_INT_MAX; + if ( coverage ) { /* see whether we can add this span to the current list */ @@ -1281,7 +1313,7 @@ #endif /* FT_DEBUG_LEVEL_TRACE */ ras.num_gray_spans = 0; - ras.span_y = y; + ras.span_y = (int)y; count = 0; span = ras.gray_spans; @@ -1317,7 +1349,7 @@ printf( "%3d:", yindex ); for ( cell = ras.ycells[yindex]; cell != NULL; cell = cell->next ) - printf( " (%3d, c:%4d, a:%6d)", cell->x, cell->cover, cell->area ); + printf( " (%3ld, c:%4ld, a:%6d)", cell->x, cell->cover, cell->area ); printf( "\n" ); } } @@ -1349,7 +1381,7 @@ for ( ; cell != NULL; cell = cell->next ) { - TArea area; + TPos area; if ( cell->x > x && cover != 0 ) @@ -1666,23 +1698,25 @@ } TBand; - - static int - gray_convert_glyph_inner( RAS_ARG ) - { - static - const FT_Outline_Funcs func_interface = - { + FT_DEFINE_OUTLINE_FUNCS(func_interface, (FT_Outline_MoveTo_Func) gray_move_to, (FT_Outline_LineTo_Func) gray_line_to, (FT_Outline_ConicTo_Func)gray_conic_to, (FT_Outline_CubicTo_Func)gray_cubic_to, 0, 0 - }; + ) + + static int + gray_convert_glyph_inner( RAS_ARG ) + { volatile int error = 0; +#ifdef FT_CONFIG_OPTION_PIC + FT_Outline_Funcs func_interface; + Init_Class_func_interface(&func_interface); +#endif if ( ft_setjmp( ras.jump_buffer ) == 0 ) { @@ -1829,7 +1863,7 @@ if ( middle == bottom ) { #ifdef FT_DEBUG_LEVEL_TRACE - FT_TRACE7(( "gray_convert_glyph: Rotten glyph!\n" )); + FT_TRACE7(( "gray_convert_glyph: rotten glyph\n" )); #endif return 1; } @@ -1917,7 +1951,7 @@ ras.clip_box.yMax = 32767L; } - gray_init_cells( worker, raster->buffer, raster->buffer_size ); + gray_init_cells( RAS_VAR_ raster->buffer, raster->buffer_size ); ras.outline = *outline; ras.num_cells = 0; @@ -1937,7 +1971,7 @@ ras.render_span_data = &ras; } - return gray_convert_glyph( worker ); + return gray_convert_glyph( RAS_VAR ); } @@ -2037,8 +2071,7 @@ } - const FT_Raster_Funcs ft_grays_raster = - { + FT_DEFINE_RASTER_FUNCS(ft_grays_raster, FT_GLYPH_FORMAT_OUTLINE, (FT_Raster_New_Func) gray_raster_new, @@ -2046,7 +2079,7 @@ (FT_Raster_Set_Mode_Func)0, (FT_Raster_Render_Func) gray_raster_render, (FT_Raster_Done_Func) gray_raster_done - }; + ) /* END */ -- cgit v1.2.3