Use SkRRect to store rects in SkClipStack::Element


BUG=skia:2181
R=robertphillips@google.com

Author: bsalomon@google.com

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

git-svn-id: http://skia.googlecode.com/svn/trunk@13544 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/core/SkClipStack.h b/include/core/SkClipStack.h
index a23ef4a..5da53ae 100644
--- a/include/core/SkClipStack.h
+++ b/include/core/SkClipStack.h
@@ -78,7 +78,10 @@
         const SkRRect& getRRect() const { SkASSERT(kRRect_Type == fType); return fRRect; }
 
         //!< Call if getType() is kRect to get the rect.
-        const SkRect& getRect() const { SkASSERT(kRect_Type == fType); return fRect; }
+        const SkRect& getRect() const {
+            SkASSERT(kRect_Type == fType && (fRRect.isRect() || fRRect.isEmpty()));
+            return fRRect.getBounds();
+        }
 
         //!< Call if getType() is not kEmpty to get the set operation used to combine this element.
         SkRegion::Op getOp() const { return fOp; }
@@ -110,8 +113,7 @@
         const SkRect& getBounds() const {
             static const SkRect kEmpty = { 0, 0, 0, 0 };
             switch (fType) {
-                case kRect_Type:
-                    return fRect;
+                case kRect_Type:  // fallthrough
                 case kRRect_Type:
                     return fRRect.getBounds();
                 case kPath_Type:
@@ -131,7 +133,7 @@
         bool contains(const SkRect& rect) const {
             switch (fType) {
                 case kRect_Type:
-                    return fRect.contains(rect);
+                    return this->getRect().contains(rect);
                 case kRRect_Type:
                     return fRRect.contains(rect);
                 case kPath_Type:
@@ -155,7 +157,6 @@
         friend class SkClipStack;
 
         SkPath          fPath;
-        SkRect          fRect;
         SkRRect         fRRect;
         int             fSaveCount; // save count of stack when this element was added.
         SkRegion::Op    fOp;
@@ -211,17 +212,17 @@
         }
 
         void initRect(int saveCount, const SkRect& rect, SkRegion::Op op, bool doAA) {
-            fRect = rect;
+            fRRect.setRect(rect);
             fType = kRect_Type;
             this->initCommon(saveCount, op, doAA);
         }
 
         void initRRect(int saveCount, const SkRRect& rrect, SkRegion::Op op, bool doAA) {
-            if (rrect.isRect()) {
-                fRect = rrect.getBounds();
+            SkRRect::Type type = rrect.getType();
+            fRRect = rrect;
+            if (SkRRect::kRect_Type == type || SkRRect::kEmpty_Type == type) {
                 fType = kRect_Type;
             } else {
-                fRRect = rrect;
                 fType = kRRect_Type;
             }
             this->initCommon(saveCount, op, doAA);