mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 18:42:56 +00:00
[WIN32K]
Apply proper formatting to polyfill.c svn path=/trunk/; revision=66645
This commit is contained in:
parent
fe4dc5d9d5
commit
42587dd1d3
1 changed files with 389 additions and 378 deletions
|
@ -77,18 +77,21 @@ FASTCALL
|
||||||
POLYGONFILL_DestroyEdgeList(FILL_EDGE_LIST* list)
|
POLYGONFILL_DestroyEdgeList(FILL_EDGE_LIST* list)
|
||||||
{
|
{
|
||||||
int i;
|
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] )
|
if (list->Edges[i])
|
||||||
EngFreeMem ( 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;
|
FILL_EDGE *pPrev, *pThis;
|
||||||
//DPRINT1("In POLYGONFILL_ActiveListInsert()\n");
|
//DPRINT1("In POLYGONFILL_ActiveListInsert()\n");
|
||||||
ASSERT ( activehead && NewEdge );
|
ASSERT(activehead && NewEdge);
|
||||||
if ( !*activehead )
|
|
||||||
|
if (!*activehead)
|
||||||
{
|
{
|
||||||
NewEdge->pNext = NULL;
|
NewEdge->pNext = NULL;
|
||||||
*activehead = NewEdge;
|
*activehead = NewEdge;
|
||||||
|
@ -204,6 +208,7 @@ POLYGONFILL_ActiveListInsert(FILL_EDGE** activehead, FILL_EDGE* NewEdge )
|
||||||
*activehead = NewEdge;
|
*activehead = NewEdge;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Ok, now scan to the next spot to put this item.
|
** 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_LIST* list = 0;
|
||||||
FILL_EDGE* e = 0;
|
FILL_EDGE* e = 0;
|
||||||
|
|
||||||
if ( 0 == Points || 2 > Count )
|
if (0 == Points || 2 > Count)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
list = (FILL_EDGE_LIST*)EngAllocMem(FL_ZERO_MEMORY, sizeof(FILL_EDGE_LIST), FILL_EDGE_ALLOC_TAG);
|
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 )
|
if ( !list->Edges )
|
||||||
goto fail;
|
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] );
|
e = POLYGONFILL_MakeEdge ( Points[CurPt-1], Points[CurPt] );
|
||||||
if ( !e )
|
if (!e)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
// If a straight horizontal line - who cares?
|
// If a straight horizontal line - who cares?
|
||||||
if ( !e->absdy )
|
if (!e->absdy)
|
||||||
EngFreeMem ( e );
|
EngFreeMem(e);
|
||||||
else
|
else
|
||||||
list->Edges[list->Count++] = e;
|
list->Edges[list->Count++] = e;
|
||||||
}
|
}
|
||||||
|
@ -262,8 +267,8 @@ POLYGONFILL_MakeEdgeList(PPOINT Points, int Count)
|
||||||
if ( !e )
|
if ( !e )
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if ( !e->absdy )
|
if (!e->absdy)
|
||||||
EngFreeMem ( e );
|
EngFreeMem(e);
|
||||||
else
|
else
|
||||||
list->Edges[list->Count++] = e;
|
list->Edges[list->Count++] = e;
|
||||||
return list;
|
return list;
|
||||||
|
@ -287,20 +292,20 @@ void
|
||||||
FASTCALL
|
FASTCALL
|
||||||
POLYGONFILL_UpdateScanline(FILL_EDGE* pEdge, int Scanline)
|
POLYGONFILL_UpdateScanline(FILL_EDGE* pEdge, int Scanline)
|
||||||
{
|
{
|
||||||
if ( 0 == pEdge->dy )
|
if (0 == pEdge->dy)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ASSERT ( pEdge->FromY <= Scanline && pEdge->ToY > Scanline );
|
ASSERT(pEdge->FromY <= Scanline && pEdge->ToY > Scanline);
|
||||||
|
|
||||||
if ( pEdge->xmajor )
|
if (pEdge->xmajor)
|
||||||
{
|
{
|
||||||
int steps;
|
int steps;
|
||||||
|
|
||||||
ASSERT ( pEdge->y == Scanline );
|
ASSERT(pEdge->y == Scanline);
|
||||||
|
|
||||||
// Now shoot to end of scanline collision
|
// Now shoot to end of scanline collision
|
||||||
steps = (pEdge->ErrorMax-pEdge->Error-1)/pEdge->absdy;
|
steps = (pEdge->ErrorMax-pEdge->Error-1)/pEdge->absdy;
|
||||||
if ( steps )
|
if (steps)
|
||||||
{
|
{
|
||||||
// Record first collision with scanline
|
// Record first collision with scanline
|
||||||
int x1 = pEdge->x;
|
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...
|
// 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->x += pEdge->XDirection;
|
||||||
pEdge->Error += pEdge->absdy;
|
pEdge->Error += pEdge->absdy;
|
||||||
ASSERT ( pEdge->Error >= pEdge->ErrorMax );
|
ASSERT(pEdge->Error >= pEdge->ErrorMax);
|
||||||
|
|
||||||
// Now step onto next scanline...
|
// Now step onto next scanline...
|
||||||
pEdge->Error -= pEdge->absdx;
|
pEdge->Error -= pEdge->absdx;
|
||||||
|
@ -334,7 +339,7 @@ POLYGONFILL_UpdateScanline(FILL_EDGE* pEdge, int Scanline)
|
||||||
pEdge->Error += pEdge->absdx;
|
pEdge->Error += pEdge->absdx;
|
||||||
pEdge->y++;
|
pEdge->y++;
|
||||||
|
|
||||||
if ( pEdge->Error >= pEdge->ErrorMax )
|
if (pEdge->Error >= pEdge->ErrorMax)
|
||||||
{
|
{
|
||||||
pEdge->Error -= pEdge->ErrorMax;
|
pEdge->Error -= pEdge->ErrorMax;
|
||||||
pEdge->x += pEdge->XDirection;
|
pEdge->x += pEdge->XDirection;
|
||||||
|
@ -352,20 +357,23 @@ POLYGONFILL_UpdateScanline(FILL_EDGE* pEdge, int Scanline)
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
APIENTRY
|
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;
|
int i;
|
||||||
|
|
||||||
ASSERT ( list && ActiveHead );
|
ASSERT(list && ActiveHead);
|
||||||
*ActiveHead = 0;
|
*ActiveHead = 0;
|
||||||
for ( i = 0; i < list->Count; i++ )
|
for (i = 0; i < list->Count; i++)
|
||||||
{
|
{
|
||||||
FILL_EDGE* pEdge = list->Edges[i];
|
FILL_EDGE* pEdge = list->Edges[i];
|
||||||
ASSERT(pEdge);
|
ASSERT(pEdge);
|
||||||
if ( pEdge->FromY <= Scanline && pEdge->ToY > Scanline )
|
if (pEdge->FromY <= Scanline && pEdge->ToY > Scanline)
|
||||||
{
|
{
|
||||||
POLYGONFILL_UpdateScanline ( pEdge, Scanline );
|
POLYGONFILL_UpdateScanline(pEdge, Scanline);
|
||||||
POLYGONFILL_ActiveListInsert ( ActiveHead, pEdge );
|
POLYGONFILL_ActiveListInsert(ActiveHead, pEdge);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -387,18 +395,18 @@ POLYGONFILL_FillScanLineAlternate(
|
||||||
{
|
{
|
||||||
FILL_EDGE *pLeft, *pRight;
|
FILL_EDGE *pLeft, *pRight;
|
||||||
|
|
||||||
if ( !ActiveHead )
|
if (!ActiveHead)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pLeft = ActiveHead;
|
pLeft = ActiveHead;
|
||||||
pRight = pLeft->pNext;
|
pRight = pLeft->pNext;
|
||||||
ASSERT(pRight);
|
ASSERT(pRight);
|
||||||
|
|
||||||
while ( NULL != pRight )
|
while (NULL != pRight)
|
||||||
{
|
{
|
||||||
int x1 = pLeft->XIntercept[0];
|
int x1 = pLeft->XIntercept[0];
|
||||||
int x2 = pRight->XIntercept[1];
|
int x2 = pRight->XIntercept[1];
|
||||||
if ( x2 > x1 )
|
if (x2 > x1)
|
||||||
{
|
{
|
||||||
RECTL BoundRect;
|
RECTL BoundRect;
|
||||||
BoundRect.top = ScanLine;
|
BoundRect.top = ScanLine;
|
||||||
|
@ -437,7 +445,7 @@ POLYGONFILL_FillScanLineWinding(
|
||||||
int x1, x2, winding = 0;
|
int x1, x2, winding = 0;
|
||||||
RECTL BoundRect;
|
RECTL BoundRect;
|
||||||
|
|
||||||
if ( !ActiveHead )
|
if (!ActiveHead)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BoundRect.top = ScanLine;
|
BoundRect.top = ScanLine;
|
||||||
|
@ -463,11 +471,10 @@ POLYGONFILL_FillScanLineWinding(
|
||||||
if ( winding )
|
if ( winding )
|
||||||
{
|
{
|
||||||
// Check and see if this new line touches the previous...
|
// Check and see if this new line touches the previous...
|
||||||
if ( (newx1 >= x1 && newx1 <= x2)
|
if ((newx1 >= x1 && newx1 <= x2) ||
|
||||||
|| (newx2 >= x1 && newx2 <= x2)
|
(newx2 >= x1 && newx2 <= x2) ||
|
||||||
|| (x1 >= newx1 && x1 <= newx2)
|
(x1 >= newx1 && x1 <= newx2) ||
|
||||||
|| (x2 >= newx2 && x2 <= newx2)
|
(x2 >= newx2 && x2 <= newx2))
|
||||||
)
|
|
||||||
{
|
{
|
||||||
// Yup, just tack it on to our existing line
|
// Yup, just tack it on to our existing line
|
||||||
x1 = min(x1,newx1);
|
x1 = min(x1,newx1);
|
||||||
|
@ -494,10 +501,12 @@ POLYGONFILL_FillScanLineWinding(
|
||||||
x2 = newx2;
|
x2 = newx2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pLeft = pRight;
|
pLeft = pRight;
|
||||||
pRight = pLeft->pNext;
|
pRight = pLeft->pNext;
|
||||||
winding += pLeft->YDirection;
|
winding += pLeft->YDirection;
|
||||||
}
|
}
|
||||||
|
|
||||||
// There will always be a line left-over, render it now...
|
// There will always be a line left-over, render it now...
|
||||||
BoundRect.left = x1;
|
BoundRect.left = x1;
|
||||||
BoundRect.right = x2;
|
BoundRect.right = x2;
|
||||||
|
@ -545,7 +554,7 @@ FillPolygon(
|
||||||
FILL_EDGE* ActiveHead,
|
FILL_EDGE* ActiveHead,
|
||||||
SURFACE *psurf,
|
SURFACE *psurf,
|
||||||
BRUSHOBJ *BrushObj,
|
BRUSHOBJ *BrushObj,
|
||||||
MIX RopMode );
|
MIX RopMode);
|
||||||
|
|
||||||
//DPRINT("FillPolygon\n");
|
//DPRINT("FillPolygon\n");
|
||||||
|
|
||||||
|
@ -555,7 +564,7 @@ FillPolygon(
|
||||||
if (NULL == list)
|
if (NULL == list)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if ( WINDING == pdcattr->jFillMode )
|
if (WINDING == pdcattr->jFillMode)
|
||||||
FillScanLine = POLYGONFILL_FillScanLineWinding;
|
FillScanLine = POLYGONFILL_FillScanLineWinding;
|
||||||
else /* Default */
|
else /* Default */
|
||||||
FillScanLine = POLYGONFILL_FillScanLineAlternate;
|
FillScanLine = POLYGONFILL_FillScanLineAlternate;
|
||||||
|
@ -563,11 +572,11 @@ FillPolygon(
|
||||||
/* For each Scanline from BoundRect.bottom to BoundRect.top,
|
/* For each Scanline from BoundRect.bottom to BoundRect.top,
|
||||||
* determine line segments to draw
|
* 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);
|
POLYGONFILL_BuildActiveList(ScanLine, list, &ActiveHead);
|
||||||
//DEBUG_PRINT_ACTIVE_EDGELIST(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. */
|
/* Free Edge List. If any are left. */
|
||||||
|
@ -600,23 +609,24 @@ IntFillPolygon(
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* For each Scanline from DestRect.top to DestRect.bottom, determine line segments to draw */
|
/* 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);
|
POLYGONFILL_BuildActiveList(ScanLine, list, &ActiveHead);
|
||||||
//DEBUG_PRINT_ACTIVE_EDGELIST(ActiveHead);
|
//DEBUG_PRINT_ACTIVE_EDGELIST(ActiveHead);
|
||||||
|
|
||||||
if ( !ActiveHead )
|
if (!ActiveHead)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
pLeft = ActiveHead;
|
pLeft = ActiveHead;
|
||||||
pRight = pLeft->pNext;
|
pRight = pLeft->pNext;
|
||||||
ASSERT(pRight);
|
ASSERT(pRight);
|
||||||
|
|
||||||
while ( NULL != pRight )
|
while (NULL != pRight)
|
||||||
{
|
{
|
||||||
int x1 = pLeft->XIntercept[0];
|
int x1 = pLeft->XIntercept[0];
|
||||||
int x2 = pRight->XIntercept[1];
|
int x2 = pRight->XIntercept[1];
|
||||||
if ( x2 > x1 )
|
|
||||||
|
if (x2 > x1)
|
||||||
{
|
{
|
||||||
RECTL LineRect;
|
RECTL LineRect;
|
||||||
LineRect.top = ScanLine;
|
LineRect.top = ScanLine;
|
||||||
|
@ -636,6 +646,7 @@ IntFillPolygon(
|
||||||
BrushOrigin,
|
BrushOrigin,
|
||||||
ROP4_FROM_INDEX(R3_OPINDEX_PATCOPY));
|
ROP4_FROM_INDEX(R3_OPINDEX_PATCOPY));
|
||||||
}
|
}
|
||||||
|
|
||||||
pLeft = pRight->pNext;
|
pLeft = pRight->pNext;
|
||||||
pRight = pLeft ? pLeft->pNext : NULL;
|
pRight = pLeft ? pLeft->pNext : NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue