summaryrefslogtreecommitdiffstats
path: root/skia/corecg/SkRegion.cpp
diff options
context:
space:
mode:
authorbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-12 21:01:41 +0000
committerbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-12 21:01:41 +0000
commit52e935d04c59135739c3a68fb6e19d313dc6d5ad (patch)
tree95f7ab178b045bef4456cbf92c6aa7e476becd99 /skia/corecg/SkRegion.cpp
parent30fab79877b4bb067944b74d98346ac9bb6bfc7e (diff)
downloadchromium_src-52e935d04c59135739c3a68fb6e19d313dc6d5ad.zip
chromium_src-52e935d04c59135739c3a68fb6e19d313dc6d5ad.tar.gz
chromium_src-52e935d04c59135739c3a68fb6e19d313dc6d5ad.tar.bz2
New drop of Skia. This is up to CL 121320.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6925 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia/corecg/SkRegion.cpp')
-rw-r--r--skia/corecg/SkRegion.cpp42
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();)