summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/freetype/src/raster/ftraster.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/freetype/src/raster/ftraster.c')
-rw-r--r--src/3rdparty/freetype/src/raster/ftraster.c498
1 files changed, 232 insertions, 266 deletions
diff --git a/src/3rdparty/freetype/src/raster/ftraster.c b/src/3rdparty/freetype/src/raster/ftraster.c
index 023b6c1eff..192ca0701a 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;
@@ -1763,9 +1742,9 @@
* SUCCESS on success, FAILURE on error.
*/
static Bool
- Decompose_Curve( RAS_ARGS UShort first,
- UShort last,
- Int flipped )
+ Decompose_Curve( RAS_ARGS Int first,
+ Int last,
+ Int flipped )
{
FT_Vector v_last;
FT_Vector v_control;
@@ -1963,7 +1942,7 @@
return SUCCESS;
Invalid_Outline:
- ras.error = FT_THROW( Invalid );
+ ras.error = FT_THROW( Invalid_Outline );
Fail:
return FAILURE;
@@ -1990,8 +1969,8 @@
static Bool
Convert_Glyph( RAS_ARGS Int flipped )
{
- Int i;
- UInt start;
+ Int i;
+ Int first, last;
ras.fProfile = NULL;
@@ -2006,8 +1985,7 @@
ras.cProfile->offset = ras.top;
ras.num_Profs = 0;
- start = 0;
-
+ last = -1;
for ( i = 0; i < ras.outline.n_contours; i++ )
{
PProfile lastProfile;
@@ -2017,12 +1995,11 @@
ras.state = Unknown_State;
ras.gProfile = NULL;
- if ( Decompose_Curve( RAS_VARS (UShort)start,
- (UShort)ras.outline.contours[i],
- flipped ) )
- return FAILURE;
+ first = last + 1;
+ last = ras.outline.contours[i];
- start = (UShort)ras.outline.contours[i] + 1;
+ if ( Decompose_Curve( RAS_VARS first, last, flipped ) )
+ return FAILURE;
/* we must now check whether the extreme arcs join or not */
if ( FRAC( ras.lastY ) == 0 &&
@@ -2116,8 +2093,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 +2187,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 +2204,7 @@
PProfile left,
PProfile right )
{
- Long e1, e2;
- Byte* target;
+ Long e1, e2;
Int dropOutControl = left->flags & 7;
@@ -2242,11 +2215,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 +2237,8 @@
if ( e2 >= 0 && e1 < ras.bWidth )
{
+ Byte* target;
+
Int c1, c2;
Byte f1, f2;
@@ -2274,7 +2248,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 +2256,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 +2267,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 +2290,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 +2327,6 @@
Int dropOutControl = left->flags & 7;
- FT_TRACE7(( ", drop-out=%d", dropOutControl ));
-
if ( e1 == e2 + ras.precision )
{
switch ( dropOutControl )
@@ -2364,7 +2336,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 +2385,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 +2408,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 +2420,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 +2450,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 +2467,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;
+
- 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,10 +2544,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 +2570,6 @@
Int dropOutControl = left->flags & 7;
- FT_TRACE7(( ", dropout=%d", dropOutControl ));
-
if ( e1 == e2 + ras.precision )
{
switch ( dropOutControl )
@@ -2585,7 +2579,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 +2603,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 +2639,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 +2648,7 @@
}
Exit:
- FT_TRACE7(( "\n" ));
+ FT_TRACE7(( " dropout=%d\n", left->flags & 7 ));
}
@@ -2721,13 +2715,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 +2948,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 +3010,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 +3094,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 +3102,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 +3122,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 +3148,6 @@
*araster = (FT_Raster)&the_raster;
FT_ZERO( &the_raster );
- ft_black_init( &the_raster );
return 0;
}
@@ -3197,30 +3165,30 @@
static int
- ft_black_new( FT_Memory memory,
- black_PRaster *araster )
+ ft_black_new( void* memory_, /* FT_Memory */
+ FT_Raster *araster_ ) /* black_PRaster */
{
+ FT_Memory memory = (FT_Memory)memory_;
+ black_PRaster *araster = (black_PRaster*)araster_;
+
FT_Error error;
black_PRaster raster = NULL;
- *araster = 0;
if ( !FT_NEW( raster ) )
- {
raster->memory = memory;
- ft_black_init( raster );
- *araster = raster;
- }
+ *araster = raster;
return error;
}
static void
- ft_black_done( black_PRaster raster )
+ ft_black_done( FT_Raster raster_ ) /* black_PRaster */
{
- FT_Memory memory = (FT_Memory)raster->memory;
+ black_PRaster raster = (black_PRaster)raster_;
+ FT_Memory memory = (FT_Memory)raster->memory;
FT_FREE( raster );
@@ -3269,38 +3237,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;
@@ -3317,11 +3283,11 @@
FT_GLYPH_FORMAT_OUTLINE,
- (FT_Raster_New_Func) ft_black_new, /* raster_new */
- (FT_Raster_Reset_Func) ft_black_reset, /* raster_reset */
- (FT_Raster_Set_Mode_Func)ft_black_set_mode, /* raster_set_mode */
- (FT_Raster_Render_Func) ft_black_render, /* raster_render */
- (FT_Raster_Done_Func) ft_black_done /* raster_done */
+ ft_black_new, /* FT_Raster_New_Func raster_new */
+ ft_black_reset, /* FT_Raster_Reset_Func raster_reset */
+ ft_black_set_mode, /* FT_Raster_Set_Mode_Func raster_set_mode */
+ ft_black_render, /* FT_Raster_Render_Func raster_render */
+ ft_black_done /* FT_Raster_Done_Func raster_done */
)