Revert of Add nine patch type to SkRRect. (https://codereview.chromium.org/196343015/)

Reason for revert:
causes tests to have infinite loop

Original issue's description:
> Add nine patch type to SkRRect.
>
> BUG=skia:2181
>
> Committed: http://code.google.com/p/skia/source/detail?r=13833

R=robertphillips@google.com, reed@google.com
TBR=reed@google.com, robertphillips@google.com
NOTREECHECKS=true
NOTRY=true
BUG=skia:2181

Author: bsalomon@google.com

Review URL: https://codereview.chromium.org/202163004

git-svn-id: http://skia.googlecode.com/svn/trunk@13837 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/core/SkRRect.h b/include/core/SkRRect.h
index 5223ae7..c09d2d4 100644
--- a/include/core/SkRRect.h
+++ b/include/core/SkRRect.h
@@ -71,14 +71,6 @@
         //!< the curves) nor a rect (i.e., both radii are non-zero)
         kSimple_Type,
 
-        //!< The RR is non-empty and the two left x radii are equal, the two top
-        //!< y radii are equal, and the same for the right and bottom but it is
-        //!< neither an rect, oval, nor a simple RR. It is called "nine patch"
-        //!< because the centers of the corner ellipses form an axis aligned
-        //!< rect with edges that divide the RR into an 9 rectangular patches:
-        //!< an interior patch, four edge patches, and four corner patches.
-        kNinePatch_Type,
-
         //!< A fully general (non-empty) RR. Some of the x and/or y radii are
         //!< different from the others and there must be one corner where
         //!< both radii are non-zero.
@@ -107,11 +99,21 @@
     inline bool isSimpleCircular() const {
         return this->isSimple() && fRadii[0].fX == fRadii[0].fY;
     }
-    inline bool isNinePatch() const { return kNinePatch_Type == this->getType(); }
     inline bool isComplex() const { return kComplex_Type == this->getType(); }
 
     bool allCornersCircular() const;
 
+    /**
+     * Are both x-radii the same on the two left corners, and similar for the top, right, and
+     * bottom. When this is the case the four ellipse centers form a rectangle.
+     */
+    bool isNinePatch() const {
+        return fRadii[kUpperLeft_Corner].fX == fRadii[kLowerLeft_Corner].fX &&
+               fRadii[kUpperRight_Corner].fX == fRadii[kLowerRight_Corner].fX &&
+               fRadii[kUpperLeft_Corner].fY == fRadii[kUpperRight_Corner].fY &&
+               fRadii[kLowerLeft_Corner].fY == fRadii[kLowerRight_Corner].fY;
+    }
+
     SkScalar width() const { return fRect.width(); }
     SkScalar height() const { return fRect.height(); }
 
@@ -170,12 +172,6 @@
     void setRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad);
 
     /**
-     * Initialize the rr with one radius per-side.
-     */
-    void setNinePatch(const SkRect& rect, SkScalar leftRad, SkScalar topRad,
-                      SkScalar rightRad, SkScalar bottomRad);
-
-    /**
      * Initialize the RR with potentially different radii for all four corners.
      */
     void setRectRadii(const SkRect& rect, const SkVector radii[4]);
diff --git a/src/core/SkRRect.cpp b/src/core/SkRRect.cpp
index 082646c..915ed75 100644
--- a/src/core/SkRRect.cpp
+++ b/src/core/SkRRect.cpp
@@ -43,61 +43,6 @@
     SkDEBUGCODE(this->validate();)
 }
 
