SkPath::PathAsRect SkPath::asRect(Direction* direction) const {
SK_COMPILE_ASSERT(0 == kNone_PathAsRect, path_as_rect_mismatch);
- SK_COMPILE_ASSERT(1 == kStroke_PathAsRect, path_as_rect_mismatch);
- SK_COMPILE_ASSERT(2 == kFill_PathAsRect, path_as_rect_mismatch);
+ SK_COMPILE_ASSERT(1 == kFill_PathAsRect, path_as_rect_mismatch);
+ SK_COMPILE_ASSERT(2 == kStroke_PathAsRect, path_as_rect_mismatch);
bool isClosed = false;
return (PathAsRect) (isRect(&isClosed, direction) + isClosed);
}
///////////////////////////////////////////////////////////////////////////////
-void SkPath::addPath(const SkPath& path, SkScalar dx, SkScalar dy) {
+void SkPath::addPath(const SkPath& path, SkScalar dx, SkScalar dy, AddPathMode mode) {
SkMatrix matrix;
matrix.setTranslate(dx, dy);
- this->addPath(path, matrix);
+ this->addPath(path, matrix, mode);
}
-void SkPath::addPath(const SkPath& path, const SkMatrix& matrix) {
+void SkPath::addPath(const SkPath& path, const SkMatrix& matrix, AddPathMode mode) {
SkPathRef::Editor(&fPathRef, path.countVerbs(), path.countPoints());
RawIter iter(path);
Verb verb;
SkMatrix::MapPtsProc proc = matrix.getMapPtsProc();
-
+ bool firstVerb = true;
while ((verb = iter.next(pts)) != kDone_Verb) {
switch (verb) {
case kMove_Verb:
proc(matrix, &pts[0], &pts[0], 1);
- this->moveTo(pts[0]);
+ if (firstVerb && mode == kExtend_AddPathMode && !isEmpty()) {
+ injectMoveToIfNeeded(); // In case last contour is closed
+ this->lineTo(pts[0]);
+ } else {
+ this->moveTo(pts[0]);
+ }
break;
case kLine_Verb:
proc(matrix, &pts[1], &pts[1], 1);
default:
SkDEBUGFAIL("unknown verb");
}
+ firstVerb = false;
}
}