Index: include/core/SkCanvas.h |
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h |
index 3eadb4cccabd207953579a51b7a6627527800814..4d9c462b73c36ab5a506e5eb07ed20da570c30ab 100644 |
--- a/include/core/SkCanvas.h |
+++ b/include/core/SkCanvas.h |
@@ -597,6 +597,20 @@ public: |
virtual void clear(SkColor); |
/** |
+ * This makes the contents of the canvas undefined. Subsequent calls that |
+ * require reading the canvas contents will produce undefined results. Examples |
+ * include blending and readPixels. The actual implementation is backend- |
+ * dependent and one legal implementation is to do nothing. Like clear(), this |
+ * ignores the clip. |
+ * |
+ * This function should only be called if the caller intends to subsequently |
+ * draw to the canvas. The canvas may do real work at discard() time in order |
+ * to optimize performance on subsequent draws. Thus, if you call this and then |
+ * never draw to the canvas subsequently you may pay a perfomance penalty. |
+ */ |
+ void discard() { this->onDiscard(); } |
+ |
+ /** |
* Fill the entire canvas' bitmap (restricted to the current clip) with the |
* specified paint. |
* @param paint The paint used to fill the canvas |
@@ -1176,6 +1190,8 @@ protected: |
virtual void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle); |
virtual void onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op); |
+ virtual void onDiscard(); |
+ |
// Returns the canvas to be used by DrawIter. Default implementation |
// returns this. Subclasses that encapsulate an indirect canvas may |
// need to overload this method. The impl must keep track of this, as it |