[webkit-changes] cvs commit: WebCore/kwq KWQPainter.h KWQPainter.mm

Darin darin at opensource.apple.com
Sun Aug 14 19:57:27 PDT 2005


darin       05/08/14 19:57:27

  Modified:    .        ChangeLog
               kwq      KWQPainter.h KWQPainter.mm
  Log:
          Reviewed by Maciej.
  
          - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=4420
            make border drawing faster by removing code to alloc/dealloc NSBezierPath
  
          * kwq/KWQPainter.h: Remove unused drawLineSegments, drawPolyline, and drawPolygon.
          * kwq/KWQPainter.mm:
          (QPainter::drawConvexPolygon): Move the body of _drawPoints into here, and remove the
          various unused code paths. Use CoreGraphics calls instead of NSBezierPath.
  
  Revision  Changes    Path
  1.4572    +12 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.4571
  retrieving revision 1.4572
  diff -u -r1.4571 -r1.4572
  --- ChangeLog	15 Aug 2005 00:32:28 -0000	1.4571
  +++ ChangeLog	15 Aug 2005 02:57:23 -0000	1.4572
  @@ -1,3 +1,15 @@
  +2005-08-14  Darin Adler  <darin at apple.com>
  +
  +        Reviewed by Maciej.
  +
  +        - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=4420
  +          make border drawing faster by removing code to alloc/dealloc NSBezierPath
  +
  +        * kwq/KWQPainter.h: Remove unused drawLineSegments, drawPolyline, and drawPolygon.
  +        * kwq/KWQPainter.mm:
  +        (QPainter::drawConvexPolygon): Move the body of _drawPoints into here, and remove the
  +        various unused code paths. Use CoreGraphics calls instead of NSBezierPath.
  +
   2005-08-14  Maciej Stachowiak  <mjs at apple.com>
   
           Reviewed by Darin.
  
  
  
  1.77      +0 -5      WebCore/kwq/KWQPainter.h
  
  Index: KWQPainter.h
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQPainter.h,v
  retrieving revision 1.76
  retrieving revision 1.77
  diff -u -r1.76 -r1.77
  --- KWQPainter.h	1 Aug 2005 09:06:33 -0000	1.76
  +++ KWQPainter.h	15 Aug 2005 02:57:27 -0000	1.77
  @@ -75,11 +75,8 @@
       
       void drawRect(int, int, int, int);
       void drawLine(int, int, int, int);
  -    void drawLineSegments(const QPointArray &, int index=0, int nlines=-1);
       void drawEllipse(int, int, int, int);
       void drawArc(int, int, int, int, int, int);
  -    void drawPolyline(const QPointArray &, int index=0, int npoints=-1);
  -    void drawPolygon(const QPointArray &, bool winding=FALSE, int index=0, int npoints=-1);
       void drawConvexPolygon(const QPointArray &);
   
       void fillRect(int, int, int, int, const QBrush &);
  @@ -151,8 +148,6 @@
   
       void _fillRect(float x, float y, float w, float h, const QColor& color);
       
  -    void _drawPoints(const QPointArray &_points, bool winding, int index, int _npoints, bool fill);
  -
       void _updateRenderer();
   
       QPainterPrivate *data;
  
  
  
  1.131     +18 -47    WebCore/kwq/KWQPainter.mm
  
  Index: KWQPainter.mm
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQPainter.mm,v
  retrieving revision 1.130
  retrieving revision 1.131
  diff -u -r1.130 -r1.131
  --- KWQPainter.mm	1 Aug 2005 09:06:33 -0000	1.130
  +++ KWQPainter.mm	15 Aug 2005 02:57:27 -0000	1.131
  @@ -391,68 +391,40 @@
       }
   }
   
  -void QPainter::drawLineSegments(const QPointArray &points, int index, int nlines)
  +void QPainter::drawConvexPolygon(const QPointArray &points)
   {
       if (data->state.paintingDisabled)
           return;
  -    
  -    _drawPoints (points, 0, index, nlines, false);
  -}
   
  -void QPainter::drawPolyline(const QPointArray &points, int index, int npoints)
  -{
  -    _drawPoints (points, 0, index, npoints, false);
  -}
  +    int npoints = points.size();
  +    if (npoints <= 1)
  +        return;
   
  -void QPainter::drawPolygon(const QPointArray &points, bool winding, int index, 
  -    int npoints)
  -{
  -    _drawPoints (points, winding, index, npoints, true);
  -}
  +    CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
   
  -void QPainter::drawConvexPolygon(const QPointArray &points)
  -{
  -    _drawPoints (points, false, 0, -1, true);
  -}
  +    CGContextBeginPath(context);
  +    CGContextMoveToPoint(context, points[0].x(), points[0].y());
  +    for (int i = 1; i < npoints; i++)
  +        CGContextAddLineToPoint(context, points[i].x(), points[i].y());
  +    CGContextClosePath(context);
   
  -void QPainter::_drawPoints (const QPointArray &_points, bool winding, int index, int _npoints, bool fill)
  -{
  -    if (data->state.paintingDisabled)
  -        return;
  -        
  -    int npoints = _npoints != -1 ? _npoints : _points.size()-index;
  -    NSPoint points[npoints];
  -    for (int i = 0; i < npoints; i++) {
  -        points[i].x = _points[index+i].x();
  -        points[i].y = _points[index+i].y();
  -    }
  -            
  -    NSBezierPath *path = [[NSBezierPath alloc] init];
  -    [path appendBezierPathWithPoints:&points[0] count:npoints];
  -    [path closePath]; // Qt always closes the path.  Determined empirically.
  -    
  -    if (fill && data->state.brush.style() != NoBrush) {
  -        [path setWindingRule:winding ? NSNonZeroWindingRule : NSEvenOddWindingRule];
  +    if (data->state.brush.style() != NoBrush) {
           _setColorFromBrush();
  -        [path fill];
  +        CGContextEOFillPath(context);
       }
   
       if (data->state.pen.style() != NoPen) {
           _setColorFromPen();
  -        [path setLineWidth:data->state.pen.width()];
  -        [path stroke];
  +        CGContextSetLineWidth(context, data->state.pen.width());
  +        CGContextStrokePath(context);
       }
  -    
  -    [path release];
   }
   
  -
   void QPainter::drawPixmap(const QPoint &p, const QPixmap &pix)
   {        
       drawPixmap(p.x(), p.y(), pix);
   }
   
  -
   void QPainter::drawPixmap(const QPoint &p, const QPixmap &pix, const QRect &r)
   {
       drawPixmap(p.x(), p.y(), pix, r.x(), r.y(), r.width(), r.height());
  @@ -464,7 +436,8 @@
       NSCompositingOperation value;
   };
   
  -#define NUM_COMPOSITE_OPERATORS 14
  +const int NUM_COMPOSITE_OPERATORS = 14;
  +
   struct CompositeOperator compositeOperators[NUM_COMPOSITE_OPERATORS] = {
       { "clear", NSCompositeClear },
       { "copy", NSCompositeCopy },
  @@ -503,9 +476,7 @@
       
       if (aString.length()) {
           const char *operatorString = aString.ascii();
  -        int i;
  -        
  -        for (i = 0; i < NUM_COMPOSITE_OPERATORS; i++) {
  +        for (int i = 0; i < NUM_COMPOSITE_OPERATORS; i++) {
               if (strcasecmp (operatorString, compositeOperators[i].name) == 0) {
                   return compositeOperators[i].value;
               }
  @@ -747,7 +718,7 @@
       return col;
   }
   
  -// A fillRect designed to work around buggy behavior in NSRectFill.
  +// A fillRect helper to work around the fact that NSRectFill uses copy mode, not source over.
   static inline void _fillRectXX(float x, float y, float w, float h, const QColor& col)
   {
       [nsColor(col) set];
  
  
  



More information about the webkit-changes mailing list