Apply proper formatting to polyfill.c

svn path=/trunk/; revision=66645
This commit is contained in:
Timo Kreuzer 2015-03-10 00:11:43 +00:00
parent fe4dc5d9d5
commit 42587dd1d3

View file

@ -77,18 +77,21 @@ FASTCALL
POLYGONFILL_DestroyEdgeList(FILL_EDGE_LIST* list)
{
int i;
if ( list )
if (list)
{
if ( list->Edges )
if (list->Edges)
{
for ( i = 0; i < list->Count; i++ )
for (i = 0; i < list->Count; i++)
{
if ( list->Edges[i] )
EngFreeMem ( list->Edges[i] );
if (list->Edges[i])
EngFreeMem(list->Edges[i]);
}
EngFreeMem ( list->Edges );
EngFreeMem(list->Edges);
}
EngFreeMem ( list );
EngFreeMem(list);
}
}
@ -188,8 +191,9 @@ POLYGONFILL_ActiveListInsert(FILL_EDGE** activehead, FILL_EDGE* NewEdge )
{
FILL_EDGE *pPrev, *pThis;
//DPRINT1("In POLYGONFILL_ActiveListInsert()\n");
ASSERT ( activehead && NewEdge );
if ( !*activehead )
ASSERT(activehead && NewEdge);
if (!*activehead)
{
NewEdge->pNext = NULL;
*activehead = NewEdge;
@ -204,6 +208,7 @@ POLYGONFILL_ActiveListInsert(FILL_EDGE** activehead, FILL_EDGE* NewEdge )
*activehead = NewEdge;
return;
}
/*
** Ok, now scan to the next spot to put this item.
*/
@ -233,7 +238,7 @@ POLYGONFILL_MakeEdgeList(PPOINT Points, int Count)
FILL_EDGE_LIST* list = 0;
FILL_EDGE* e = 0;
if ( 0 == Points || 2 > Count )
if (0 == Points || 2 > Count)
return 0;
list = (FILL_EDGE_LIST*)EngAllocMem(FL_ZERO_MEMORY, sizeof(FILL_EDGE_LIST), FILL_EDGE_ALLOC_TAG);
@ -244,17 +249,17 @@ POLYGONFILL_MakeEdgeList(PPOINT Points, int Count)
if ( !list->Edges )
goto fail;
memset ( list->Edges, 0, Count * sizeof(FILL_EDGE*) );
memset(list->Edges, 0, Count * sizeof(FILL_EDGE*));
for ( CurPt = 1; CurPt < Count; ++CurPt )
for (CurPt = 1; CurPt < Count; ++CurPt)
{
e = POLYGONFILL_MakeEdge ( Points[CurPt-1], Points[CurPt] );
if ( !e )
if (!e)
goto fail;
// If a straight horizontal line - who cares?
if ( !e->absdy )
EngFreeMem ( e );
if (!e->absdy)
EngFreeMem(e);
else
list->Edges[list->Count++] = e;
}
@ -262,8 +267,8 @@ POLYGONFILL_MakeEdgeList(PPOINT Points, int Count)
if ( !e )
goto fail;
if ( !e->absdy )
EngFreeMem ( e );
if (!e->absdy)
EngFreeMem(e);
else
list->Edges[list->Count++] = e;
return list;
@ -287,20 +292,20 @@ void
FASTCALL
POLYGONFILL_UpdateScanline(FILL_EDGE* pEdge, int Scanline)
{
if ( 0 == pEdge->dy )
if (0 == pEdge->dy)
return;
ASSERT ( pEdge->FromY <= Scanline && pEdge->ToY > Scanline );
ASSERT(pEdge->FromY <= Scanline && pEdge->ToY > Scanline);
if ( pEdge->xmajor )
if (pEdge->xmajor)
{
int steps;
ASSERT ( pEdge->y == Scanline );
ASSERT(pEdge->y == Scanline);
// Now shoot to end of scanline collision
steps = (pEdge->ErrorMax-pEdge->Error-1)/pEdge->absdy;
if ( steps )
if (steps)
{
// Record first collision with scanline
int x1 = pEdge->x;
@ -317,10 +322,10 @@ POLYGONFILL_UpdateScanline(FILL_EDGE* pEdge, int Scanline)
}
// We should require exactly 1 step to step onto next scanline...
ASSERT ( (pEdge->ErrorMax-pEdge->Error-1) / pEdge->absdy == 0 );
ASSERT((pEdge->ErrorMax-pEdge->Error-1) / pEdge->absdy == 0);
pEdge->x += pEdge->XDirection;
pEdge->Error += pEdge->absdy;
ASSERT ( pEdge->Error >= pEdge->ErrorMax );
ASSERT(pEdge->Error >= pEdge->ErrorMax);
// Now step onto next scanline...
pEdge->Error -= pEdge->absdx;
@ -334,7 +339,7 @@ POLYGONFILL_UpdateScanline(FILL_EDGE* pEdge, int Scanline)
pEdge->Error += pEdge->absdx;
pEdge->y++;
if ( pEdge->Error >= pEdge->ErrorMax )
if (pEdge->Error >= pEdge->ErrorMax)
{
pEdge->Error -= pEdge->ErrorMax;
pEdge->x += pEdge->XDirection;
@ -352,20 +357,23 @@ POLYGONFILL_UpdateScanline(FILL_EDGE* pEdge, int Scanline)
static
void
APIENTRY
POLYGONFILL_BuildActiveList ( int Scanline, FILL_EDGE_LIST* list, FILL_EDGE** ActiveHead )
POLYGONFILL_BuildActiveList(
int Scanline,
FILL_EDGE_LIST* list,
FILL_EDGE** ActiveHead)
{
int i;
ASSERT ( list && ActiveHead );
ASSERT(list && ActiveHead);
*ActiveHead = 0;
for ( i = 0; i < list->Count; i++ )
for (i = 0; i < list->Count; i++)
{
FILL_EDGE* pEdge = list->Edges[i];
ASSERT(pEdge);
if ( pEdge->FromY <= Scanline && pEdge->ToY > Scanline )
if (pEdge->FromY <= Scanline && pEdge->ToY > Scanline)
{
POLYGONFILL_UpdateScanline ( pEdge, Scanline );
POLYGONFILL_ActiveListInsert ( ActiveHead, pEdge );
POLYGONFILL_UpdateScanline(pEdge, Scanline);
POLYGONFILL_ActiveListInsert(ActiveHead, pEdge);
}
}
}
@ -387,18 +395,18 @@ POLYGONFILL_FillScanLineAlternate(
{
FILL_EDGE *pLeft, *pRight;
if ( !ActiveHead )
if (!ActiveHead)
return;
pLeft = ActiveHead;
pRight = pLeft->pNext;
ASSERT(pRight);
while ( NULL != pRight )
while (NULL != pRight)
{
int x1 = pLeft->XIntercept[0];
int x2 = pRight->XIntercept[1];
if ( x2 > x1 )
if (x2 > x1)
{
RECTL BoundRect;
BoundRect.top = ScanLine;
@ -437,7 +445,7 @@ POLYGONFILL_FillScanLineWinding(
int x1, x2, winding = 0;
RECTL BoundRect;
if ( !ActiveHead )
if (!ActiveHead)
return;
BoundRect.top = ScanLine;
@ -463,11 +471,10 @@ POLYGONFILL_FillScanLineWinding(
if ( winding )
{
// Check and see if this new line touches the previous...
if ( (newx1 >= x1 && newx1 <= x2)
|| (newx2 >= x1 && newx2 <= x2)
|| (x1 >= newx1 && x1 <= newx2)
|| (x2 >= newx2 && x2 <= newx2)
)
if ((newx1 >= x1 && newx1 <= x2) ||
(newx2 >= x1 && newx2 <= x2) ||
(x1 >= newx1 && x1 <= newx2) ||
(x2 >= newx2 && x2 <= newx2))
{
// Yup, just tack it on to our existing line
x1 = min(x1,newx1);
@ -494,10 +501,12 @@ POLYGONFILL_FillScanLineWinding(
x2 = newx2;
}
}
pLeft = pRight;
pRight = pLeft->pNext;
winding += pLeft->YDirection;
}
// There will always be a line left-over, render it now...
BoundRect.left = x1;
BoundRect.right = x2;
@ -545,7 +554,7 @@ FillPolygon(
FILL_EDGE* ActiveHead,
SURFACE *psurf,
BRUSHOBJ *BrushObj,
MIX RopMode );
MIX RopMode);
//DPRINT("FillPolygon\n");
@ -555,7 +564,7 @@ FillPolygon(
if (NULL == list)
return FALSE;
if ( WINDING == pdcattr->jFillMode )
if (WINDING == pdcattr->jFillMode)
FillScanLine = POLYGONFILL_FillScanLineWinding;
else /* Default */
FillScanLine = POLYGONFILL_FillScanLineAlternate;
@ -563,11 +572,11 @@ FillPolygon(
/* For each Scanline from BoundRect.bottom to BoundRect.top,
* determine line segments to draw
*/
for ( ScanLine = BoundRect.top; ScanLine < BoundRect.bottom; ++ScanLine )
for (ScanLine = BoundRect.top; ScanLine < BoundRect.bottom; ++ScanLine)
{
POLYGONFILL_BuildActiveList(ScanLine, list, &ActiveHead);
//DEBUG_PRINT_ACTIVE_EDGELIST(ActiveHead);
FillScanLine ( dc, ScanLine, ActiveHead, psurf, BrushObj, RopMode );
FillScanLine(dc, ScanLine, ActiveHead, psurf, BrushObj, RopMode);
}
/* Free Edge List. If any are left. */
@ -600,23 +609,24 @@ IntFillPolygon(
return FALSE;
/* For each Scanline from DestRect.top to DestRect.bottom, determine line segments to draw */
for ( ScanLine = DestRect.top; ScanLine < DestRect.bottom; ++ScanLine )
for (ScanLine = DestRect.top; ScanLine < DestRect.bottom; ++ScanLine)
{
POLYGONFILL_BuildActiveList(ScanLine, list, &ActiveHead);
//DEBUG_PRINT_ACTIVE_EDGELIST(ActiveHead);
if ( !ActiveHead )
if (!ActiveHead)
return FALSE;
pLeft = ActiveHead;
pRight = pLeft->pNext;
ASSERT(pRight);
while ( NULL != pRight )
while (NULL != pRight)
{
int x1 = pLeft->XIntercept[0];
int x2 = pRight->XIntercept[1];
if ( x2 > x1 )
if (x2 > x1)
{
RECTL LineRect;
LineRect.top = ScanLine;
@ -636,6 +646,7 @@ IntFillPolygon(
BrushOrigin,
ROP4_FROM_INDEX(R3_OPINDEX_PATCOPY));
}
pLeft = pRight->pNext;
pRight = pLeft ? pLeft->pNext : NULL;
}