Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: include/core/SkClipStack.h

Issue 54543008: Revert "Avoid re-rendering stencil clip for every draw with reducable clip stack" (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/core/SkClipStack.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « no previous file | src/core/SkClipStack.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698