[raster] Consolidate profile increment to the next line.

* src/raster/ftraster.c (s/Sort/Increment): Rename this function to
reflect its true purpose, delete exhausted profiles here...
(Draw_Sweep): ... instead of here.
This commit is contained in:
Alexei Podtelezhnikov 2023-11-03 23:10:41 -04:00
parent 046c4fc7be
commit 32081d8123
1 changed files with 22 additions and 47 deletions

View File

@ -2019,26 +2019,32 @@
/************************************************************************** /**************************************************************************
* *
* Sort * Increment
* *
* Sorts a trace list. In 95%, the list is already sorted. We need * Advances all profile in the list to the next scanline. It also
* an algorithm which is fast in this case. Bubble sort is enough * sorts the trace list in the unlikely case of profile crossing.
* and simple. * In 95%, the list is already sorted. We need an algorithm which
* is fast in this case. Bubble sort is enough and simple.
*/ */
static void static void
Sort( PProfileList list ) Increment( PProfileList list )
{ {
PProfile *old, current, next; PProfile *old, current, next;
/* First, set the new X coordinate of each profile */ /* First, set the new X coordinates and remove exhausted profiles */
current = *list; old = list;
while ( current ) while ( *old )
{ {
current->X = current->x[current->offset]; current = *old;
current->offset += ( current->flags & Flow_Up ) ? 1 : -1; if ( --current->height )
current->height--; {
current = current->link; current->offset += ( current->flags & Flow_Up ) ? 1 : -1;
current->X = current->x[current->offset];
old = &current->link;
}
else
*old = current->link; /* remove */
} }
/* Then sort them */ /* Then sort them */
@ -2610,15 +2616,10 @@
Q = &P->link; Q = &P->link;
} }
/* sort the drawing lists */
Sort( &draw_left );
Sort( &draw_right );
y_change = (Int)*ras.maxBuff; y_change = (Int)*ras.maxBuff;
y_height = y_change - y; y_height = y_change - y;
while ( y < y_change ) do
{ {
/* let's trace */ /* let's trace */
@ -2674,36 +2675,10 @@
ras.Proc_Sweep_Step( RAS_VAR ); ras.Proc_Sweep_Step( RAS_VAR );
y++; Increment( &draw_left );
Increment( &draw_right );
if ( y < y_change )
{
Sort( &draw_left );
Sort( &draw_right );
}
}
/* remove exhausted profiles */
Q = &draw_left;
while ( *Q )
{
P = *Q;
if ( P->height == 0 )
*Q = P->link;
else
Q = &P->link;
}
Q = &draw_right;
while ( *Q )
{
P = *Q;
if ( P->height == 0 )
*Q = P->link;
else
Q = &P->link;
} }
while ( ++y < y_change );
} }
return SUCCESS; return SUCCESS;