-void SkRRect::setNinePatch(const SkRect& rect, SkScalar leftRad, SkScalar topRad,
-                           SkScalar rightRad, SkScalar bottomRad) {
-    if (rect.isEmpty()) {
-        this->setEmpty();
-        return;
-    }
-
-    leftRad = SkMaxScalar(leftRad, 0);
-    topRad = SkMaxScalar(topRad, 0);
-    rightRad = SkMaxScalar(rightRad, 0);
-    bottomRad = SkMaxScalar(bottomRad, 0);
-
-    SkScalar scale = SK_Scalar1;
-    if (leftRad + rightRad > rect.width()) {
-        scale = SkScalarDiv(rect.width(), leftRad + rightRad);
-    }
-    if (topRad + bottomRad > rect.height()) {
-        scale = SkMinScalar(scale, SkScalarDiv(rect.width(), leftRad + rightRad));
-    }
-
-    if (scale < SK_Scalar1) {
-        leftRad = SkScalarMul(leftRad, scale);
-        topRad = SkScalarMul(topRad, scale);
-        rightRad = SkScalarMul(rightRad, scale);
-        bottomRad = SkScalarMul(bottomRad, scale);
-    }
-
-    if (leftRad == rightRad && topRad == bottomRad) {
-        if (leftRad >= SkScalarHalf(rect.width()) && topRad >= SkScalarHalf(rect.height())) {
-            fType = kOval_Type;
-        } else if (0 == leftRad || 0 == topRad) {
-            // If the left and (by equality check above) right radii are zero then it is a rect.
-            // Same goes for top/bottom.
-            fType = kRect_Type;
-            leftRad = 0;
-            topRad = 0;
-            rightRad = 0;
-            bottomRad = 0;
-        } else {
-            fType = kSimple_Type;
-        }
-    } else {
-        fType = kNinePatch_Type;
-    }
-
-    fRect = rect;
-    fRadii[kUpperLeft_Corner].set(leftRad, topRad);
-    fRadii[kUpperRight_Corner].set(rightRad, topRad);
-    fRadii[kLowerRight_Corner].set(rightRad, bottomRad);
-    fRadii[kLowerLeft_Corner].set(leftRad, bottomRad);
-
-    SkDEBUGCODE(this->validate();)
-}
-
-
 void SkRRect::setRectRadii(const SkRect& rect, const SkVector radii[4]) {
     if (rect.isEmpty()) {
         this->setEmpty();
@@ -255,13 +200,6 @@
            this->checkCornerContainment(rect.fLeft, rect.fBottom);
 }
 
-static bool radii_are_nine_patch(const SkVector radii[4]) {
-    return radii[SkRRect::kUpperLeft_Corner].fX == radii[SkRRect::kLowerLeft_Corner].fX &&
-           radii[SkRRect::kUpperLeft_Corner].fY == radii[SkRRect::kUpperRight_Corner].fY &&
-           radii[SkRRect::kUpperRight_Corner].fX == radii[SkRRect::kLowerRight_Corner].fX &&
-           radii[SkRRect::kLowerLeft_Corner].fY == radii[SkRRect::kLowerRight_Corner].fY;
-}
-
 // There is a simplified version of this method in setRectXY
 void SkRRect::computeType() const {
     SkDEBUGCODE(this->validate();)
@@ -300,11 +238,7 @@
         return;
     }
 
-    if (radii_are_nine_patch(fRadii)) {
-        fType = kNinePatch_Type;
-    } else {
-        fType = kComplex_Type;
-    }
+    fType = kComplex_Type;
 }
 
 static bool matrix_only_scale_and_translate(const SkMatrix& matrix) {
@@ -457,7 +391,6 @@
             allCornersSquare = false;
         }
     }
-    bool patchesOfNine = radii_are_nine_patch(fRadii);
 
     switch (fType) {
         case kEmpty_Type:
@@ -484,15 +417,9 @@
             SkASSERT(!fRect.isEmpty());
             SkASSERT(!allRadiiZero && allRadiiSame && !allCornersSquare);
             break;
-        case kNinePatch_Type:
-            SkASSERT(!fRect.isEmpty());
-            SkASSERT(!allRadiiZero && !allRadiiSame && !allCornersSquare);
-            SkASSERT(patchesOfNine);
-            break;
         case kComplex_Type:
             SkASSERT(!fRect.isEmpty());
             SkASSERT(!allRadiiZero && !allRadiiSame && !allCornersSquare);
-            SkASSERT(!patchesOfNine);
             break;
         case kUnknown_Type:
             // no limits on this
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index ff98daf..a5cdc4f 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -288,10 +288,10 @@
             // already have code for rectangles.
             return kUnimplemented_FilterReturn;
 
-        // These three can take advantage of this fast path.
         case SkRRect::kSimple_Type:
-        case SkRRect::kNinePatch_Type:
+            // Fall through.
         case SkRRect::kComplex_Type:
+            // These can take advantage of this fast path.
             break;
     }
 
diff --git a/src/utils/SkLua.cpp b/src/utils/SkLua.cpp
index 44f2211..4b87458 100644
--- a/src/utils/SkLua.cpp
+++ b/src/utils/SkLua.cpp
@@ -1208,7 +1208,6 @@
         case SkRRect::kRect_Type: return "rect";
         case SkRRect::kOval_Type: return "oval";
         case SkRRect::kSimple_Type: return "simple";
-        case SkRRect::kNinePatch_Type: return "nine-patch";
         case SkRRect::kComplex_Type: return "complex";
     }
     SkDEBUGFAIL("never get here");
