diff options
author | 2017-02-07 16:58:28 -0500 | |
---|---|---|
committer | 2017-02-22 16:29:41 +0000 | |
commit | f3ee34f1eca8f32fa0ec5494c335ce75382420a7 (patch) | |
tree | 6b5b0e6416dede0ecbe77c4be4e088a8574f87f6 /src/core/SkClipStack.cpp | |
parent | 384b90af5ccdbb071f32e20b382f41351b2a0b69 (diff) |
SkClipStack: add bounds() and isEmpty() methods
Also: update some of SkPDF to use these rather than the RasterClip.
Change-Id: I5a2564d2269c145135df6a8eda65ab05e4aeaf14
Reviewed-on: https://skia-review.googlesource.com/8159
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
Diffstat (limited to 'src/core/SkClipStack.cpp')
-rw-r--r-- | src/core/SkClipStack.cpp | 14 |
1 files changed, 14 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 { |