Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / skia / src / core / SkPath.cpp
index 04c807b..9f94b72 100644 (file)
@@ -506,8 +506,8 @@ bool SkPath::isRectContour(bool allowPartial, int* currVerb, const SkPoint** pts
 
 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);
 }
@@ -1443,14 +1443,14 @@ void SkPath::arcTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
 
 ///////////////////////////////////////////////////////////////////////////////
 
-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);
@@ -1458,12 +1458,17 @@ void SkPath::addPath(const SkPath& path, const SkMatrix& matrix) {
     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);
@@ -1487,6 +1492,7 @@ void SkPath::addPath(const SkPath& path, const SkMatrix& matrix) {
             default:
                 SkDEBUGFAIL("unknown verb");
         }
+        firstVerb = false;
     }
 }