[raster] Improve profile accounting.

* src/raster/ftraster.c (End_Profile): Do not initiate next profile.
(New_Profile): Fully initiate new profile.
(Convert_Glyph): Clean up variables, initialize `fProfile` here.
This commit is contained in:
Alexei Podtelezhnikov 2023-10-13 15:22:32 +00:00
parent f09c5e58c2
commit 153c038e3c
1 changed files with 8 additions and 19 deletions

View File

@ -618,9 +618,8 @@
New_Profile( RAS_ARGS TStates aState, New_Profile( RAS_ARGS TStates aState,
Bool overshoot ) Bool overshoot )
{ {
if ( !ras.fProfile ) if ( !ras.cProfile || ras.cProfile->height )
{ {
ras.fProfile = (PProfile)ras.top;
ras.cProfile = (PProfile)ras.top; ras.cProfile = (PProfile)ras.top;
ras.top += AlignProfileSize; ras.top += AlignProfileSize;
@ -717,20 +716,8 @@
ras.cProfile->flags |= Overshoot_Bottom; ras.cProfile->flags |= Overshoot_Bottom;
} }
/* premature, the last profile in the controur must loop */
ras.cProfile->next = (PProfile)ras.top; ras.cProfile->next = (PProfile)ras.top;
ras.cProfile = (PProfile)ras.top;
ras.top += AlignProfileSize;
if ( ras.top >= ras.maxBuff )
{
FT_TRACE1(( "overflow in End_Profile\n" ));
ras.error = FT_THROW( Raster_Overflow );
return FAILURE;
}
ras.cProfile->offset = ras.top;
ras.cProfile->height = 0;
ras.num_Profs++; ras.num_Profs++;
} }
@ -1971,6 +1958,7 @@
ras.fProfile = NULL; ras.fProfile = NULL;
ras.cProfile = NULL;
ras.joint = FALSE; ras.joint = FALSE;
ras.fresh = FALSE; ras.fresh = FALSE;
@ -1983,7 +1971,6 @@
last = -1; last = -1;
for ( i = 0; i < ras.outline.n_contours; i++ ) for ( i = 0; i < ras.outline.n_contours; i++ )
{ {
PProfile lastProfile;
Bool o; Bool o;
@ -2009,7 +1996,6 @@
( ras.cProfile->flags & Flow_Up ) ) ( ras.cProfile->flags & Flow_Up ) )
ras.top--; ras.top--;
lastProfile = ras.cProfile;
if ( ras.top != ras.cProfile->offset && if ( ras.top != ras.cProfile->offset &&
( ras.cProfile->flags & Flow_Up ) ) ( ras.cProfile->flags & Flow_Up ) )
o = IS_TOP_OVERSHOOT( ras.lastY ); o = IS_TOP_OVERSHOOT( ras.lastY );
@ -2018,8 +2004,11 @@
if ( End_Profile( RAS_VARS o ) ) if ( End_Profile( RAS_VARS o ) )
return FAILURE; return FAILURE;
/* close the `next profile in contour' linked list */ /* loop the last profile in the contour */
lastProfile->next = ras.gProfile; ras.cProfile->next = ras.gProfile;
if ( !ras.fProfile )
ras.fProfile = ras.gProfile;
} }
if ( Finalize_Profile_Table( RAS_VAR ) ) if ( Finalize_Profile_Table( RAS_VAR ) )