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

Eric eseidel at opensource.apple.com
Tue Nov 29 02:11:21 PST 2005


eseidel     05/11/29 02:11:20

  Modified:    .        ChangeLog
               kwq      KWQRegion.h KWQRegion.mm
  Log:
  Bug #: 5310
  Submitted by: mitz
  Reviewed by: hyatt
          Not possible to test (functionality shouldn't change).
  
          Switch QRegion from using NSBezierPath to CGPath
          http://bugzilla.opendarwin.org/show_bug.cgi?id=5310
  
          * kwq/KWQRegion.h:
          * kwq/KWQRegion.mm:
          (QRegion::QRegion):
          (QRegion::~QRegion):
          (QRegion::operator=):
          (QRegion::contains):
          (QRegion::translate):
          (QRegion::boundingRect):
  
  Revision  Changes    Path
  1.419     +18 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.418
  retrieving revision 1.419
  diff -u -r1.418 -r1.419
  --- ChangeLog	29 Nov 2005 09:07:53 -0000	1.418
  +++ ChangeLog	29 Nov 2005 10:11:19 -0000	1.419
  @@ -1,3 +1,21 @@
  +2005-11-29  Mitz Pettel  <opendarwin.org at mitzpettel.com>
  +
  +        Reviewed by hyatt.  Committed by eseidel.
  +
  +        Not possible to test (functionality shouldn't change).
  +
  +        Switch QRegion from using NSBezierPath to CGPath
  +        http://bugzilla.opendarwin.org/show_bug.cgi?id=5310
  +
  +        * kwq/KWQRegion.h:
  +        * kwq/KWQRegion.mm:
  +        (QRegion::QRegion):
  +        (QRegion::~QRegion):
  +        (QRegion::operator=):
  +        (QRegion::contains):
  +        (QRegion::translate):
  +        (QRegion::boundingRect):
  +
   2005-11-28  Alexey Proskuryakov  <ap at nypop.com>
   
           Reviewed by Darin. Commited by Maciej.
  
  
  
  1.23      +2 -6      WebCore/kwq/KWQRegion.h
  
  Index: KWQRegion.h
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQRegion.h,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- KWQRegion.h	22 Jan 2003 00:12:35 -0000	1.22
  +++ KWQRegion.h	29 Nov 2005 10:11:20 -0000	1.23
  @@ -30,11 +30,7 @@
   #include "KWQImage.h"
   #include "KWQRect.h"
   
  -#ifdef __OBJC__
  - at class NSBezierPath;
  -#else
  -class NSBezierPath;
  -#endif
  +typedef struct CGPath *CGMutablePathRef;
   
   class QRegion {
   public:
  @@ -55,7 +51,7 @@
       void translate(int deltaX, int deltaY);
   
   private:
  -    NSBezierPath *path;    
  +    CGMutablePathRef path;    
   };
   
   #endif
  
  
  
  1.22      +23 -27    WebCore/kwq/KWQRegion.mm
  
  Index: KWQRegion.mm
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQRegion.mm,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- KWQRegion.mm	3 Oct 2005 21:13:08 -0000	1.21
  +++ KWQRegion.mm	29 Nov 2005 10:11:20 -0000	1.22
  @@ -27,42 +27,37 @@
   #import "KWQRegion.h"
   #import "KWQFoundationExtras.h"
   
  -// None of the NSBezierPath calls here can possibly throw an NSException.
  -// Some path calls do this when the path is empty, but we always make
  -// those when the path is guaranteed non-empty.
  -
   QRegion::QRegion(const QRect &rect)
  -    : path(KWQRetain([NSBezierPath bezierPathWithRect:rect]))
   {
  +    path = CGPathCreateMutable();
  +    CGPathAddRect(path, 0, rect);
   }
   
   QRegion::QRegion(int x, int y, int w, int h, RegionType t)
   {
  -    if (t == Rectangle) {
  -        path = KWQRetain([NSBezierPath bezierPathWithRect:NSMakeRect(x, y, w, h)]);
  -    } else { // Ellipse
  -        path = KWQRetain([NSBezierPath bezierPathWithOvalInRect:NSMakeRect(x, y, w, h)]);
  -    }
  +    path = CGPathCreateMutable();
  +    if (t == Rectangle)
  +        CGPathAddRect(path, 0, CGRectMake(x, y, w, h));
  +    else // Ellipse
  +        CGPathAddEllipseInRect(path, 0, CGRectMake(x, y, w, h));
   }
   
   QRegion::QRegion(const QPointArray &arr)
   {
  -    path = KWQRetainNSRelease([[NSBezierPath alloc] init]);
  -    [path moveToPoint:arr[0]];
  -    // the moveToPoint: guarantees the path is not empty, which means lineToPoint:
  -    // can't throw.
  -    for (uint i = 1; i < arr.count(); ++i) {
  -        [path lineToPoint:arr[i]];
  -    }
  +    path = CGPathCreateMutable();
  +    CGPathMoveToPoint(path, 0, arr[0].x(), arr[0].y());
  +    for (uint i = 1; i < arr.count(); ++i)
  +        CGPathAddLineToPoint(path, 0, arr[i].x(), arr[i].y());
  +    CGPathCloseSubpath(path);
   }
   
   QRegion::~QRegion()
   {
  -    KWQRelease(path);
  +    CGPathRelease(path);
   }
   
   QRegion::QRegion(const QRegion &other)
  -    : path(KWQRetainNSRelease([other.path copy]))
  +    : path(CGPathCreateMutableCopy(other.path))
   {
   }
   
  @@ -71,25 +66,26 @@
       if (path == other.path) {
           return *this;
       }
  -    KWQRelease(path);
  -    path = KWQRetainNSRelease([other.path copy]);
  +    CGPathRelease(path);
  +    path = CGPathCreateMutableCopy(other.path);
       return *this;
   }
   
   bool QRegion::contains(const QPoint &point) const
   {
  -    return [path containsPoint:point];
  +    return CGPathContainsPoint(path, 0, point, false);
   }
   
   void QRegion::translate(int deltaX, int deltaY)
   {
  -    NSAffineTransform *translation = [[NSAffineTransform alloc] init];
  -    [translation translateXBy:deltaX yBy:deltaY];
  -    [path transformUsingAffineTransform:translation];    
  -    [translation release];
  +    CGAffineTransform translation = CGAffineTransformMake(1, 0, 0, 1, deltaX, deltaY);
  +    CGMutablePathRef newPath = CGPathCreateMutable();
  +    CGPathAddPath(newPath, &translation, path);
  +    CGPathRelease(path);
  +    path = newPath;
   }
   
   QRect QRegion::boundingRect() const
   {
  -    return path ? QRect([path bounds]) : QRect();
  +    return path ? QRect(CGPathGetBoundingBox(path)) : QRect();
   }
  
  
  



More information about the webkit-changes mailing list