diff --git a/src/servers/app/server/AccelerantDriver.cpp b/src/servers/app/server/AccelerantDriver.cpp index fb1c447886..f4bf1520e1 100644 --- a/src/servers/app/server/AccelerantDriver.cpp +++ b/src/servers/app/server/AccelerantDriver.cpp @@ -112,6 +112,8 @@ void AccLineCalc::Swap(AccLineCalc &from) float AccLineCalc::GetX(float y) { + if (start.x == end.x) + return start.x; return ( (y-offset)/slope ); } @@ -845,7 +847,7 @@ void AccelerantDriver::FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, Lay all pairs of intersections. Watch out for horizontal line segments. */ _Lock(); - if ( !ptlist || (numpts < 3) || (sizeof(ptlist) < numpts*sizeof(BPoint)) ) + if ( !ptlist || (numpts < 3) ) { _Unlock(); return; @@ -853,7 +855,7 @@ void AccelerantDriver::FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, Lay PatternHandler pattern(pat); pattern.SetColors(d->highcolor, d->lowcolor); - BPoint *currentPoint, *nextPoint; + BPoint *currentPoint, *nextPoint; BPoint tempNextPoint; BPoint tempCurrentPoint; int currentIndex, bestIndex, i, j, y; @@ -861,26 +863,30 @@ void AccelerantDriver::FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, Lay int numSegments = 0; /* Generate the segment list */ - currentPoint = ptlist; + currentPoint = ptlist; currentIndex = 0; nextPoint = &ptlist[1]; - while (currentPoint) + while (currentPoint) { + if ( numSegments >= 2*numpts ) + { + printf("ERROR: Insufficient memory allocated to segment array\n"); + delete[] segmentArray; + return; + } + for (i=0; i currentPoint->y) && (ptlist[i].y < nextPoint->y)) || ((ptlist[i].y < currentPoint->y) && (ptlist[i].y > nextPoint->y)) ) { - tempNextPoint.x = ptlist[i].x; + segmentArray[numSegments].SetPoints(*currentPoint,*nextPoint); + tempNextPoint.x = segmentArray[numSegments].GetX(ptlist[i].y); tempNextPoint.y = ptlist[i].y; nextPoint = &tempNextPoint; } } - if ( numSegments >= 2*numpts ) - { - printf("ERROR: Insufficient memory allocated to segment array\n"); - return; - } + segmentArray[numSegments].SetPoints(*currentPoint,*nextPoint); numSegments++; if ( nextPoint == &tempNextPoint ) @@ -907,9 +913,9 @@ void AccelerantDriver::FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, Lay bestIndex = i; for (j=i+1; jhighcolor, d->lowcolor); - // Sort points according to their y values - if(pts[0].y < pts[1].y) + // Sort points according to their y values and x values (y is primary) + if ( (pts[0].y < pts[1].y) || + ((pts[0].y == pts[1].y) && (pts[0].x <= pts[1].x)) ) { first=pts[0]; second=pts[1]; @@ -1103,7 +1110,8 @@ void AccelerantDriver::FillTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pa second=pts[0]; } - if(second.y