Chromium Code Reviews| Index: include/core/SkCanvas.h |
| diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h |
| index 7235efb2f0a9cd3b23132541d9c695b0c81e1704..b427c4045ce452f367b261932c07b7bfbc54d9d5 100644 |
| --- a/include/core/SkCanvas.h |
| +++ b/include/core/SkCanvas.h |
| @@ -891,7 +891,27 @@ public: |
| // do nothing. Subclasses may do something |
| } |
| + /** |
| + * This call asserts that subsequent draw operations (up to the matching popCull() call) |
| + * are fully contained within the given bounding box. The assertion is not enforced, |
| + * but the information might be used to quick-reject command blocks, so an incorrect |
| + * bounding box may result in incomplete rendering. |
| + */ |
| + void pushCull(const SkRect& cullRect) { |
| + fCullCount += 1; |
| + this->onPushCull(cullRect); |
| + } |
| + /** |
| + * Terminates the current culling block, and restores the previous one (if any). |
| + */ |
| + void popCull() { |
| + SkASSERT(fCullCount > 0); |
| + if (fCullCount > 0) { |
|
caryclark
2014/02/14 14:54:35
since you have the assert, do you also need the te
f(malita)
2014/02/20 02:37:26
We guard against underflow for restore(), so I fig
|
| + fCullCount -= 1; |
| + this->onPopCull(); |
| + } |
| + } |
|
reed1
2014/02/14 14:39:06
I wonder if we'll want similar helpers to what sav
|
| ////////////////////////////////////////////////////////////////////////// |
| /** Get the current bounder object. |
| @@ -1053,6 +1073,9 @@ protected: |
| */ |
| virtual SkBaseDevice* setDevice(SkBaseDevice* device); |
| + virtual void onPushCull(const SkRect& cullRect); |
| + virtual void onPopCull(); |
| + |
| private: |
| class MCRec; |
| @@ -1065,6 +1088,7 @@ private: |
| SkBounder* fBounder; |
| int fSaveLayerCount; // number of successful saveLayer calls |
| + unsigned fCullCount; // number of active culls |
|
reed1
2014/02/14 14:39:06
nit: int so we can notice negatives easier, and to
f(malita)
2014/02/20 02:37:26
Will do.
|
| SkMetaData* fMetaData; |