diff --git a/src/utils/debugger/SkObjectParser.cpp b/src/utils/debugger/SkObjectParser.cpp
index a3b2085..028300c 100644
--- a/src/utils/debugger/SkObjectParser.cpp
+++ b/src/utils/debugger/SkObjectParser.cpp
@@ -241,8 +241,6 @@
             mRRect->append("oval");
         } else if (rrect.isSimple()) {
             mRRect->append("simple");
-        } else if (rrect.isNinePatch()) {
-            mRRect->append("nine-patch");
         } else {
             SkASSERT(rrect.isComplex());
             mRRect->append("complex");
diff --git a/tests/RoundRectTest.cpp b/tests/RoundRectTest.cpp
index 0a528a6..9b2eecd 100644
--- a/tests/RoundRectTest.cpp
+++ b/tests/RoundRectTest.cpp
@@ -60,13 +60,6 @@
     for (int i = 0; i < 4; ++i) {
         REPORTER_ASSERT(reporter, zeroPt == rr1.radii((SkRRect::Corner) i));
     }
-    SkRRect rr1_2; // construct the same RR using the most general set function
-    SkVector rr1_2_radii[4] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } };
-    rr1_2.setRectRadii(rect, rr1_2_radii);
-    REPORTER_ASSERT(reporter, rr1_2 == rr1 && rr1_2.getType() == rr1.getType());
-    SkRRect rr1_3;  // construct the same RR using the nine patch set function
-    rr1_3.setNinePatch(rect, 0, 0, 0, 0);
-    REPORTER_ASSERT(reporter, rr1_3 == rr1 && rr1_3.getType() == rr1.getType());
 
     //----
     SkPoint halfPoint = { SkScalarHalf(kWidth), SkScalarHalf(kHeight) };
@@ -80,14 +73,6 @@
         REPORTER_ASSERT(reporter,
                         rr2.radii((SkRRect::Corner) i).equalsWithinTolerance(halfPoint));
     }
-    SkRRect rr2_2;  // construct the same RR using the most general set function
-    SkVector rr2_2_radii[4] = { { halfPoint.fX, halfPoint.fY }, { halfPoint.fX, halfPoint.fY },
-                                { halfPoint.fX, halfPoint.fY }, { halfPoint.fX, halfPoint.fY } };
-    rr2_2.setRectRadii(rect, rr2_2_radii);
-    REPORTER_ASSERT(reporter, rr2_2 == rr2 && rr2_2.getType() == rr2.getType());
-    SkRRect rr2_3;  // construct the same RR using the nine patch set function
-    rr2_3.setNinePatch(rect, halfPoint.fX, halfPoint.fY, halfPoint.fX, halfPoint.fY);
-    REPORTER_ASSERT(reporter, rr2_3 == rr2 && rr2_3.getType() == rr2.getType());
 
     //----
     SkPoint p = { 5, 5 };
@@ -100,33 +85,19 @@
     for (int i = 0; i < 4; ++i) {
         REPORTER_ASSERT(reporter, p == rr3.radii((SkRRect::Corner) i));
     }
-    SkRRect rr3_2; // construct the same RR using the most general set function
-    SkVector rr3_2_radii[4] = { { 5, 5 }, { 5, 5 }, { 5, 5 }, { 5, 5 } };
-    rr3_2.setRectRadii(rect, rr3_2_radii);
-    REPORTER_ASSERT(reporter, rr3_2 == rr3 && rr3_2.getType() == rr3.getType());
-    SkRRect rr3_3;  // construct the same RR using the nine patch set function
-    rr3_3.setNinePatch(rect, 5, 5, 5, 5);
-    REPORTER_ASSERT(reporter, rr3_3 == rr3 && rr3_3.getType() == rr3.getType());
 
     //----
-    SkRect ninePatchRadii = { 10, 9, 8, 7 };
+    SkPoint radii[4] = { { 5, 5 }, { 5, 5 }, { 5, 5 }, { 5, 5 } };
 
     SkRRect rr4;
-    rr4.setNinePatch(rect, ninePatchRadii.fLeft, ninePatchRadii.fTop, ninePatchRadii.fRight,
-                     ninePatchRadii.fBottom);
+    rr4.setRectRadii(rect, radii);
 
-    REPORTER_ASSERT(reporter, SkRRect::kNinePatch_Type == rr4.type());
+    REPORTER_ASSERT(reporter, SkRRect::kSimple_Type == rr4.type());
     REPORTER_ASSERT(reporter, rr4.rect() == rect);
 
-    SkPoint rquad[4];
-    ninePatchRadii.toQuad(rquad);
     for (int i = 0; i < 4; ++i) {
-        REPORTER_ASSERT(reporter, rquad[i] == rr4.radii((SkRRect::Corner) i));
+        REPORTER_ASSERT(reporter, radii[i] == rr4.radii((SkRRect::Corner) i));
     }
-    SkRRect rr4_2; // construct the same RR using the most general set function
-    SkVector rr4_2_radii[4] = { { 10, 9 }, { 8, 9 }, {8, 7 }, { 10, 7 } };
-    rr4_2.setRectRadii(rect, rr4_2_radii);
-    REPORTER_ASSERT(reporter, rr4_2 == rr4 && rr4_2.getType() == rr4.getType());
 
     //----
     SkPoint radii2[4] = { { 0, 0 }, { 0, 0 }, { 50, 50 }, { 20, 50 } };
@@ -143,7 +114,7 @@
 
     // Test out == & !=
     REPORTER_ASSERT(reporter, empty != rr3);
-    REPORTER_ASSERT(reporter, rr3 != rr4);
+    REPORTER_ASSERT(reporter, rr3 == rr4);
     REPORTER_ASSERT(reporter, rr4 != rr5);
 }