diff options
Diffstat (limited to 'skia/corecg/SkRegion.cpp')
-rw-r--r-- | skia/corecg/SkRegion.cpp | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/skia/corecg/SkRegion.cpp b/skia/corecg/SkRegion.cpp index a0860b6e..4edd222 100644 --- a/skia/corecg/SkRegion.cpp +++ b/skia/corecg/SkRegion.cpp @@ -1,6 +1,6 @@ /* libs/corecg/SkRegion.cpp ** -** Copyright 2006, Google Inc. +** Copyright 2006, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. @@ -430,6 +430,46 @@ const SkRegion::RunType* SkRegion::getRuns(RunType tmpStorage[], int* count) con ///////////////////////////////////////////////////////////////////////////////////// +bool SkRegion::intersects(const SkIRect& r) const { + if (this->isEmpty() || r.isEmpty()) { + return false; + } + + if (!SkIRect::Intersects(fBounds, r)) { + return false; + } + + if (this->isRect()) { + return true; + } + + // we are complex + SkRegion tmp; + return tmp.op(*this, r, kIntersect_Op); +} + +bool SkRegion::intersects(const SkRegion& rgn) const { + if (this->isEmpty() || rgn.isEmpty()) { + return false; + } + + if (!SkIRect::Intersects(fBounds, rgn.fBounds)) { + return false; + } + + if (this->isRect() && rgn.isRect()) { + return true; + } + + // one or both of us is complex + // TODO: write a faster version that aborts as soon as we write the first + // non-empty span, to avoid build the entire result + SkRegion tmp; + return tmp.op(*this, rgn, kIntersect_Op); +} + +///////////////////////////////////////////////////////////////////////////////////// + int operator==(const SkRegion& a, const SkRegion& b) { SkDEBUGCODE(a.validate();) |