diff options
Diffstat (limited to 'src/3rdparty/freetype/src/raster')
-rw-r--r-- | src/3rdparty/freetype/src/raster/Jamfile | 32 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/raster/ftmisc.h | 9 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/raster/ftraster.c | 454 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/raster/ftraster.h | 5 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/raster/ftrend1.c | 9 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/raster/ftrend1.h | 5 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/raster/module.mk | 2 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/raster/raster.c | 3 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/raster/rasterrs.h | 6 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/raster/rastpic.c | 89 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/raster/rastpic.h | 63 | ||||
-rw-r--r-- | src/3rdparty/freetype/src/raster/rules.mk | 2 |
12 files changed, 227 insertions, 452 deletions
diff --git a/src/3rdparty/freetype/src/raster/Jamfile b/src/3rdparty/freetype/src/raster/Jamfile deleted file mode 100644 index 3990c05cd8..0000000000 --- a/src/3rdparty/freetype/src/raster/Jamfile +++ /dev/null @@ -1,32 +0,0 @@ -# FreeType 2 src/raster Jamfile -# -# Copyright (C) 2001-2019 by -# David Turner, Robert Wilhelm, and Werner Lemberg. -# -# This file is part of the FreeType project, and may only be used, modified, -# and distributed under the terms of the FreeType project license, -# LICENSE.TXT. By continuing to use, modify, or distribute this file you -# indicate that you have read the license and understand and accept it -# fully. - -SubDir FT2_TOP $(FT2_SRC_DIR) raster ; - -{ - local _sources ; - - if $(FT2_MULTI) - { - _sources = ftraster - ftrend1 - rastpic - ; - } - else - { - _sources = raster ; - } - - Library $(FT2_LIB) : $(_sources).c ; -} - -# end of src/raster Jamfile diff --git a/src/3rdparty/freetype/src/raster/ftmisc.h b/src/3rdparty/freetype/src/raster/ftmisc.h index a246569e3b..33dbfd631e 100644 --- a/src/3rdparty/freetype/src/raster/ftmisc.h +++ b/src/3rdparty/freetype/src/raster/ftmisc.h @@ -5,7 +5,7 @@ * Miscellaneous macros for stand-alone rasterizer (specification * only). * - * Copyright (C) 2005-2019 by + * Copyright (C) 2005-2023 by * David Turner, Robert Wilhelm, and Werner Lemberg. * * This file is part of the FreeType project, and may only be used @@ -47,11 +47,8 @@ typedef signed long FT_F26Dot6; typedef int FT_Error; -#define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \ - ( ( (FT_ULong)_x1 << 24 ) | \ - ( (FT_ULong)_x2 << 16 ) | \ - ( (FT_ULong)_x3 << 8 ) | \ - (FT_ULong)_x4 ) + +#define FT_STATIC_BYTE_CAST( type, var ) (type)(FT_Byte)(var) /* from include/freetype/ftsystem.h */ diff --git a/src/3rdparty/freetype/src/raster/ftraster.c b/src/3rdparty/freetype/src/raster/ftraster.c index 023b6c1eff..67cbfd5d9b 100644 --- a/src/3rdparty/freetype/src/raster/ftraster.c +++ b/src/3rdparty/freetype/src/raster/ftraster.c @@ -4,7 +4,7 @@ * * The FreeType glyph rasterizer (body). * - * Copyright (C) 1996-2019 by + * Copyright (C) 1996-2023 by * David Turner, Robert Wilhelm, and Werner Lemberg. * * This file is part of the FreeType project, and may only be used, @@ -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_ */ @@ -150,9 +149,6 @@ /*************************************************************************/ /*************************************************************************/ - /* define DEBUG_RASTER if you want to compile a debugging version */ -/* #define DEBUG_RASTER */ - /*************************************************************************/ /*************************************************************************/ @@ -201,12 +197,13 @@ #define FT_THROW( e ) FT_ERR_CAT( Raster_Err_, e ) #endif -#define Raster_Err_None 0 -#define Raster_Err_Not_Ini -1 -#define Raster_Err_Overflow -2 -#define Raster_Err_Neg_Height -3 -#define Raster_Err_Invalid -4 -#define Raster_Err_Unsupported -5 +#define Raster_Err_Ok 0 +#define Raster_Err_Invalid_Outline -1 +#define Raster_Err_Cannot_Render_Glyph -2 +#define Raster_Err_Invalid_Argument -3 +#define Raster_Err_Raster_Overflow -4 +#define Raster_Err_Raster_Uninitialized -5 +#define Raster_Err_Raster_Negative_Height -6 #define ft_memset memset @@ -226,18 +223,11 @@ #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" -#define Raster_Err_None FT_Err_Ok -#define Raster_Err_Not_Ini Raster_Err_Raster_Uninitialized -#define Raster_Err_Overflow Raster_Err_Raster_Overflow -#define Raster_Err_Neg_Height Raster_Err_Raster_Negative_Height -#define Raster_Err_Invalid Raster_Err_Invalid_Outline -#define Raster_Err_Unsupported Raster_Err_Cannot_Render_Glyph - #endif /* !STANDALONE_ */ @@ -376,16 +366,6 @@ typedef PProfile* PProfileList; - /* Simple record used to implement a stack of bands, required */ - /* by the sub-banding mechanism */ - typedef struct black_TBand_ - { - Short y_min; /* band's minimum */ - Short y_max; /* band's maximum */ - - } black_TBand; - - #define AlignProfileSize \ ( ( sizeof ( TProfile ) + sizeof ( Alignment ) - 1 ) / sizeof ( Long ) ) @@ -427,8 +407,8 @@ /* prototypes used for sweep function dispatch */ typedef void - Function_Sweep_Init( RAS_ARGS Short* min, - Short* max ); + Function_Sweep_Init( RAS_ARGS Short min, + Short max ); typedef void Function_Sweep_Span( RAS_ARGS Short y, @@ -460,6 +440,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 @@ -488,10 +473,11 @@ Int numTurns; /* number of Y-turns in outline */ - TPoint* arc; /* current Bezier arc pointer */ + Byte dropOutControl; /* current drop_out control method */ UShort bWidth; /* target bitmap width */ PByte bOrigin; /* target bitmap bottom-left origin */ + PByte bLine; /* target bitmap current line */ Long lastX, lastY; Long minY, maxY; @@ -513,9 +499,6 @@ FT_Bitmap target; /* description of target bit/pixmap */ FT_Outline outline; - Long traceOfs; /* current offset in target bitmap */ - Short traceIncr; /* sweep's increment in target bitmap */ - /* dispatch variables */ Function_Sweep_Init* Proc_Sweep_Init; @@ -523,18 +506,6 @@ Function_Sweep_Span* Proc_Sweep_Drop; Function_Sweep_Step* Proc_Sweep_Step; - Byte dropOutControl; /* current drop_out control method */ - - Bool second_pass; /* indicates whether a horizontal pass */ - /* should be performed to control */ - /* drop-out accurately when calling */ - /* Render_Glyph. */ - - TPoint arcs[3 * MaxBezier + 1]; /* The Bezier stack */ - - black_TBand band_stack[16]; /* band stack used for sub-banding */ - Int band_top; /* band stack top */ - }; @@ -656,7 +627,7 @@ if ( ras.top >= ras.maxBuff ) { - ras.error = FT_THROW( Overflow ); + ras.error = FT_THROW( Raster_Overflow ); return FAILURE; } @@ -674,18 +645,18 @@ 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: FT_ERROR(( "New_Profile: invalid profile direction\n" )); - ras.error = FT_THROW( Invalid ); + ras.error = FT_THROW( Invalid_Outline ); return FAILURE; } @@ -727,7 +698,7 @@ if ( h < 0 ) { FT_ERROR(( "End_Profile: negative height encountered\n" )); - ras.error = FT_THROW( Neg_Height ); + ras.error = FT_THROW( Raster_Negative_Height ); return FAILURE; } @@ -737,7 +708,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 ) @@ -763,7 +734,7 @@ if ( ras.top >= ras.maxBuff ) { FT_TRACE1(( "overflow in End_Profile\n" )); - ras.error = FT_THROW( Overflow ); + ras.error = FT_THROW( Raster_Overflow ); return FAILURE; } @@ -818,7 +789,7 @@ ras.maxBuff--; if ( ras.maxBuff <= ras.top ) { - ras.error = FT_THROW( Overflow ); + ras.error = FT_THROW( Raster_Overflow ); return FAILURE; } ras.numTurns++; @@ -1082,7 +1053,7 @@ size = e2 - e1 + 1; if ( ras.top + size >= ras.maxBuff ) { - ras.error = FT_THROW( Overflow ); + ras.error = FT_THROW( Raster_Overflow ); return FAILURE; } @@ -1205,6 +1176,7 @@ */ static Bool Bezier_Up( RAS_ARGS Int degree, + TPoint* arc, TSplitter splitter, Long miny, Long maxy ) @@ -1212,13 +1184,11 @@ Long y1, y2, e, e2, e0; Short f1; - TPoint* arc; TPoint* start_arc; PLong top; - arc = ras.arc; y1 = arc[degree].y; y2 = arc[0].y; top = ras.top; @@ -1267,7 +1237,7 @@ if ( ( top + TRUNC( e2 - e ) + 1 ) >= ras.maxBuff ) { ras.top = top; - ras.error = FT_THROW( Overflow ); + ras.error = FT_THROW( Raster_Overflow ); return FAILURE; } @@ -1310,7 +1280,6 @@ Fin: ras.top = top; - ras.arc -= degree; return SUCCESS; } @@ -1342,11 +1311,11 @@ */ static Bool Bezier_Down( RAS_ARGS Int degree, + TPoint* arc, TSplitter splitter, Long miny, Long maxy ) { - TPoint* arc = ras.arc; Bool result, fresh; @@ -1358,7 +1327,7 @@ fresh = ras.fresh; - result = Bezier_Up( RAS_VARS degree, splitter, -maxy, -miny ); + result = Bezier_Up( RAS_VARS degree, arc, splitter, -maxy, -miny ); if ( fresh && !ras.fresh ) ras.cProfile->start = -ras.cProfile->start; @@ -1499,22 +1468,24 @@ { Long y1, y2, y3, x3, ymin, ymax; TStates state_bez; + TPoint arcs[2 * MaxBezier + 1]; /* The Bezier stack */ + TPoint* arc; /* current Bezier arc pointer */ - ras.arc = ras.arcs; - ras.arc[2].x = ras.lastX; - ras.arc[2].y = ras.lastY; - ras.arc[1].x = cx; - ras.arc[1].y = cy; - ras.arc[0].x = x; - ras.arc[0].y = y; + arc = arcs; + arc[2].x = ras.lastX; + arc[2].y = ras.lastY; + arc[1].x = cx; + arc[1].y = cy; + arc[0].x = x; + arc[0].y = y; do { - y1 = ras.arc[2].y; - y2 = ras.arc[1].y; - y3 = ras.arc[0].y; - x3 = ras.arc[0].x; + y1 = arc[2].y; + y2 = arc[1].y; + y3 = arc[0].y; + x3 = arc[0].x; /* first, categorize the Bezier arc */ @@ -1532,13 +1503,13 @@ if ( y2 < ymin || y2 > ymax ) { /* this arc has no given direction, split it! */ - Split_Conic( ras.arc ); - ras.arc += 2; + Split_Conic( arc ); + arc += 2; } else if ( y1 == y3 ) { /* this arc is flat, ignore it and pop it from the Bezier stack */ - ras.arc -= 2; + arc -= 2; } else { @@ -1565,15 +1536,18 @@ /* now call the appropriate routine */ if ( state_bez == Ascending_State ) { - if ( Bezier_Up( RAS_VARS 2, Split_Conic, ras.minY, ras.maxY ) ) + if ( Bezier_Up( RAS_VARS 2, arc, Split_Conic, + ras.minY, ras.maxY ) ) goto Fail; } else - if ( Bezier_Down( RAS_VARS 2, Split_Conic, ras.minY, ras.maxY ) ) + if ( Bezier_Down( RAS_VARS 2, arc, Split_Conic, + ras.minY, ras.maxY ) ) goto Fail; + arc -= 2; } - } while ( ras.arc >= ras.arcs ); + } while ( arc >= arcs ); ras.lastX = x3; ras.lastY = y3; @@ -1628,25 +1602,27 @@ { Long y1, y2, y3, y4, x4, ymin1, ymax1, ymin2, ymax2; TStates state_bez; + TPoint arcs[3 * MaxBezier + 1]; /* The Bezier stack */ + TPoint* arc; /* current Bezier arc pointer */ - ras.arc = ras.arcs; - ras.arc[3].x = ras.lastX; - ras.arc[3].y = ras.lastY; - ras.arc[2].x = cx1; - ras.arc[2].y = cy1; - ras.arc[1].x = cx2; - ras.arc[1].y = cy2; - ras.arc[0].x = x; - ras.arc[0].y = y; + arc = arcs; + arc[3].x = ras.lastX; + arc[3].y = ras.lastY; + arc[2].x = cx1; + arc[2].y = cy1; + arc[1].x = cx2; + arc[1].y = cy2; + arc[0].x = x; + arc[0].y = y; do { - y1 = ras.arc[3].y; - y2 = ras.arc[2].y; - y3 = ras.arc[1].y; - y4 = ras.arc[0].y; - x4 = ras.arc[0].x; + y1 = arc[3].y; + y2 = arc[2].y; + y3 = arc[1].y; + y4 = arc[0].y; + x4 = arc[0].x; /* first, categorize the Bezier arc */ @@ -1675,13 +1651,13 @@ if ( ymin2 < ymin1 || ymax2 > ymax1 ) { /* this arc has no given direction, split it! */ - Split_Cubic( ras.arc ); - ras.arc += 3; + Split_Cubic( arc ); + arc += 3; } else if ( y1 == y4 ) { /* this arc is flat, ignore it and pop it from the Bezier stack */ - ras.arc -= 3; + arc -= 3; } else { @@ -1707,15 +1683,18 @@ /* compute intersections */ if ( state_bez == Ascending_State ) { - if ( Bezier_Up( RAS_VARS 3, Split_Cubic, ras.minY, ras.maxY ) ) + if ( Bezier_Up( RAS_VARS 3, arc, Split_Cubic, + ras.minY, ras.maxY ) ) goto Fail; } else - if ( Bezier_Down( RAS_VARS 3, Split_Cubic, ras.minY, ras.maxY ) ) + if ( Bezier_Down( RAS_VARS 3, arc, Split_Cubic, + ras.minY, ras.maxY ) ) goto Fail; + arc -= 3; } - } while ( ras.arc >= ras.arcs ); + } while ( arc >= arcs ); ras.lastX = x4; ras.lastY = y4; @@ -1963,7 +1942,7 @@ return SUCCESS; Invalid_Outline: - ras.error = FT_THROW( Invalid ); + ras.error = FT_THROW( Invalid_Outline ); Fail: return FAILURE; @@ -2116,8 +2095,8 @@ * Removes an old profile from a linked list. */ static void - DelOld( PProfileList list, - PProfile profile ) + DelOld( PProfileList list, + const PProfile profile ) { PProfile *old, current; @@ -2210,16 +2189,13 @@ */ static void - Vertical_Sweep_Init( RAS_ARGS Short* min, - Short* max ) + Vertical_Sweep_Init( RAS_ARGS Short min, + Short max ) { - Long pitch = ras.target.pitch; - FT_UNUSED( max ); - ras.traceIncr = (Short)-pitch; - ras.traceOfs = -*min * pitch; + ras.bLine = ras.bOrigin - min * ras.target.pitch; } @@ -2230,8 +2206,7 @@ PProfile left, PProfile right ) { - Long e1, e2; - Byte* target; + Long e1, e2; Int dropOutControl = left->flags & 7; @@ -2242,11 +2217,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 )); + (double)x1 / (double)ras.precision, + (double)x2 / (double)ras.precision )); /* Drop-out control */ @@ -2265,6 +2239,8 @@ if ( e2 >= 0 && e1 < ras.bWidth ) { + Byte* target; + Int c1, c2; Byte f1, f2; @@ -2274,7 +2250,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 ); @@ -2282,7 +2258,7 @@ f1 = (Byte) ( 0xFF >> ( e1 & 7 ) ); f2 = (Byte) ~( 0x7F >> ( e2 & 7 ) ); - target = ras.bOrigin + ras.traceOfs + c1; + target = ras.bLine + c1; c2 -= c1; if ( c2 > 0 ) @@ -2293,7 +2269,7 @@ /* This is due to the fact that, in the vast majority of cases, */ /* the span length in bytes is relatively small. */ while ( --c2 > 0 ) - *(++target) = 0xFF; + *( ++target ) = 0xFF; target[1] |= f2; } @@ -2316,10 +2292,10 @@ 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 )); + (double)x1 / (double)ras.precision, + (double)x2 / (double)ras.precision )); /* Drop-out control */ @@ -2353,8 +2329,6 @@ Int dropOutControl = left->flags & 7; - FT_TRACE7(( ", drop-out=%d", dropOutControl )); - if ( e1 == e2 + ras.precision ) { switch ( dropOutControl ) @@ -2364,7 +2338,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 +2387,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 */ @@ -2436,8 +2410,8 @@ c1 = (Short)( e1 >> 3 ); f1 = (Short)( e1 & 7 ); - if ( e1 >= 0 && e1 < ras.bWidth && - ras.bOrigin[ras.traceOfs + c1] & ( 0x80 >> f1 ) ) + if ( e1 >= 0 && e1 < ras.bWidth && + ras.bLine[c1] & ( 0x80 >> f1 ) ) goto Exit; } else @@ -2448,23 +2422,23 @@ 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 ); - ras.bOrigin[ras.traceOfs + c1] |= (char)( 0x80 >> f1 ); + ras.bLine[c1] |= (char)( 0x80 >> f1 ); } Exit: - FT_TRACE7(( "\n" )); + FT_TRACE7(( " dropout=%d\n", left->flags & 7 )); } static void Vertical_Sweep_Step( RAS_ARG ) { - ras.traceOfs += ras.traceIncr; + ras.bLine -= ras.target.pitch; } @@ -2478,8 +2452,8 @@ */ static void - Horizontal_Sweep_Init( RAS_ARGS Short* min, - Short* max ) + Horizontal_Sweep_Init( RAS_ARGS Short min, + Short max ) { /* nothing, really */ FT_UNUSED_RASTER; @@ -2495,44 +2469,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, + (double)x1 / (double)ras.precision, + (double)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; + + + bits = ras.bOrigin + ( y >> 3 ) - e2 * ras.target.pitch; + f1 = (Byte)( 0x80 >> ( y & 7 ) ); + + FT_TRACE7(( bits[0] & f1 ? " redundant" + : " -> y=%ld edge", e2 )); - FT_TRACE7(( "\n" )); + bits[0] |= f1; + } } + + FT_TRACE7(( "\n" )); } @@ -2548,10 +2546,10 @@ 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 )); + (double)x1 / (double)ras.precision, + (double)x2 / (double)ras.precision )); /* During the horizontal sweep, we only take care of drop-outs */ @@ -2574,8 +2572,6 @@ Int dropOutControl = left->flags & 7; - FT_TRACE7(( ", dropout=%d", dropOutControl )); - if ( e1 == e2 + ras.precision ) { switch ( dropOutControl ) @@ -2585,7 +2581,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 +2605,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 +2641,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 +2650,7 @@ } Exit: - FT_TRACE7(( "\n" )); + FT_TRACE7(( " dropout=%d\n", left->flags & 7 )); } @@ -2721,13 +2717,13 @@ /* check the Y-turns */ if ( ras.numTurns == 0 ) { - ras.error = FT_THROW( Invalid ); + ras.error = FT_THROW( Invalid_Outline ); return FAILURE; } /* now initialize the sweep */ - ras.Proc_Sweep_Init( RAS_VARS &min_Y, &max_Y ); + ras.Proc_Sweep_Init( RAS_VARS min_Y, max_Y ); /* then compute the distance of each profile from min_Y */ @@ -2954,11 +2950,11 @@ FT_Outline_Get_CBox( const FT_Outline* outline, FT_BBox *acbox ) { - Long xMin, yMin, xMax, yMax; - - if ( outline && acbox ) { + Long xMin, yMin, xMax, yMax; + + if ( outline->n_points == 0 ) { xMin = 0; @@ -3016,63 +3012,54 @@ * Renderer error code. */ static int - Render_Single_Pass( RAS_ARGS Bool flipped ) + Render_Single_Pass( RAS_ARGS Bool flipped, + Int y_min, + Int y_max ) { - Short i, j, k; + Int y_mid; + Int band_top = 0; + Int band_stack[32]; /* enough to bisect 32-bit int bands */ - while ( ras.band_top >= 0 ) + while ( 1 ) { - ras.maxY = (Long)ras.band_stack[ras.band_top].y_max * ras.precision; - ras.minY = (Long)ras.band_stack[ras.band_top].y_min * ras.precision; + ras.minY = (Long)y_min * ras.precision; + ras.maxY = (Long)y_max * ras.precision; ras.top = ras.buff; - ras.error = Raster_Err_None; + ras.error = Raster_Err_Ok; if ( Convert_Glyph( RAS_VARS flipped ) ) { - if ( ras.error != Raster_Err_Overflow ) - return FAILURE; - - ras.error = Raster_Err_None; + if ( ras.error != Raster_Err_Raster_Overflow ) + return ras.error; /* sub-banding */ -#ifdef DEBUG_RASTER - ClearBand( RAS_VARS TRUNC( ras.minY ), TRUNC( ras.maxY ) ); -#endif - - i = ras.band_stack[ras.band_top].y_min; - j = ras.band_stack[ras.band_top].y_max; - - k = (Short)( ( i + j ) / 2 ); + if ( y_min == y_max ) + return ras.error; /* still Raster_Overflow */ - if ( ras.band_top >= 7 || k < i ) - { - ras.band_top = 0; - ras.error = FT_THROW( Invalid ); + y_mid = ( y_min + y_max ) >> 1; - return ras.error; - } - - ras.band_stack[ras.band_top + 1].y_min = k; - ras.band_stack[ras.band_top + 1].y_max = j; - - ras.band_stack[ras.band_top].y_max = (Short)( k - 1 ); - - ras.band_top++; + band_stack[band_top++] = y_min; + y_min = y_mid + 1; } else { if ( ras.fProfile ) if ( Draw_Sweep( RAS_VAR ) ) return ras.error; - ras.band_top--; + + if ( --band_top < 0 ) + break; + + y_max = y_min - 1; + y_min = band_stack[band_top]; } } - return SUCCESS; + return Raster_Err_Ok; } @@ -3109,9 +3096,6 @@ ras.dropOutControl += 1; } - ras.second_pass = (Bool)( !( ras.outline.flags & - FT_OUTLINE_SINGLE_PASS ) ); - /* Vertical Sweep */ FT_TRACE7(( "Vertical pass (ftraster)\n" )); @@ -3120,21 +3104,18 @@ ras.Proc_Sweep_Drop = Vertical_Sweep_Drop; ras.Proc_Sweep_Step = Vertical_Sweep_Step; - ras.band_top = 0; - ras.band_stack[0].y_min = 0; - ras.band_stack[0].y_max = (Short)( ras.target.rows - 1 ); - ras.bWidth = (UShort)ras.target.width; ras.bOrigin = (Byte*)ras.target.buffer; if ( ras.target.pitch > 0 ) ras.bOrigin += (Long)( ras.target.rows - 1 ) * ras.target.pitch; - if ( ( error = Render_Single_Pass( RAS_VARS 0 ) ) != 0 ) + error = Render_Single_Pass( RAS_VARS 0, 0, (Int)ras.target.rows - 1 ); + if ( error ) return error; /* Horizontal Sweep */ - if ( ras.second_pass && ras.dropOutControl != 2 ) + if ( !( ras.outline.flags & FT_OUTLINE_SINGLE_PASS ) ) { FT_TRACE7(( "Horizontal pass (ftraster)\n" )); @@ -3143,22 +3124,12 @@ ras.Proc_Sweep_Drop = Horizontal_Sweep_Drop; ras.Proc_Sweep_Step = Horizontal_Sweep_Step; - ras.band_top = 0; - ras.band_stack[0].y_min = 0; - ras.band_stack[0].y_max = (Short)( ras.target.width - 1 ); - - if ( ( error = Render_Single_Pass( RAS_VARS 1 ) ) != 0 ) + error = Render_Single_Pass( RAS_VARS 1, 0, (Int)ras.target.width - 1 ); + if ( error ) return error; } - return Raster_Err_None; - } - - - static void - ft_black_init( black_PRaster raster ) - { - FT_UNUSED( raster ); + return Raster_Err_Ok; } @@ -3179,7 +3150,6 @@ *araster = (FT_Raster)&the_raster; FT_ZERO( &the_raster ); - ft_black_init( &the_raster ); return 0; } @@ -3204,14 +3174,10 @@ black_PRaster raster = NULL; - *araster = 0; if ( !FT_NEW( raster ) ) - { raster->memory = memory; - ft_black_init( raster ); - *araster = raster; - } + *araster = raster; return error; } @@ -3269,38 +3235,36 @@ if ( !raster ) - return FT_THROW( Not_Ini ); + return FT_THROW( Raster_Uninitialized ); if ( !outline ) - return FT_THROW( Invalid ); + return FT_THROW( Invalid_Outline ); /* return immediately if the outline is empty */ if ( outline->n_points == 0 || outline->n_contours <= 0 ) - return Raster_Err_None; + return Raster_Err_Ok; if ( !outline->contours || !outline->points ) - return FT_THROW( Invalid ); + return FT_THROW( Invalid_Outline ); if ( outline->n_points != outline->contours[outline->n_contours - 1] + 1 ) - return FT_THROW( Invalid ); + return FT_THROW( Invalid_Outline ); /* this version of the raster does not support direct rendering, sorry */ - if ( params->flags & FT_RASTER_FLAG_DIRECT ) - return FT_THROW( Unsupported ); - - if ( params->flags & FT_RASTER_FLAG_AA ) - return FT_THROW( Unsupported ); + if ( params->flags & FT_RASTER_FLAG_DIRECT || + params->flags & FT_RASTER_FLAG_AA ) + return FT_THROW( Cannot_Render_Glyph ); if ( !target_map ) - return FT_THROW( Invalid ); + return FT_THROW( Invalid_Argument ); /* nothing to do */ if ( !target_map->width || !target_map->rows ) - return Raster_Err_None; + return Raster_Err_Ok; if ( !target_map->buffer ) - return FT_THROW( Invalid ); + return FT_THROW( Invalid_Argument ); ras.outline = *outline; ras.target = *target_map; diff --git a/src/3rdparty/freetype/src/raster/ftraster.h b/src/3rdparty/freetype/src/raster/ftraster.h index 50d34201a1..b511b3a99e 100644 --- a/src/3rdparty/freetype/src/raster/ftraster.h +++ b/src/3rdparty/freetype/src/raster/ftraster.h @@ -4,7 +4,7 @@ * * The FreeType glyph rasterizer (specification). * - * Copyright (C) 1996-2019 by + * Copyright (C) 1996-2023 by * David Turner, Robert Wilhelm, and Werner Lemberg. * * This file is part of the FreeType project, and may only be used @@ -22,8 +22,9 @@ #include <ft2build.h> #include FT_CONFIG_CONFIG_H -#include FT_IMAGE_H +#include <freetype/ftimage.h> +#include <freetype/internal/compiler-macros.h> FT_BEGIN_HEADER diff --git a/src/3rdparty/freetype/src/raster/ftrend1.c b/src/3rdparty/freetype/src/raster/ftrend1.c index 62c727182a..0b5d867147 100644 --- a/src/3rdparty/freetype/src/raster/ftrend1.c +++ b/src/3rdparty/freetype/src/raster/ftrend1.c @@ -4,7 +4,7 @@ * * The FreeType glyph rasterizer interface (body). * - * Copyright (C) 1996-2019 by + * Copyright (C) 1996-2023 by * David Turner, Robert Wilhelm, and Werner Lemberg. * * This file is part of the FreeType project, and may only be used, @@ -16,10 +16,9 @@ */ -#include <ft2build.h> -#include FT_INTERNAL_DEBUG_H -#include FT_INTERNAL_OBJECTS_H -#include FT_OUTLINE_H +#include <freetype/internal/ftdebug.h> +#include <freetype/internal/ftobjs.h> +#include <freetype/ftoutln.h> #include "ftrend1.h" #include "ftraster.h" diff --git a/src/3rdparty/freetype/src/raster/ftrend1.h b/src/3rdparty/freetype/src/raster/ftrend1.h index 82ecac686c..cec35c8528 100644 --- a/src/3rdparty/freetype/src/raster/ftrend1.h +++ b/src/3rdparty/freetype/src/raster/ftrend1.h @@ -4,7 +4,7 @@ * * The FreeType glyph rasterizer interface (specification). * - * Copyright (C) 1996-2019 by + * Copyright (C) 1996-2023 by * David Turner, Robert Wilhelm, and Werner Lemberg. * * This file is part of the FreeType project, and may only be used, @@ -20,8 +20,7 @@ #define FTREND1_H_ -#include <ft2build.h> -#include FT_RENDER_H +#include <freetype/ftrender.h> FT_BEGIN_HEADER diff --git a/src/3rdparty/freetype/src/raster/module.mk b/src/3rdparty/freetype/src/raster/module.mk index 0a6d4b09d9..6ad1aa77b4 100644 --- a/src/3rdparty/freetype/src/raster/module.mk +++ b/src/3rdparty/freetype/src/raster/module.mk @@ -3,7 +3,7 @@ # -# Copyright (C) 1996-2019 by +# Copyright (C) 1996-2023 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/raster/raster.c b/src/3rdparty/freetype/src/raster/raster.c index e3ac9e566a..82f474547d 100644 --- a/src/3rdparty/freetype/src/raster/raster.c +++ b/src/3rdparty/freetype/src/raster/raster.c @@ -4,7 +4,7 @@ * * FreeType monochrome rasterer module component (body only). * - * Copyright (C) 1996-2019 by + * Copyright (C) 1996-2023 by * David Turner, Robert Wilhelm, and Werner Lemberg. * * This file is part of the FreeType project, and may only be used, @@ -17,7 +17,6 @@ #define FT_MAKE_OPTION_SINGLE_OBJECT -#include <ft2build.h> #include "ftraster.c" #include "ftrend1.c" diff --git a/src/3rdparty/freetype/src/raster/rasterrs.h b/src/3rdparty/freetype/src/raster/rasterrs.h index 7266407365..989d8b44be 100644 --- a/src/3rdparty/freetype/src/raster/rasterrs.h +++ b/src/3rdparty/freetype/src/raster/rasterrs.h @@ -4,7 +4,7 @@ * * monochrome renderer error codes (specification only). * - * Copyright (C) 2001-2019 by + * Copyright (C) 2001-2023 by * David Turner, Robert Wilhelm, and Werner Lemberg. * * This file is part of the FreeType project, and may only be used, @@ -26,7 +26,7 @@ #ifndef RASTERRS_H_ #define RASTERRS_H_ -#include FT_MODULE_ERRORS_H +#include <freetype/ftmoderr.h> #undef FTERRORS_H_ @@ -34,7 +34,7 @@ #define FT_ERR_PREFIX Raster_Err_ #define FT_ERR_BASE FT_Mod_Err_Raster -#include FT_ERRORS_H +#include <freetype/fterrors.h> #endif /* RASTERRS_H_ */ diff --git a/src/3rdparty/freetype/src/raster/rastpic.c b/src/3rdparty/freetype/src/raster/rastpic.c deleted file mode 100644 index 1dc8981b8a..0000000000 --- a/src/3rdparty/freetype/src/raster/rastpic.c +++ /dev/null @@ -1,89 +0,0 @@ -/***************************************************************************/ -/* */ -/* rastpic.c */ -/* */ -/* The FreeType position independent code services for raster module. */ -/* */ -/* Copyright 2009-2018 by */ -/* Oran Agra and Mickey Gabel. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#include <ft2build.h> -#include FT_FREETYPE_H -#include FT_INTERNAL_OBJECTS_H -#include "rastpic.h" -#include "rasterrs.h" - - -#ifdef FT_CONFIG_OPTION_PIC - - /* forward declaration of PIC init functions from ftraster.c */ - void - FT_Init_Class_ft_standard_raster( FT_Raster_Funcs* funcs ); - - - void - ft_raster1_renderer_class_pic_free( FT_Library library ) - { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Memory memory = library->memory; - - - if ( pic_container->raster ) - { - RasterPIC* container = (RasterPIC*)pic_container->raster; - - - if ( --container->ref_count ) - return; - FT_FREE( container ); - pic_container->raster = NULL; - } - } - - - FT_Error - ft_raster1_renderer_class_pic_init( FT_Library library ) - { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Error error = FT_Err_Ok; - RasterPIC* container = NULL; - FT_Memory memory = library->memory; - - - /* XXX: since this function also served the no longer available */ - /* raster5 renderer it uses reference counting, which could */ - /* be removed now */ - if ( pic_container->raster ) - { - ((RasterPIC*)pic_container->raster)->ref_count++; - return error; - } - - /* allocate pointer, clear and set global container pointer */ - if ( FT_ALLOC( container, sizeof ( *container ) ) ) - return error; - FT_MEM_SET( container, 0, sizeof ( *container ) ); - pic_container->raster = container; - - container->ref_count = 1; - - /* initialize pointer table - */ - /* this is how the module usually expects this data */ - FT_Init_Class_ft_standard_raster( &container->ft_standard_raster ); - - return error; - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - -/* END */ diff --git a/src/3rdparty/freetype/src/raster/rastpic.h b/src/3rdparty/freetype/src/raster/rastpic.h deleted file mode 100644 index 6d0877c423..0000000000 --- a/src/3rdparty/freetype/src/raster/rastpic.h +++ /dev/null @@ -1,63 +0,0 @@ -/***************************************************************************/ -/* */ -/* rastpic.h */ -/* */ -/* The FreeType position independent code services for raster module. */ -/* */ -/* Copyright 2009-2018 by */ -/* Oran Agra and Mickey Gabel. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef RASTPIC_H_ -#define RASTPIC_H_ - - -#include FT_INTERNAL_PIC_H - - -FT_BEGIN_HEADER - -#ifndef FT_CONFIG_OPTION_PIC - -#define FT_STANDARD_RASTER_GET ft_standard_raster - -#else /* FT_CONFIG_OPTION_PIC */ - - typedef struct RasterPIC_ - { - int ref_count; - FT_Raster_Funcs ft_standard_raster; - - } RasterPIC; - - -#define GET_PIC( lib ) \ - ( (RasterPIC*)( (lib)->pic_container.raster ) ) -#define FT_STANDARD_RASTER_GET ( GET_PIC( library )->ft_standard_raster ) - - - /* see rastpic.c for the implementation */ - void - ft_raster1_renderer_class_pic_free( FT_Library library ); - - FT_Error - ft_raster1_renderer_class_pic_init( FT_Library library ); - -#endif /* FT_CONFIG_OPTION_PIC */ - - /* */ - -FT_END_HEADER - -#endif /* RASTPIC_H_ */ - - -/* END */ diff --git a/src/3rdparty/freetype/src/raster/rules.mk b/src/3rdparty/freetype/src/raster/rules.mk index 7664671e80..031b85fb9e 100644 --- a/src/3rdparty/freetype/src/raster/rules.mk +++ b/src/3rdparty/freetype/src/raster/rules.mk @@ -3,7 +3,7 @@ # -# Copyright (C) 1996-2019 by +# Copyright (C) 1996-2023 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, |