[raster] Use bitwise dropout mode interpretation.

* src/raster/ftraster.c (Vertical_Sweep_Drop, Horizontal_Sweep_Drop,
Draw_Sweep, Render_GLyph): Interpret dropout mode using bit masks.
This commit is contained in:
Alexei Podtelezhnikov 2023-11-20 22:46:36 -05:00
parent e969289f88
commit d7c72ff919
1 changed files with 38 additions and 74 deletions

View File

@ -2082,15 +2082,11 @@
/* pixel contour contour pixel */ /* pixel contour contour pixel */
/* center center */ /* center center */
/* drop-out mode scan conversion rules (as defined in OpenType) */ /* drop-out mode scan conversion rules (OpenType specs) */
/* --------------------------------------------------------------- */ /* ------------------------------------------------------- */
/* 0 1, 2, 3 */ /* bit 0 exclude stubs if set */
/* 1 1, 2, 4 */ /* bit 1 ignore drop-outs if set */
/* 2 1, 2 */ /* bit 2 smart rounding if set */
/* 3 same as mode 2 */
/* 4 1, 2, 5 */
/* 5 1, 2, 6 */
/* 6, 7 same as mode 2 */
e1 = CEILING( x1 ); e1 = CEILING( x1 );
e2 = FLOOR ( x2 ); e2 = FLOOR ( x2 );
@ -2103,19 +2099,6 @@
if ( e1 == e2 + ras.precision ) if ( e1 == e2 + ras.precision )
{ {
switch ( dropOutControl )
{
case 0: /* simple drop-outs including stubs */
pxl = e2;
break;
case 4: /* smart drop-outs including stubs */
pxl = SMART( x1, x2 );
break;
case 1: /* simple drop-outs excluding stubs */
case 5: /* smart drop-outs excluding stubs */
/* Drop-out Control Rules #4 and #6 */ /* Drop-out Control Rules #4 and #6 */
/* The specification neither provides an exact definition */ /* The specification neither provides an exact definition */
@ -2142,30 +2125,28 @@
/* - the covered interval is greater or equal to a half */ /* - the covered interval is greater or equal to a half */
/* pixel */ /* pixel */
/* upper stub test */ if ( dropOutControl & 1 )
{
/* rightmost stub test */
if ( left->next == right && if ( left->next == right &&
left->height == 1 && left->height == 1 &&
!( left->flags & Overshoot_Top && !( left->flags & Overshoot_Top &&
x2 - x1 >= ras.precision_half ) ) x2 - x1 >= ras.precision_half ) )
goto Exit; goto Exit;
/* lower stub test */ /* leftmost stub test */
if ( right->next == left && if ( right->next == left &&
left->offset == 0 && left->offset == 0 &&
!( left->flags & Overshoot_Bottom && !( left->flags & Overshoot_Bottom &&
x2 - x1 >= ras.precision_half ) ) x2 - x1 >= ras.precision_half ) )
goto Exit; goto Exit;
if ( dropOutControl == 1 )
pxl = e2;
else
pxl = SMART( x1, x2 );
break;
default: /* modes 2, 3, 6, 7 */
goto Exit; /* no drop-out control */
} }
if ( dropOutControl & 4 )
pxl = SMART( x1, x2 );
else
pxl = e2;
/* undocumented but confirmed: If the drop-out would result in a */ /* undocumented but confirmed: If the drop-out would result in a */
/* pixel outside of the bounding box, use the pixel inside of the */ /* pixel outside of the bounding box, use the pixel inside of the */
/* bounding box instead */ /* bounding box instead */
@ -2346,20 +2327,8 @@
if ( e1 == e2 + ras.precision ) if ( e1 == e2 + ras.precision )
{ {
switch ( dropOutControl ) if ( dropOutControl & 1 )
{ {
case 0: /* simple drop-outs including stubs */
pxl = e2;
break;
case 4: /* smart drop-outs including stubs */
pxl = SMART( x1, x2 );
break;
case 1: /* simple drop-outs excluding stubs */
case 5: /* smart drop-outs excluding stubs */
/* see Vertical_Sweep_Drop for details */
/* rightmost stub test */ /* rightmost stub test */
if ( left->next == right && if ( left->next == right &&
left->height == 1 && left->height == 1 &&
@ -2373,17 +2342,13 @@
!( left->flags & Overshoot_Bottom && !( left->flags & Overshoot_Bottom &&
x2 - x1 >= ras.precision_half ) ) x2 - x1 >= ras.precision_half ) )
goto Exit; goto Exit;
if ( dropOutControl == 1 )
pxl = e2;
else
pxl = SMART( x1, x2 );
break;
default: /* modes 2, 3, 6, 7 */
goto Exit; /* no drop-out control */
} }
if ( dropOutControl & 4 )
pxl = SMART( x1, x2 );
else
pxl = e2;
/* undocumented but confirmed: If the drop-out would result in a */ /* undocumented but confirmed: If the drop-out would result in a */
/* pixel outside of the bounding box, use the pixel inside of the */ /* pixel outside of the bounding box, use the pixel inside of the */
/* bounding box instead */ /* bounding box instead */
@ -2518,19 +2483,20 @@
Int dropOutControl = P_Left->flags & 7; Int dropOutControl = P_Left->flags & 7;
if ( dropOutControl != 2 ) if ( dropOutControl & 2 )
{ goto Next_Pair;
P_Left ->X = x1;
P_Right->X = x2;
/* mark profile for drop-out processing */ P_Left ->X = x1;
P_Left->flags |= Dropout; P_Right->X = x2;
dropouts++;
} /* mark profile for drop-out processing */
P_Left->flags |= Dropout;
dropouts++;
} }
else else
ras.Proc_Sweep_Span( RAS_VARS y, x1, x2, P_Left, P_Right ); ras.Proc_Sweep_Span( RAS_VARS y, x1, x2, P_Left, P_Right );
Next_Pair:
P_Left = P_Left->link; P_Left = P_Left->link;
P_Right = P_Right->link; P_Right = P_Right->link;
} }
@ -2769,18 +2735,16 @@
Set_High_Precision( RAS_VARS ras.outline.flags & Set_High_Precision( RAS_VARS ras.outline.flags &
FT_OUTLINE_HIGH_PRECISION ); FT_OUTLINE_HIGH_PRECISION );
if ( ras.outline.flags & FT_OUTLINE_IGNORE_DROPOUTS ) ras.dropOutControl = 0;
ras.dropOutControl = 2;
else
{
if ( ras.outline.flags & FT_OUTLINE_SMART_DROPOUTS )
ras.dropOutControl = 4;
else
ras.dropOutControl = 0;
if ( !( ras.outline.flags & FT_OUTLINE_INCLUDE_STUBS ) ) if ( ras.outline.flags & FT_OUTLINE_IGNORE_DROPOUTS )
ras.dropOutControl += 1; ras.dropOutControl |= 2;
}
if ( ras.outline.flags & FT_OUTLINE_SMART_DROPOUTS )
ras.dropOutControl |= 4;
if ( !( ras.outline.flags & FT_OUTLINE_INCLUDE_STUBS ) )
ras.dropOutControl |= 1;
FT_TRACE6(( "BW Raster: precision 1/%d, dropout mode %d\n", FT_TRACE6(( "BW Raster: precision 1/%d, dropout mode %d\n",
ras.precision, ras.dropOutControl )); ras.precision, ras.dropOutControl ));