Revert "Avoid re-rendering stencil clip for every draw with reducable clip stack"

This reverts commit 92a7d4bf6a371f1f864154be902e8d86938e560b.

Revert "fix mac 10.6 build"

This reverts commit 114cd1a9f2734aaed6914718814364811b78bd7f.

BUG=

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

git-svn-id: http://skia.googlecode.com/svn/trunk/include@12087 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/core/SkClipStack.h b/core/SkClipStack.h
index 0d6cfb2..145552d 100644
--- a/core/SkClipStack.h
+++ b/core/SkClipStack.h
@@ -109,7 +109,7 @@
             stack not to the element itself. That is the same clip path in different stacks will
             have a different ID since the elements produce different clip result in the context of
             their stacks. */
-        int32_t getGenID() const { SkASSERT(kInvalidGenID != fGenID); return fGenID; }
+        int32_t getGenID() const { return fGenID; }
 
         /**
          * Gets the bounds of the clip element, either the rect or path bounds. (Whether the shape
@@ -316,12 +316,25 @@
     bool isWideOpen() const;
 
     /**
+     * Add a callback function that will be called whenever a clip state
+     * is no longer viable. This will occur whenever restore
+     * is called or when a clipDevRect or clipDevPath call updates the
+     * clip within an existing save/restore state. Each clip state is
+     * represented by a unique generation ID.
+     */
+    typedef void (*PFPurgeClipCB)(int genID, void* data);
+    void addPurgeClipCallback(PFPurgeClipCB callback, void* data) const;
+
+    /**
+     * Remove a callback added earlier via addPurgeClipCallback
+     */
+    void removePurgeClipCallback(PFPurgeClipCB callback, void* data) const;
+
+    /**
      * The generation ID has three reserved values to indicate special
      * (potentially ignorable) cases
      */
-    static const int32_t kInvalidGenID = 0;     //!< Invalid id that is never returned by
-                                                //!< SkClipStack. Useful when caching clips
-                                                //!< based on GenID.
+    static const int32_t kInvalidGenID = 0;
     static const int32_t kEmptyGenID = 1;       // no pixels writeable
     static const int32_t kWideOpenGenID = 2;    // all pixels writeable
 
@@ -427,12 +440,29 @@
     // invalid ID.
     static int32_t     gGenID;
 
+    struct ClipCallbackData {
+        PFPurgeClipCB   fCallback;
+        void*           fData;
+
+        friend bool operator==(const ClipCallbackData& a,
+                               const ClipCallbackData& b) {
+            return a.fCallback == b.fCallback && a.fData == b.fData;
+        }
+    };
+
+    mutable SkTDArray<ClipCallbackData> fCallbackData;
+
     /**
      * Restore the stack back to the specified save count.
      */
     void restoreTo(int saveCount);
 
     /**
+     * Invoke all the purge callbacks passing in element's generation ID.
+     */
+    void purgeClip(Element* element);
+
+    /**
      * Return the next unique generation ID.
      */
     static int32_t GetNextGenID();