From 754de5f65b466f721d952a379194cc94de376f42 Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Mon, 24 Feb 2014 19:38:20 +0000 Subject: [PATCH] add isClipEmpty() -- encourage clients to call this rather than checking clipFoo() results BUG=skia: R=robertphillips@google.com Review URL: https://codereview.chromium.org/177073006 git-svn-id: http://skia.googlecode.com/svn/trunk@13568 2bbb7eff-a529-9590-31e7-b0007b416f81 --- include/core/SkCanvas.h | 9 +++++++++ src/core/SkCanvas.cpp | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h index 754fd167a3..e639212e38 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -972,6 +972,15 @@ public: ////////////////////////////////////////////////////////////////////////// + /** + * Return true if the current clip is empty (i.e. nothing will draw). + * Note: this is not always a free call, so it should not be used + * more often than necessary. However, once the canvas has computed this + * result, subsequent calls will be cheap (until the clip state changes, + * which can happen on any clip..() or restore() call. + */ + bool isClipEmpty() const; + /** Return the current matrix on the canvas. This does not account for the translate in any of the devices. @return The current matrix on the canvas. diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index 1e9dda3098..8159adf0ee 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -1484,6 +1484,10 @@ void SkCanvas::replayClips(ClipVisitor* visitor) const { /////////////////////////////////////////////////////////////////////////////// +bool SkCanvas::isClipEmpty() const { + return fMCRec->fRasterClip->isEmpty(); +} + bool SkCanvas::quickReject(const SkRect& rect) const { if (!rect.isFinite())