Index: include/core/SkClipStack.h |
diff --git a/include/core/SkClipStack.h b/include/core/SkClipStack.h |
index 0d6cfb296fc578e54ece0f8b7181d814d43cafd2..145552dc13aca12b5cc1fd19404896379eb0f6b2 100644 |
--- a/include/core/SkClipStack.h |
+++ b/include/core/SkClipStack.h |
@@ -109,7 +109,7 @@ public: |
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 @@ public: |
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 @@ private: |
// 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(); |