aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-10-10 21:24:37 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-10-10 21:24:37 +0000
commit5e2457ef2eba0c3f2e4c8fc89be7f36659e4f3b1 (patch)
tree3418fe75b782bb62645295c1d0b51d60a85dac1b
parentd1e3c5fde3f2ed309273cb08dbba2309b13e527f (diff)
add getTotalClipBounds() as a partial replacement for getTotalClip. This can be
faster than getTotalClip, since it doesn't need to compute the actual complex region for the answer. git-svn-id: http://skia.googlecode.com/svn/trunk@2452 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--include/core/SkCanvas.h8
-rw-r--r--src/core/SkCanvas.cpp7
2 files changed, 15 insertions, 0 deletions
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 6ca9fa08a9..73fd7200ad 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -768,6 +768,14 @@ public:
const SkRegion& getTotalClip() const;
/**
+ * Return true if the current clip is non-empty.
+ *
+ * If bounds is not NULL, set it to the bounds of the current clip
+ * in global coordinates.
+ */
+ bool getTotalClipBounds(SkIRect* bounds) const;
+
+ /**
* Return the current clipstack. This mirrors the result in getTotalClip()
* but is represented as a stack of geometric clips + region-ops.
*/
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index f563cd1211..89c6e5b79d 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1151,6 +1151,13 @@ SkCanvas::ClipType SkCanvas::getClipType() const {
return kComplex_ClipType;
}
+bool SkCanvas::getTotalClipBounds(SkIRect* bounds) const {
+ if (bounds) {
+ *bounds = fMCRec->fRegion->getBounds();
+ }
+ return !fMCRec->fRegion->isEmpty();
+}
+
const SkRegion& SkCanvas::getTotalClip() const {
return *fMCRec->fRegion;
}