diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkClipStack.cpp | 14 | ||||
-rw-r--r-- | src/core/SkClipStack.h | 3 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/core/SkClipStack.cpp b/src/core/SkClipStack.cpp index bc8c5c5d62..f41945e090 100644 --- a/src/core/SkClipStack.cpp +++ b/src/core/SkClipStack.cpp @@ -580,6 +580,20 @@ void SkClipStack::restoreTo(int saveCount) { } } +SkRect SkClipStack::bounds(const SkIRect& deviceBounds) const { + // TODO: optimize this. + SkRect r; + SkClipStack::BoundsType bounds; + this->getBounds(&r, &bounds); + if (bounds == SkClipStack::kInsideOut_BoundsType) { + return SkRect::Make(deviceBounds); + } + return r.intersect(SkRect::Make(deviceBounds)) ? r : SkRect::MakeEmpty(); +} + +// TODO: optimize this. +bool SkClipStack::isEmpty(const SkIRect& r) const { return this->bounds(r).isEmpty(); } + void SkClipStack::getBounds(SkRect* canvFiniteBound, BoundsType* boundType, bool* isIntersectionOfRects) const { diff --git a/src/core/SkClipStack.h b/src/core/SkClipStack.h index 2f24d69502..080712dfe3 100644 --- a/src/core/SkClipStack.h +++ b/src/core/SkClipStack.h @@ -353,6 +353,9 @@ public: BoundsType* boundType, bool* isIntersectionOfRects = NULL) const; + SkRect bounds(const SkIRect& deviceBounds) const; + bool isEmpty(const SkIRect& deviceBounds) const; + /** * Returns true if the input (r)rect in device space is entirely contained * by the clip. A return value of false does not guarantee that the (r)rect |