SkClipStack::Element tweaks.

(
This is intended to facilitate efficient kMatrix_SaveFlags emulation
on restore():

  * collect all clip stack elements for the current save count into a
    side clip stack
  * canvas.restore(everything)
  * replay the collected clip ops to restore the initial clip state
  => we restored the matrix but the clip state is unchanged
)

Two main changes:

  * expose the save count for SkClipStack::Element
  * expose a replay method for the same (logic relocated from
    SkCanvas::replayClips)

The SkCanvas::ClipVisitor shuffling is to enable forward decl
in SkClipStack.h (cannot fwdecl a nested class).

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

Author: fmalita@chromium.org

Review URL: https://codereview.chromium.org/269693003
diff --git a/src/core/SkClipStack.cpp b/src/core/SkClipStack.cpp
index b60a6c9..d087592 100644
--- a/src/core/SkClipStack.cpp
+++ b/src/core/SkClipStack.cpp
@@ -1,10 +1,11 @@
-
 /*
  * Copyright 2011 Google Inc.
  *
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
+
+#include "SkCanvas.h"
 #include "SkClipStack.h"
 #include "SkPath.h"
 #include "SkThread.h"
@@ -66,6 +67,25 @@
     }
 }
 
+void SkClipStack::Element::replay(SkCanvasClipVisitor* visitor) const {
+    static const SkRect kEmptyRect = { 0, 0, 0, 0 };
+
+    switch (fType) {
+        case kPath_Type:
+            visitor->clipPath(this->getPath(), this->getOp(), this->isAA());
+            break;
+        case kRRect_Type:
+            visitor->clipRRect(this->getRRect(), this->getOp(), this->isAA());
+            break;
+        case kRect_Type:
+            visitor->clipRect(this->getRect(), this->getOp(), this->isAA());
+            break;
+        case kEmpty_Type:
+            visitor->clipRect(kEmptyRect, SkRegion::kIntersect_Op, false);
+            break;
+    }
+}
+
 void SkClipStack::Element::invertShapeFillType() {
     switch (fType) {
         case kRect_Type: