Share code with SkRect
http://codereview.appspot.com/4523046/
git-svn-id: http://skia.googlecode.com/svn/trunk@1277 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/src/GrPath.cpp b/gpu/src/GrPath.cpp
index 3687b80..aa89d37 100644
--- a/gpu/src/GrPath.cpp
+++ b/gpu/src/GrPath.cpp
@@ -104,7 +104,7 @@
iter->offset(tx, ty);
++iter;
}
- fConservativeBounds.translate(tx, ty);
+ fConservativeBounds.offset(tx, ty);
}
///////////////////////////////////////////////////////////////////////////////
@@ -221,7 +221,7 @@
}
int n = NumPathCmdPoints(cmd);
for (int i = 0; i < n; ++i) {
- fConservativeBounds.growToInclude(pts[i]);
+ fConservativeBounds.growToInclude(pts[i].fX, pts[i].fY);
}
if (0 == subPathPts && n > 0) {
previousPt = pts[0];
@@ -423,6 +423,13 @@
this->rewind();
}
+#ifdef SK_DEBUG
+static bool containsInclusive(const GrRect& rect, const GrPoint& point) {
+ return point.fX >= rect.fLeft && point.fX <= rect.fRight &&
+ point.fY >= rect.fTop && point.fY <= rect.fBottom;
+}
+#endif
+
GrPathCmd GrPath::Iter::next(GrPoint points[]) {
if (fCmdIndex == fPath->fCmds.count()) {
GrAssert(fPtIndex == fPath->fPts.count());
@@ -441,7 +448,7 @@
}
fLastPt = srcPts[0];
GrAssert(fPtIndex <= fPath->fPts.count() + 1);
- GrAssert(fPath->getConservativeBounds().containsInclusive(srcPts[0]));
+ GrAssert(containsInclusive(fPath->getConservativeBounds(), srcPts[0]));
fPtIndex += 1;
break;
case kLine_PathCmd:
@@ -451,7 +458,7 @@
}
fLastPt = srcPts[0];
GrAssert(fPtIndex <= fPath->fPts.count() + 1);
- GrAssert(fPath->getConservativeBounds().containsInclusive(srcPts[0]));
+ GrAssert(containsInclusive(fPath->getConservativeBounds(), srcPts[0]));
fPtIndex += 1;
break;
case kQuadratic_PathCmd:
@@ -462,8 +469,8 @@
}
fLastPt = srcPts[1];
GrAssert(fPtIndex <= fPath->fPts.count() + 2);
- GrAssert(fPath->getConservativeBounds().containsInclusive(srcPts[0]));
- GrAssert(fPath->getConservativeBounds().containsInclusive(srcPts[1]));
+ GrAssert(containsInclusive(fPath->getConservativeBounds(), srcPts[0]));
+ GrAssert(containsInclusive(fPath->getConservativeBounds(), srcPts[1]));
fPtIndex += 2;
break;
case kCubic_PathCmd:
@@ -475,9 +482,9 @@
}
fLastPt = srcPts[2];
GrAssert(fPtIndex <= fPath->fPts.count() + 3);
- GrAssert(fPath->getConservativeBounds().containsInclusive(srcPts[0]));
- GrAssert(fPath->getConservativeBounds().containsInclusive(srcPts[1]));
- GrAssert(fPath->getConservativeBounds().containsInclusive(srcPts[2]));
+ GrAssert(containsInclusive(fPath->getConservativeBounds(), srcPts[0]));
+ GrAssert(containsInclusive(fPath->getConservativeBounds(), srcPts[1]));
+ GrAssert(containsInclusive(fPath->getConservativeBounds(), srcPts[2]));
fPtIndex += 3;
break;
case kClose_PathCmd: