diff options
Diffstat (limited to 'Build/source/libs/freetype2/freetype-src/src/raster/ftraster.c')
-rw-r--r-- | Build/source/libs/freetype2/freetype-src/src/raster/ftraster.c | 119 |
1 files changed, 71 insertions, 48 deletions
diff --git a/Build/source/libs/freetype2/freetype-src/src/raster/ftraster.c b/Build/source/libs/freetype2/freetype-src/src/raster/ftraster.c index 35655a63467..9f0a7976fad 100644 --- a/Build/source/libs/freetype2/freetype-src/src/raster/ftraster.c +++ b/Build/source/libs/freetype2/freetype-src/src/raster/ftraster.c @@ -62,10 +62,9 @@ #else /* !STANDALONE_ */ -#include <ft2build.h> #include "ftraster.h" -#include FT_INTERNAL_CALC_H /* for FT_MulDiv and FT_MulDiv_No_Round */ -#include FT_OUTLINE_H /* for FT_Outline_Get_CBox */ +#include <freetype/internal/ftcalc.h> /* for FT_MulDiv and FT_MulDiv_No_Round */ +#include <freetype/ftoutln.h> /* for FT_Outline_Get_CBox */ #endif /* !STANDALONE_ */ @@ -226,8 +225,8 @@ #else /* !STANDALONE_ */ -#include FT_INTERNAL_OBJECTS_H -#include FT_INTERNAL_DEBUG_H /* for FT_TRACE, FT_ERROR, and FT_THROW */ +#include <freetype/internal/ftobjs.h> +#include <freetype/internal/ftdebug.h> /* for FT_TRACE, FT_ERROR, and FT_THROW */ #include "rasterrs.h" @@ -460,6 +459,11 @@ #define IS_TOP_OVERSHOOT( x ) \ (Bool)( x - FLOOR( x ) >= ras.precision_half ) + /* Smart dropout rounding to find which pixel is closer to span ends. */ + /* To mimick Windows, symmetric cases break down indepenently of the */ + /* precision. */ +#define SMART( p, q ) FLOOR( ( (p) + (q) + ras.precision * 63 / 64 ) >> 1 ) + #if FT_RENDER_POOL_SIZE > 2048 #define FT_MAX_BLACK_POOL ( FT_RENDER_POOL_SIZE / sizeof ( Long ) ) #else @@ -674,13 +678,13 @@ if ( overshoot ) ras.cProfile->flags |= Overshoot_Bottom; - FT_TRACE6(( " new ascending profile = %p\n", ras.cProfile )); + FT_TRACE6(( " new ascending profile = %p\n", (void *)ras.cProfile )); break; case Descending_State: if ( overshoot ) ras.cProfile->flags |= Overshoot_Top; - FT_TRACE6(( " new descending profile = %p\n", ras.cProfile )); + FT_TRACE6(( " new descending profile = %p\n", (void *)ras.cProfile )); break; default: @@ -737,7 +741,7 @@ FT_TRACE6(( " ending profile %p, start = %ld, height = %ld\n", - ras.cProfile, ras.cProfile->start, h )); + (void *)ras.cProfile, ras.cProfile->start, h )); ras.cProfile->height = h; if ( overshoot ) @@ -2242,11 +2246,10 @@ /* in high-precision mode, we need 12 digits after the comma to */ /* represent multiples of 1/(1<<12) = 1/4096 */ - FT_TRACE7(( " y=%d x=[%.12f;%.12f], drop-out=%d", + FT_TRACE7(( " y=%d x=[% .12f;% .12f]", y, x1 / (double)ras.precision, - x2 / (double)ras.precision, - dropOutControl )); + x2 / (double)ras.precision )); /* Drop-out control */ @@ -2274,7 +2277,7 @@ if ( e2 >= ras.bWidth ) e2 = ras.bWidth - 1; - FT_TRACE7(( " -> x=[%d;%d]", e1, e2 )); + FT_TRACE7(( " -> x=[%ld;%ld]", e1, e2 )); c1 = (Short)( e1 >> 3 ); c2 = (Short)( e2 >> 3 ); @@ -2316,7 +2319,7 @@ Short c1, f1; - FT_TRACE7(( " y=%d x=[%.12f;%.12f]", + FT_TRACE7(( " y=%d x=[% .12f;% .12f]", y, x1 / (double)ras.precision, x2 / (double)ras.precision )); @@ -2353,8 +2356,6 @@ Int dropOutControl = left->flags & 7; - FT_TRACE7(( ", drop-out=%d", dropOutControl )); - if ( e1 == e2 + ras.precision ) { switch ( dropOutControl ) @@ -2364,7 +2365,7 @@ break; case 4: /* smart drop-outs including stubs */ - pxl = FLOOR( ( x1 + x2 - 1 ) / 2 + ras.precision_half ); + pxl = SMART( x1, x2 ); break; case 1: /* simple drop-outs excluding stubs */ @@ -2413,7 +2414,7 @@ if ( dropOutControl == 1 ) pxl = e2; else - pxl = FLOOR( ( x1 + x2 - 1 ) / 2 + ras.precision_half ); + pxl = SMART( x1, x2 ); break; default: /* modes 2, 3, 6, 7 */ @@ -2448,7 +2449,7 @@ if ( e1 >= 0 && e1 < ras.bWidth ) { - FT_TRACE7(( " -> x=%d (drop-out)", e1 )); + FT_TRACE7(( " -> x=%ld", e1 )); c1 = (Short)( e1 >> 3 ); f1 = (Short)( e1 & 7 ); @@ -2457,7 +2458,7 @@ } Exit: - FT_TRACE7(( "\n" )); + FT_TRACE7(( " dropout=%d\n", left->flags & 7 )); } @@ -2495,44 +2496,68 @@ PProfile left, PProfile right ) { + Long e1, e2; + FT_UNUSED( left ); FT_UNUSED( right ); - if ( x2 - x1 < ras.precision ) - { - Long e1, e2; + FT_TRACE7(( " x=%d y=[% .12f;% .12f]", + y, + x1 / (double)ras.precision, + x2 / (double)ras.precision )); + /* We should not need this procedure but the vertical sweep */ + /* mishandles horizontal lines through pixel centers. So we */ + /* have to check perfectly aligned span edges here. */ + /* */ + /* XXX: Can we handle horizontal lines better and drop this? */ - FT_TRACE7(( " x=%d y=[%.12f;%.12f]", - y, - x1 / (double)ras.precision, - x2 / (double)ras.precision )); + e1 = CEILING( x1 ); - e1 = CEILING( x1 ); - e2 = FLOOR ( x2 ); + if ( x1 == e1 ) + { + e1 = TRUNC( e1 ); - if ( e1 == e2 ) + if ( e1 >= 0 && (ULong)e1 < ras.target.rows ) { - e1 = TRUNC( e1 ); - - if ( e1 >= 0 && (ULong)e1 < ras.target.rows ) - { - Byte f1; - PByte bits; + Byte f1; + PByte bits; - FT_TRACE7(( " -> y=%d (drop-out)", e1 )); + bits = ras.bOrigin + ( y >> 3 ) - e1 * ras.target.pitch; + f1 = (Byte)( 0x80 >> ( y & 7 ) ); - bits = ras.bOrigin + ( y >> 3 ) - e1 * ras.target.pitch; - f1 = (Byte)( 0x80 >> ( y & 7 ) ); + FT_TRACE7(( bits[0] & f1 ? " redundant" + : " -> y=%ld edge", e1 )); - bits[0] |= f1; - } + bits[0] |= f1; } + } + + e2 = FLOOR ( x2 ); + + if ( x2 == e2 ) + { + e2 = TRUNC( e2 ); + + if ( e2 >= 0 && (ULong)e2 < ras.target.rows ) + { + Byte f1; + PByte bits; + - FT_TRACE7(( "\n" )); + bits = ras.bOrigin + ( y >> 3 ) - e2 * ras.target.pitch; + f1 = (Byte)( 0x80 >> ( y & 7 ) ); + + FT_TRACE7(( bits[0] & f1 ? " redundant" + : " -> y=%ld edge", e2 )); + + bits[0] |= f1; + } } + + FT_TRACE7(( "\n" )); } @@ -2548,7 +2573,7 @@ Byte f1; - FT_TRACE7(( " x=%d y=[%.12f;%.12f]", + FT_TRACE7(( " x=%d y=[% .12f;% .12f]", y, x1 / (double)ras.precision, x2 / (double)ras.precision )); @@ -2574,8 +2599,6 @@ Int dropOutControl = left->flags & 7; - FT_TRACE7(( ", dropout=%d", dropOutControl )); - if ( e1 == e2 + ras.precision ) { switch ( dropOutControl ) @@ -2585,7 +2608,7 @@ break; case 4: /* smart drop-outs including stubs */ - pxl = FLOOR( ( x1 + x2 - 1 ) / 2 + ras.precision_half ); + pxl = SMART( x1, x2 ); break; case 1: /* simple drop-outs excluding stubs */ @@ -2609,7 +2632,7 @@ if ( dropOutControl == 1 ) pxl = e2; else - pxl = FLOOR( ( x1 + x2 - 1 ) / 2 + ras.precision_half ); + pxl = SMART( x1, x2 ); break; default: /* modes 2, 3, 6, 7 */ @@ -2645,7 +2668,7 @@ if ( e1 >= 0 && (ULong)e1 < ras.target.rows ) { - FT_TRACE7(( " -> y=%d (drop-out)", e1 )); + FT_TRACE7(( " -> y=%ld", e1 )); bits = ras.bOrigin + ( y >> 3 ) - e1 * ras.target.pitch; f1 = (Byte)( 0x80 >> ( y & 7 ) ); @@ -2654,7 +2677,7 @@ } Exit: - FT_TRACE7(( "\n" )); + FT_TRACE7(( " dropout=%d\n", left->flags & 7 )); } |