diff --git a/src/servers/app/DisplayDriver.cpp b/src/servers/app/DisplayDriver.cpp index 2b62ba42c0..4578fb77b8 100644 --- a/src/servers/app/DisplayDriver.cpp +++ b/src/servers/app/DisplayDriver.cpp @@ -36,7 +36,7 @@ #include "ServerCursor.h" #include "CursorData.h" -// TODO: Remove remnants of old API. Inplement all functions. Bounds checking needs to be +// TODO: Implement all functions. Bounds checking needs to be // handled by the public drawing functions. // Add clipping and make sure public functions have Lock & Unlock. @@ -53,10 +53,6 @@ DisplayDriver::DisplayDriver(void) : { _locker=new BLocker(); fCursorHandler.SetCursor(new ServerCursor(default_cursor_data)); -// _is_cursor_hidden=false; -// _is_cursor_obscured=false; -// _cursor=NULL; -// _cursorsave=NULL; fDPMSCaps=B_DPMS_ON; fDPMSState=B_DPMS_ON; } @@ -284,35 +280,6 @@ DisplayDriver::DrawBitmap(BRegion *region, ServerBitmap *bitmap, Invalidate(destrect); } -/*! - \brief Called for all BView::DrawBitmap calls - \param bmp Bitmap to be drawn. It will always be non-NULL and valid. The color - space is not guaranteed to match. - \param src Source rectangle - \param dest Destination rectangle. Source will be scaled to fit if not the same size. - \param d Data structure containing any other data necessary for the call. Always non-NULL. -*/ - -//void DisplayDriver::DrawBitmap(ServerBitmap *bmp, const BRect &src, const BRect &dest, const DrawData *d) -//{ -/* Lock(); - - FBBitmap frameBuffer; - //FBBitmap *fbmp = &frameBuffer; - - if(!AcquireBuffer(&frameBuffer)) - { - debugger("ERROR: Couldn't acquire framebuffer in DrawBitmap()\n"); - return; - } - - ReleaseBuffer(); - Unlock(); - - Invalidate(dest); -*/ -//} - void DisplayDriver::CopyRegionList(BList* list, BList* pList, int32 rCount, BRegion* clipReg) { Lock(); @@ -447,372 +414,6 @@ void DisplayDriver::CopyRegionList(BList* list, BList* pList, int32 rCount, BReg // ConstrainClippingRegion(NULL); } - -/*! - \brief Called for all BView::FillArc calls - \param r Rectangle enclosing the entire arc - \param angle Starting angle for the arc in degrees - \param span Span of the arc in degrees. Ending angle = angle+span. - \param color The color of the arc -*/ -/*void DisplayDriver::FillArc(const BRect &r, const float &angle, const float &span, const RGBColor &color) -{ - if(fCursorHandler.IntersectsCursor(r)) - fCursorHandler.DriverHide(); - - float xc = (r.left+r.right)/2; - float yc = (r.top+r.bottom)/2; - float rx = r.Width()/2; - float ry = r.Height()/2; - int Rx2 = ROUND(rx*rx); - int Ry2 = ROUND(ry*ry); - int twoRx2 = 2*Rx2; - int twoRy2 = 2*Ry2; - int p; - int x=0; - int y = (int)ry; - int px = 0; - int py = twoRx2 * y; - int startx, endx; - int starty, endy; - int xclip, startclip, endclip; - int startQuad, endQuad; - bool useQuad1, useQuad2, useQuad3, useQuad4; - bool shortspan = false; - - // Watch out for bozos giving us whacko spans - if ( (span >= 360) || (span <= -360) ) - { - FillEllipse(r,color); - fCursorHandler.DriverShow(); - return; - } - - Lock(); - - if ( span > 0 ) - { - startQuad = (int)(angle/90)%4+1; - endQuad = (int)((angle+span)/90)%4+1; - startx = ROUND(.5*r.Width()*fabs(cos(angle*M_PI/180))); - endx = ROUND(.5*r.Width()*fabs(cos((angle+span)*M_PI/180))); - } - else - { - endQuad = (int)(angle/90)%4+1; - startQuad = (int)((angle+span)/90)%4+1; - endx = ROUND(.5*r.Width()*fabs(cos(angle*M_PI/180))); - startx = ROUND(.5*r.Width()*fabs(cos((angle+span)*M_PI/180))); - } - - starty = ROUND(ry*sqrt(1-(double)startx*startx/(rx*rx))); - endy = ROUND(ry*sqrt(1-(double)endx*endx/(rx*rx))); - - if ( startQuad != endQuad ) - { - useQuad1 = (endQuad > 1) && (startQuad > endQuad); - useQuad2 = ((startQuad == 1) && (endQuad > 2)) || ((startQuad > endQuad) && (endQuad > 2)); - useQuad3 = ((startQuad < 3) && (endQuad == 4)) || ((startQuad < 3) && (endQuad < startQuad)); - useQuad4 = (startQuad < 4) && (startQuad > endQuad); - } - else - { - if ( (span < 90) && (span > -90) ) - { - useQuad1 = false; - useQuad2 = false; - useQuad3 = false; - useQuad4 = false; - shortspan = true; - } - else - { - useQuad1 = (startQuad != 1); - useQuad2 = (startQuad != 2); - useQuad3 = (startQuad != 3); - useQuad4 = (startQuad != 4); - } - } - - if ( useQuad1 ) - StrokeSolidLine(ROUND(xc),ROUND(yc-y),ROUND(xc+x),ROUND(yc-y),color); - if ( useQuad2 ) - StrokeSolidLine(ROUND(xc),ROUND(yc-y),ROUND(xc-x),ROUND(yc-y),color); - if ( useQuad3 ) - StrokeSolidLine(ROUND(xc),ROUND(yc+y),ROUND(xc-x),ROUND(yc+y),color); - if ( useQuad4 ) - StrokeSolidLine(ROUND(xc),ROUND(yc+y),ROUND(xc+x),ROUND(yc+y),color); - - p = ROUND (Ry2 - (Rx2 * ry) + (.25 * Rx2)); - while (px < py) - { - x++; - px += twoRy2; - if ( p < 0 ) - p += Ry2 + px; - else - { - y--; - py -= twoRx2; - p += Ry2 + px - py; - } - - if ( useQuad1 ) - StrokeSolidLine(ROUND(xc),ROUND(yc-y),ROUND(xc+x),ROUND(yc-y),color); - if ( useQuad2 ) - StrokeSolidLine(ROUND(xc),ROUND(yc-y),ROUND(xc-x),ROUND(yc-y),color); - if ( useQuad3 ) - StrokeSolidLine(ROUND(xc),ROUND(yc+y),ROUND(xc-x),ROUND(yc+y),color); - if ( useQuad4 ) - StrokeSolidLine(ROUND(xc),ROUND(yc+y),ROUND(xc+x),ROUND(yc+y),color); - if ( !shortspan ) - { - if ( startQuad == 1 ) - { - if ( x <= startx ) - StrokeSolidLine(ROUND(xc),ROUND(yc-y),ROUND(xc+x),ROUND(yc-y),color); - else - { - xclip = ROUND(y*startx/(double)starty); - StrokeSolidLine(ROUND(xc),ROUND(yc-y),ROUND(xc+xclip),ROUND(yc-y),color); - } - } - else if ( startQuad == 2 ) - { - if ( x >= startx ) - { - xclip = ROUND(y*startx/(double)starty); - StrokeSolidLine(ROUND(xc-x),ROUND(yc-y),ROUND(xc-xclip),ROUND(yc-y),color); - } - } - else if ( startQuad == 3 ) - { - if ( x <= startx ) - StrokeSolidLine(ROUND(xc-x),ROUND(yc+y),ROUND(xc),ROUND(yc+y),color); - else - { - xclip = ROUND(y*startx/(double)starty); - StrokeSolidLine(ROUND(xc-xclip),ROUND(yc+y),ROUND(xc),ROUND(yc+y),color); - } - } - else if ( startQuad == 4 ) - { - if ( x >= startx ) - { - xclip = ROUND(y*startx/(double)starty); - StrokeSolidLine(ROUND(xc+xclip),ROUND(yc+y),ROUND(xc+x),ROUND(yc+y),color); - } - } - - if ( endQuad == 1 ) - { - if ( x >= endx ) - { - xclip = ROUND(y*endx/(double)endy); - StrokeSolidLine(ROUND(xc+xclip),ROUND(yc-y),ROUND(xc+x),ROUND(yc-y),color); - } - } - else if ( endQuad == 2 ) - { - if ( x <= endx ) - StrokeSolidLine(ROUND(xc-x),ROUND(yc-y),ROUND(xc),ROUND(yc-y),color); - else - { - xclip = ROUND(y*endx/(double)endy); - StrokeSolidLine(ROUND(xc-xclip),ROUND(yc-y),ROUND(xc),ROUND(yc-y),color); - } - } - else if ( endQuad == 3 ) - { - if ( x >= endx ) - { - xclip = ROUND(y*endx/(double)endy); - StrokeSolidLine(ROUND(xc-x),ROUND(yc+y),ROUND(xc-xclip),ROUND(yc+y),color); - } - } - else if ( endQuad == 4 ) - { - if ( x <= endx ) - StrokeSolidLine(ROUND(xc),ROUND(yc+y),ROUND(xc+x),ROUND(yc+y),color); - else - { - xclip = ROUND(y*endx/(double)endy); - StrokeSolidLine(ROUND(xc),ROUND(yc+y),ROUND(xc+xclip),ROUND(yc+y),color); - } - } - } - else - { - startclip = ROUND(y*startx/(double)starty); - endclip = ROUND(y*endx/(double)endy); - if ( startQuad == 1 ) - { - if ( (x <= startx) && (x >= endx) ) - StrokeSolidLine(ROUND(xc+endclip),ROUND(yc-y),ROUND(xc+x),ROUND(yc-y),color); - else - StrokeSolidLine(ROUND(xc+endclip),ROUND(yc-y),ROUND(xc+startclip),ROUND(yc-y),color); - } - else if ( startQuad == 2 ) - { - if ( (x <= startx) && (x >= endx) ) - StrokeSolidLine(ROUND(xc-x),ROUND(yc-y),ROUND(xc-startclip),ROUND(yc-y),color); - else - StrokeSolidLine(ROUND(xc-endclip),ROUND(yc-y),ROUND(xc-startclip),ROUND(yc-y),color); - } - else if ( startQuad == 3 ) - { - if ( (x <= startx) && (x >= endx) ) - StrokeSolidLine(ROUND(xc-x),ROUND(yc+y),ROUND(xc-endclip),ROUND(yc+y),color); - else - StrokeSolidLine(ROUND(xc-startclip),ROUND(yc+y),ROUND(xc-endclip),ROUND(yc+y),color); - } - else if ( startQuad == 4 ) - { - if ( (x <= startx) && (x >= endx) ) - StrokeSolidLine(ROUND(xc+startclip),ROUND(yc+y),ROUND(xc+x),ROUND(yc+y),color); - else - StrokeSolidLine(ROUND(xc+startclip),ROUND(yc+y),ROUND(xc+endclip),ROUND(yc+y),color); - } - } - } - - p = ROUND(Ry2*(x+.5)*(x+.5) + Rx2*(y-1)*(y-1) - Rx2*Ry2); - while (y>0) - { - y--; - py -= twoRx2; - if (p>0) - p += Rx2 - py; - else - { - x++; - px += twoRy2; - p += Rx2 - py +px; - } - - if ( useQuad1 ) - StrokeSolidLine(ROUND(xc),ROUND(yc-y),ROUND(xc+x),ROUND(yc-y),color); - if ( useQuad2 ) - StrokeSolidLine(ROUND(xc),ROUND(yc-y),ROUND(xc-x),ROUND(yc-y),color); - if ( useQuad3 ) - StrokeSolidLine(ROUND(xc),ROUND(yc+y),ROUND(xc-x),ROUND(yc+y),color); - if ( useQuad4 ) - StrokeSolidLine(ROUND(xc),ROUND(yc+y),ROUND(xc+x),ROUND(yc+y),color); - if ( !shortspan ) - { - if ( startQuad == 1 ) - { - if ( x <= startx ) - StrokeSolidLine(ROUND(xc),ROUND(yc-y),ROUND(xc+x),ROUND(yc-y),color); - else - { - xclip = ROUND(y*startx/(double)starty); - StrokeSolidLine(ROUND(xc),ROUND(yc-y),ROUND(xc+xclip),ROUND(yc-y),color); - } - } - else if ( startQuad == 2 ) - { - if ( x >= startx ) - { - xclip = ROUND(y*startx/(double)starty); - StrokeSolidLine(ROUND(xc-x),ROUND(yc-y),ROUND(xc-xclip),ROUND(yc-y),color); - } - } - else if ( startQuad == 3 ) - { - if ( x <= startx ) - StrokeSolidLine(ROUND(xc-x),ROUND(yc+y),ROUND(xc),ROUND(yc+y),color); - else - { - xclip = ROUND(y*startx/(double)starty); - StrokeSolidLine(ROUND(xc-xclip),ROUND(yc+y),ROUND(xc),ROUND(yc+y),color); - } - } - else if ( startQuad == 4 ) - { - if ( x >= startx ) - { - xclip = ROUND(y*startx/(double)starty); - StrokeSolidLine(ROUND(xc+xclip),ROUND(yc+y),ROUND(xc+x),ROUND(yc+y),color); - } - } - - if ( endQuad == 1 ) - { - if ( x >= endx ) - { - xclip = ROUND(y*endx/(double)endy); - StrokeSolidLine(ROUND(xc+xclip),ROUND(yc-y),ROUND(xc+x),ROUND(yc-y),color); - } - } - else if ( endQuad == 2 ) - { - if ( x <= endx ) - StrokeSolidLine(ROUND(xc-x),ROUND(yc-y),ROUND(xc),ROUND(yc-y),color); - else - { - xclip = ROUND(y*endx/(double)endy); - StrokeSolidLine(ROUND(xc-xclip),ROUND(yc-y),ROUND(xc),ROUND(yc-y),color); - } - } - else if ( endQuad == 3 ) - { - if ( x >= endx ) - { - xclip = ROUND(y*endx/(double)endy); - StrokeSolidLine(ROUND(xc-x),ROUND(yc+y),ROUND(xc-xclip),ROUND(yc+y),color); - } - } - else if ( endQuad == 4 ) - { - if ( x <= endx ) - StrokeSolidLine(ROUND(xc),ROUND(yc+y),ROUND(xc+x),ROUND(yc+y),color); - else - { - xclip = ROUND(y*endx/(double)endy); - StrokeSolidLine(ROUND(xc),ROUND(yc+y),ROUND(xc+xclip),ROUND(yc+y),color); - } - } - } - else - { - startclip = ROUND(y*startx/(double)starty); - endclip = ROUND(y*endx/(double)endy); - if ( startQuad == 1 ) - { - if ( (x <= startx) && (x >= endx) ) - StrokeSolidLine(ROUND(xc+endclip),ROUND(yc-y),ROUND(xc+x),ROUND(yc-y),color); - else - StrokeSolidLine(ROUND(xc+endclip),ROUND(yc-y),ROUND(xc+startclip),ROUND(yc-y),color); - } - else if ( startQuad == 2 ) - { - if ( (x <= startx) && (x >= endx) ) - StrokeSolidLine(ROUND(xc-x),ROUND(yc-y),ROUND(xc-startclip),ROUND(yc-y),color); - else - StrokeSolidLine(ROUND(xc-endclip),ROUND(yc-y),ROUND(xc-startclip),ROUND(yc-y),color); - } - else if ( startQuad == 3 ) - { - if ( (x <= startx) && (x >= endx) ) - StrokeSolidLine(ROUND(xc-x),ROUND(yc+y),ROUND(xc-endclip),ROUND(yc+y),color); - else - StrokeSolidLine(ROUND(xc-startclip),ROUND(yc+y),ROUND(xc-endclip),ROUND(yc+y),color); - } - else if ( startQuad == 4 ) - { - if ( (x <= startx) && (x >= endx) ) - StrokeSolidLine(ROUND(xc+startclip),ROUND(yc+y),ROUND(xc+x),ROUND(yc+y),color); - else - StrokeSolidLine(ROUND(xc+startclip),ROUND(yc+y),ROUND(xc+endclip),ROUND(yc+y),color); - } - } - } - fCursorHandler.DriverShow(); - Invalidate(r); - Unlock(); -}*/ - /*! \brief Called for all BView::FillArc calls \param r Rectangle enclosing the entire arc @@ -1181,22 +782,7 @@ void DisplayDriver::FillArc(const BRect &r, const float &angle, const float &spa Invalidate(r); Unlock(); } -/* -void DisplayDriver::FillBezier(BPoint *pts, const RGBColor &color) -{ - Lock(); - BezierCurve curve(pts); - - if(fCursorHandler.IntersectsCursor(curve.Frame())) - fCursorHandler.DriverHide(); - - FillPolygon(curve.GetPointArray(), curve.points.CountItems(), curve.Frame(), color); - - fCursorHandler.DriverShow(); - Unlock(); -} -*/ /*! \brief Called for all BView::FillBezier calls. \param pts 4-element array of BPoints in the order of start, end, and then the two control @@ -1217,76 +803,7 @@ void DisplayDriver::FillBezier(BPoint *pts, const DrawData *d) fCursorHandler.DriverShow(); Unlock(); } -/*! - \brief Called for all BView::FillEllipse calls - \param r BRect enclosing the ellipse to be drawn. - \param color The color of the ellipse -*/ -/* -void DisplayDriver::FillEllipse(const BRect &r, const RGBColor &color) -{ - float xc = (r.left+r.right)/2; - float yc = (r.top+r.bottom)/2; - float rx = r.Width()/2; - float ry = r.Height()/2; - int Rx2 = ROUND(rx*rx); - int Ry2 = ROUND(ry*ry); - int twoRx2 = 2*Rx2; - int twoRy2 = 2*Ry2; - int p; - int x=0; - int y = (int)ry; - int px = 0; - int py = twoRx2 * y; - Lock(); - - if(fCursorHandler.IntersectsCursor(r)) - fCursorHandler.DriverHide(); - - StrokeSolidLine(ROUND(xc),ROUND(yc-y),ROUND(xc),ROUND(yc-y),color); - StrokeSolidLine(ROUND(xc),ROUND(yc+y),ROUND(xc),ROUND(yc+y),color); - - p = ROUND (Ry2 - (Rx2 * ry) + (.25 * Rx2)); - while (px < py) - { - x++; - px += twoRy2; - if ( p < 0 ) - p += Ry2 + px; - else - { - y--; - py -= twoRx2; - p += Ry2 + px - py; - } - - StrokeSolidLine(ROUND(xc-x),ROUND(yc-y),ROUND(xc+x),ROUND(yc-y),color); - StrokeSolidLine(ROUND(xc-x),ROUND(yc+y),ROUND(xc+x),ROUND(yc+y),color); - } - - p = ROUND(Ry2*(x+.5)*(x+.5) + Rx2*(y-1)*(y-1) - Rx2*Ry2); - while (y>0) - { - y--; - py -= twoRx2; - if (p>0) - p += Rx2 - py; - else - { - x++; - px += twoRy2; - p += Rx2 - py +px; - } - - StrokeSolidLine(ROUND(xc-x),ROUND(yc-y),ROUND(xc+x),ROUND(yc-y),color); - StrokeSolidLine(ROUND(xc-x),ROUND(yc+y),ROUND(xc+x),ROUND(yc+y),color); - } - fCursorHandler.DriverShow(); - Invalidate(r); - Unlock(); -} -*/ /*! \brief Called for all BView::FillEllipse calls \param r BRect enclosing the ellipse to be drawn. @@ -1360,153 +877,6 @@ void DisplayDriver::FillEllipse(const BRect &r, const DrawData *d) Unlock(); } -/*! - \brief Called for all BView::FillPolygon calls - \param ptlist Array of BPoints defining the polygon. - \param numpts Number of points in the BPoint array. - \param color The color of the polygon -*/ -/* -void DisplayDriver::FillPolygon(BPoint *ptlist, int32 numpts, const BRect &bounds, const RGBColor &color) -{ - // Here's the plan. Record all line segments in polygon. If a line segments crosses - // the y-value of a point not in the segment, split the segment into 2 segments. - // Once we have gone through all of the segments, sort them primarily on y-value - // and secondarily on x-value. Step through each y-value in the bounding rectangle - // and look for intersections with line segments. First intersection is start of - // horizontal line, second intersection is end of horizontal line. Continue for - // all pairs of intersections. Watch out for horizontal line segments. - - if ( !ptlist || (numpts < 3) ) - return; - - Lock(); - - if(fCursorHandler.IntersectsCursor(bounds)) - fCursorHandler.DriverHide(); - - BPoint *currentPoint, *nextPoint; - BPoint tempNextPoint; - BPoint tempCurrentPoint; - int currentIndex, bestIndex, i, j, y; - LineCalc *segmentArray = new LineCalc[2*numpts]; - int numSegments = 0; - int minX, minY, maxX, maxY; - - minX = ROUND(ptlist[0].x); - maxX = ROUND(ptlist[0].x); - minY = ROUND(ptlist[0].y); - maxY = ROUND(ptlist[0].y); - - // Generate the segment list - currentPoint = ptlist; - currentIndex = 0; - nextPoint = &ptlist[1]; - while (currentPoint) - { - if ( numSegments >= 2*numpts ) - { - printf("ERROR: Insufficient memory allocated to segment array\n"); - delete[] segmentArray; - Unlock(); - return; - } - - if ( ROUND(currentPoint->x) < minX ) - minX = ROUND(currentPoint->x); - if ( ROUND(currentPoint->x) > maxX ) - maxX = ROUND(currentPoint->x); - if ( ROUND(currentPoint->y) < minY ) - minY = ROUND(currentPoint->y); - if ( ROUND(currentPoint->y) > maxY ) - maxY = ROUND(currentPoint->y); - - for (i=0; i currentPoint->y) && (ptlist[i].y < nextPoint->y)) || - ((ptlist[i].y < currentPoint->y) && (ptlist[i].y > nextPoint->y)) ) - { - segmentArray[numSegments].SetPoints(*currentPoint,*nextPoint); - tempNextPoint.x = segmentArray[numSegments].GetX(ptlist[i].y); - tempNextPoint.y = ptlist[i].y; - nextPoint = &tempNextPoint; - } - } - - segmentArray[numSegments].SetPoints(*currentPoint,*nextPoint); - numSegments++; - if ( nextPoint == &tempNextPoint ) - { - tempCurrentPoint = tempNextPoint; - currentPoint = &tempCurrentPoint; - nextPoint = &ptlist[(currentIndex+1)%numpts]; - } - else if ( nextPoint == ptlist ) - { - currentPoint = NULL; - } - else - { - currentPoint = nextPoint; - currentIndex++; - nextPoint = &ptlist[(currentIndex+1)%numpts]; - } - } - - // Selection sort the segments. Probably should replace this later. - for (i=0; i y) - break; - if (segmentArray[i].MaxY() < y) - { - i++; - continue; - } - if (segmentArray[i].MinY() == segmentArray[i].MaxY()) - { - if ( (segmentArray[i].MinX() < fDisplayMode.virtual_width) && - (segmentArray[i].MaxX() >= 0) ) - StrokeSolidLine(ROUND(segmentArray[i].MinX()), y, - ROUND(segmentArray[i].MaxX()), y, color); - i++; - } - else - { - if ( (segmentArray[i+1].GetX(y) < fDisplayMode.virtual_width) && - (segmentArray[i].GetX(y) >= 0) ) - StrokeSolidLine(ROUND(segmentArray[i].GetX(y)), y, - ROUND(segmentArray[i+1].GetX(y)), y, color); - i+=2; - } - } - } - - delete[] segmentArray; - fCursorHandler.DriverShow(); - Invalidate(bounds); - Unlock(); - -}*/ - /*! \brief Called for all BView::FillPolygon calls \param ptlist Array of BPoints defining the polygon. @@ -1773,29 +1143,6 @@ void DisplayDriver::FillRect(const BRect &r, const DrawData *d) Unlock(); } -/*! - \brief Convenience function for server use - \param r BRegion to be filled - \param color The color used to fill the region -*/ -/*void DisplayDriver::FillRegion(BRegion& r, const RGBColor &color) -{ - Lock(); - - if(fCursorHandler.IntersectsCursor(r.Frame())) - fCursorHandler.DriverHide(); - - int numRects; - - numRects = r.CountRects(); - for(int32 i=0; i= 360) || (span <= -360) ) - { - StrokeEllipse(r,color); - fCursorHandler.DriverShow(); - Unlock(); - return; - } - - if ( span > 0 ) - { - startQuad = (int)(angle/90)%4+1; - endQuad = (int)((angle+span)/90)%4+1; - startx = ROUND(.5*r.Width()*fabs(cos(angle*M_PI/180))); - endx = ROUND(.5*r.Width()*fabs(cos((angle+span)*M_PI/180))); - } - else - { - endQuad = (int)(angle/90)%4+1; - startQuad = (int)((angle+span)/90)%4+1; - endx = ROUND(.5*r.Width()*fabs(cos(angle*M_PI/180))); - startx = ROUND(.5*r.Width()*fabs(cos((angle+span)*M_PI/180))); - } - - if ( startQuad != endQuad ) - { - useQuad1 = (endQuad > 1) && (startQuad > endQuad); - useQuad2 = ((startQuad == 1) && (endQuad > 2)) || ((startQuad > endQuad) && (endQuad > 2)); - useQuad3 = ((startQuad < 3) && (endQuad == 4)) || ((startQuad < 3) && (endQuad < startQuad)); - useQuad4 = (startQuad < 4) && (startQuad > endQuad); - } - else - { - if ( (span < 90) && (span > -90) ) - { - useQuad1 = false; - useQuad2 = false; - useQuad3 = false; - useQuad4 = false; - shortspan = true; - } - else - { - useQuad1 = (startQuad != 1); - useQuad2 = (startQuad != 2); - useQuad3 = (startQuad != 3); - useQuad4 = (startQuad != 4); - } - } - - if ( useQuad1 || - (!shortspan && (((startQuad == 1) && (x <= startx)) || ((endQuad == 1) && (x >= endx)))) || - (shortspan && (startQuad == 1) && (x <= startx) && (x >= endx)) ) - StrokePoint(BPoint(xc+x,yc-y),color); - if ( useQuad2 || - (!shortspan && (((startQuad == 2) && (x >= startx)) || ((endQuad == 2) && (x <= endx)))) || - (shortspan && (startQuad == 2) && (x >= startx) && (x <= endx)) ) - StrokePoint(BPoint(xc-x,yc-y),color); - if ( useQuad3 || - (!shortspan && (((startQuad == 3) && (x <= startx)) || ((endQuad == 3) && (x >= endx)))) || - (shortspan && (startQuad == 3) && (x <= startx) && (x >= endx)) ) - StrokePoint(BPoint(xc-x,yc+y),color); - if ( useQuad4 || - (!shortspan && (((startQuad == 4) && (x >= startx)) || ((endQuad == 4) && (x <= endx)))) || - (shortspan && (startQuad == 4) && (x >= startx) && (x <= endx)) ) - StrokePoint(BPoint(xc+x,yc+y),color); - - p = ROUND (Ry2 - (Rx2 * ry) + (.25 * Rx2)); - while (px < py) - { - x++; - px += twoRy2; - if ( p < 0 ) - p += Ry2 + px; - else - { - y--; - py -= twoRx2; - p += Ry2 + px - py; - } - - if ( useQuad1 || - (!shortspan && (((startQuad == 1) && (x <= startx)) || ((endQuad == 1) && (x >= endx)))) || - (shortspan && (startQuad == 1) && (x <= startx) && (x >= endx)) ) - StrokePoint(BPoint(xc+x,yc-y),color); - if ( useQuad2 || - (!shortspan && (((startQuad == 2) && (x >= startx)) || ((endQuad == 2) && (x <= endx)))) || - (shortspan && (startQuad == 2) && (x >= startx) && (x <= endx)) ) - StrokePoint(BPoint(xc-x,yc-y),color); - if ( useQuad3 || - (!shortspan && (((startQuad == 3) && (x <= startx)) || ((endQuad == 3) && (x >= endx)))) || - (shortspan && (startQuad == 3) && (x <= startx) && (x >= endx)) ) - StrokePoint(BPoint(xc-x,yc+y),color); - if ( useQuad4 || - (!shortspan && (((startQuad == 4) && (x >= startx)) || ((endQuad == 4) && (x <= endx)))) || - (shortspan && (startQuad == 4) && (x >= startx) && (x <= endx)) ) - StrokePoint(BPoint(xc+x,yc+y),color); - } - - p = ROUND(Ry2*(x+.5)*(x+.5) + Rx2*(y-1)*(y-1) - Rx2*Ry2); - while (y>0) - { - y--; - py -= twoRx2; - if (p>0) - p += Rx2 - py; - else - { - x++; - px += twoRy2; - p += Rx2 - py +px; - } - - if ( useQuad1 || - (!shortspan && (((startQuad == 1) && (x <= startx)) || ((endQuad == 1) && (x >= endx)))) || - (shortspan && (startQuad == 1) && (x <= startx) && (x >= endx)) ) - StrokePoint(BPoint(xc+x,yc-y),color); - if ( useQuad2 || - (!shortspan && (((startQuad == 2) && (x >= startx)) || ((endQuad == 2) && (x <= endx)))) || - (shortspan && (startQuad == 2) && (x >= startx) && (x <= endx)) ) - StrokePoint(BPoint(xc-x,yc-y),color); - if ( useQuad3 || - (!shortspan && (((startQuad == 3) && (x <= startx)) || ((endQuad == 3) && (x >= endx)))) || - (shortspan && (startQuad == 3) && (x <= startx) && (x >= endx)) ) - StrokePoint(BPoint(xc-x,yc+y),color); - if ( useQuad4 || - (!shortspan && (((startQuad == 4) && (x >= startx)) || ((endQuad == 4) && (x <= endx)))) || - (shortspan && (startQuad == 4) && (x >= startx) && (x <= endx)) ) - StrokePoint(BPoint(xc+x,yc+y),color); - } - fCursorHandler.DriverShow(); - Invalidate(r); - Unlock(); -}*/ - /*! \brief Called for all BView::StrokeArc calls \param r Rectangle enclosing the entire arc @@ -2497,30 +1547,6 @@ void DisplayDriver::StrokeArc(const BRect &r, const float &angle, const float &s Unlock(); } -/*! - \brief Called for all BView::StrokeBezier calls. - \param pts 4-element array of BPoints in the order of start, end, and then the two control points. - \param color draw color -*/ -/*void DisplayDriver::StrokeBezier(BPoint *pts, const RGBColor &color) -{ - int i, numLines; - - Lock(); - BezierCurve curve(pts); - - if(fCursorHandler.IntersectsCursor(curve.Frame())) - fCursorHandler.DriverHide(); - - numLines = curve.points.CountItems()-1; - for (i=0; i0) - { - lastx = x; - lasty = y; - y--; - py -= twoRx2; - if (p>0) - p += Rx2 - py; - else - { - x++; - px += twoRy2; - p += Rx2 - py +px; - } - - StrokeLine(BPoint(xc+lastx,yc-lasty),BPoint(xc+x,yc-y),color); - StrokeLine(BPoint(xc-lastx,yc-lasty),BPoint(xc-x,yc-y),color); - StrokeLine(BPoint(xc-lastx,yc+lasty),BPoint(xc-x,yc+y),color); - StrokeLine(BPoint(xc+lastx,yc+lasty),BPoint(xc+x,yc+y),color); - } - - fCursorHandler.DriverShow(); - Invalidate(r); - Unlock(); -}*/ - /*! \brief Called for all BView::StrokeEllipse calls \param r BRect enclosing the ellipse to be drawn. @@ -2827,44 +1777,6 @@ void DisplayDriver::StrokeLine(const BPoint &start, const BPoint &end, const Dra Unlock(); } -/*! - \brief Draws a line. Really. - \param start Starting point - \param end Ending point - \param setPixel Pixel drawing function which handles things like size and pattern. -*/ -/*void DisplayDriver::StrokeLine(const BPoint &start, const BPoint &end, DisplayDriver* driver, SetPixelFuncType setPixel) -{ - // TODO: What's this particular StrokeLine call for? - - int x1 = ROUND(start.x); - int y1 = ROUND(start.y); - int x2 = ROUND(end.x); - int y2 = ROUND(end.y); - int dx = x2 - x1; - int dy = y2 - y1; - int steps, k; - double xInc, yInc; - double x = x1; - double y = y1; - - if ( abs(dx) > abs(dy) ) - steps = abs(dx); - else - steps = abs(dy); - xInc = dx / (double) steps; - yInc = dy / (double) steps; - - (driver->*setPixel)(ROUND(x),ROUND(y)); - for (k=0; k*setPixel)(ROUND(x),ROUND(y)); - } - Invalidate(BRect(start,end)); -}*/ - void DisplayDriver::StrokePoint(const BPoint& pt, const RGBColor &color) { StrokeLine(pt, pt, color); @@ -2877,25 +1789,6 @@ void DisplayDriver::StrokePoint(const BPoint& pt, const DrawData *d) Invalidate(BRect(pt,pt)); } -/*void DisplayDriver::StrokePolygon(BPoint *ptlist, int32 numpts, const BRect &bounds, const RGBColor &color, bool is_closed) -{ - if(!ptlist) - return; - - Lock(); - if(fCursorHandler.IntersectsCursor(bounds)) - fCursorHandler.DriverHide(); - - for(int32 i=0; i<(numpts-1); i++) - StrokeLine(ptlist[i],ptlist[i+1],color); - if(is_closed) - StrokeLine(ptlist[numpts-1],ptlist[0],color); - - fCursorHandler.DriverShow(); - Invalidate(bounds); - Unlock(); -}*/ - /*! \brief Called for all BView::StrokePolygon calls \param ptlist Array of BPoints defining the polygon. @@ -2922,10 +1815,9 @@ void DisplayDriver::StrokePolygon(BPoint *ptlist, int32 numpts, const BRect &bou } /*! - \brief Called for all BView::StrokeRect calls + \brief Called by Decorator \param r BRect to be drawn - \param pensize Thickness of the lines - \param color The color of the rectangle + \param color Color in which to draw */ void DisplayDriver::StrokeRect(const BRect &r, const RGBColor &color) { @@ -2940,6 +1832,11 @@ void DisplayDriver::StrokeRect(const BRect &r, const RGBColor &color) Unlock(); } +/*! + \brief Called for all BView::StrokeRect calls + \param r BRect to be drawn + \param d DrawData containing all of the other options +*/ void DisplayDriver::StrokeRect(const BRect &r, const DrawData *d) { Lock(); @@ -2959,24 +1856,8 @@ void DisplayDriver::StrokeRect(const BRect &r, const DrawData *d) \brief Convenience function for server use \param r BRegion to be stroked \param d Data structure containing any other data necessary for the call. Always non-NULL. - \param pat 8-byte array containing the const Pattern &to use. Always non-NULL. */ -/*void DisplayDriver::StrokeRegion(BRegion& r, const RGBColor &color) -{ - Lock(); - - if(fCursorHandler.IntersectsCursor(r.Frame())) - fCursorHandler.DriverHide(); - - for(int32 i=0; i