Use SkTLazy to hold path in SkClipStack::Element

R=reed@google.com, robertphillips@google.com

Author: bsalomon@google.com

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

git-svn-id: http://skia.googlecode.com/svn/trunk@13610 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkClipStack.cpp b/src/core/SkClipStack.cpp
index 7e67ddf..b60a6c9 100644
--- a/src/core/SkClipStack.cpp
+++ b/src/core/SkClipStack.cpp
@@ -16,6 +16,31 @@
 static const int32_t kFirstUnreservedGenID = 3;
 int32_t SkClipStack::gGenID = kFirstUnreservedGenID;
 
+SkClipStack::Element::Element(const Element& that) {
+    switch (that.getType()) {
+        case kEmpty_Type:
+            fPath.reset();
+            break;
+        case kRect_Type: // Rect uses rrect
+        case kRRect_Type:
+            fPath.reset();
+            fRRect = that.fRRect;
+            break;
+        case kPath_Type:
+            fPath.set(that.getPath());
+            break;
+    }
+
+    fSaveCount = that.fSaveCount;
+    fOp = that.fOp;
+    fType = that.fType;
+    fDoAA = that.fDoAA;
+    fFiniteBoundType = that.fFiniteBoundType;
+    fFiniteBound = that.fFiniteBound;
+    fIsIntersectionOfRects = that.fIsIntersectionOfRects;
+    fGenID = that.fGenID;
+}
+
 bool SkClipStack::Element::operator== (const Element& element) const {
     if (this == &element) {
         return true;
@@ -28,7 +53,7 @@
     }
     switch (fType) {
         case kPath_Type:
-            return fPath == element.fPath;
+            return this->getPath() == element.getPath();
         case kRRect_Type:
             return fRRect == element.fRRect;
         case kRect_Type:
@@ -44,19 +69,19 @@
 void SkClipStack::Element::invertShapeFillType() {
     switch (fType) {
         case kRect_Type:
-            fPath.reset();
-            fPath.addRect(this->getRect());
-            fPath.setFillType(SkPath::kInverseEvenOdd_FillType);
+            fPath.init();
+            fPath.get()->addRect(this->getRect());
+            fPath.get()->setFillType(SkPath::kInverseEvenOdd_FillType);
             fType = kPath_Type;
             break;
         case kRRect_Type:
-            fPath.reset();
-            fPath.addRRect(fRRect);
-            fPath.setFillType(SkPath::kInverseEvenOdd_FillType);
+            fPath.init();
+            fPath.get()->addRRect(fRRect);
+            fPath.get()->setFillType(SkPath::kInverseEvenOdd_FillType);
             fType = kPath_Type;
             break;
         case kPath_Type:
-            fPath.toggleInverseFillType();
+            fPath.get()->toggleInverseFillType();
             break;
         case kEmpty_Type:
             // Should this set to an empty, inverse filled path?
@@ -79,7 +104,7 @@
             return;
         }
     }
-    fPath = path;
+    fPath.set(path);
     fType = kPath_Type;
     this->initCommon(saveCount, op, doAA);
 }
@@ -98,7 +123,7 @@
             path->addRRect(fRRect);
             break;
         case kPath_Type:
-            *path = fPath;
+            *path = *fPath.get();
             break;
     }
 }
@@ -119,7 +144,7 @@
     SkASSERT(kNormal_BoundsType == fFiniteBoundType);
     SkASSERT(!fIsIntersectionOfRects);
     SkASSERT(kEmptyGenID == fGenID);
-    SkASSERT(fPath.isEmpty());
+    SkASSERT(!fPath.isValid());
 }
 
 bool SkClipStack::Element::canBeIntersectedInPlace(int saveCount, SkRegion::Op op) const {
@@ -357,9 +382,9 @@
             fFiniteBoundType = kNormal_BoundsType;
             break;
         case kPath_Type:
-            fFiniteBound = fPath.getBounds();
+            fFiniteBound = fPath.get()->getBounds();
 
-            if (fPath.isInverseFillType()) {
+            if (fPath.get()->isInverseFillType()) {
                 fFiniteBoundType = kInsideOut_BoundsType;
             } else {
                 fFiniteBoundType = kNormal_BoundsType;