From f3c1da1e977a0e02535af71749fe9e92665ed51e Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Mon, 10 Oct 2011 19:35:47 +0000 Subject: add setRegion and doAA parameter to setPath git-svn-id: http://skia.googlecode.com/svn/trunk@2450 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/core/SkAAClip.cpp | 28 ++++++++++++++++++++++++---- src/core/SkAAClip.h | 5 +++-- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/core/SkAAClip.cpp b/src/core/SkAAClip.cpp index 3e740313ab..0dbdd0fbd8 100644 --- a/src/core/SkAAClip.cpp +++ b/src/core/SkAAClip.cpp @@ -210,14 +210,30 @@ bool SkAAClip::setRect(const SkIRect& bounds) { return this->setPath(path); } -bool SkAAClip::setRect(const SkRect& r) { +bool SkAAClip::setRect(const SkRect& r, bool doAA) { if (r.isEmpty()) { return this->setEmpty(); } SkPath path; path.addRect(r); - return this->setPath(path); + return this->setPath(path, NULL, doAA); +} + +bool SkAAClip::setRegion(const SkRegion& rgn) { + if (rgn.isEmpty()) { + return this->setEmpty(); + } + if (rgn.isRect()) { + return this->setRect(rgn.getBounds()); + } + + SkAAClip clip; + SkRegion::Iterator iter(rgn); + for (; !iter.done(); iter.next()) { + clip.op(iter.rect(), SkRegion::kUnion_Op); + } + this->swap(clip); } /////////////////////////////////////////////////////////////////////////////// @@ -544,7 +560,7 @@ private: } }; -bool SkAAClip::setPath(const SkPath& path, const SkRegion* clip) { +bool SkAAClip::setPath(const SkPath& path, const SkRegion* clip, bool doAA) { if (clip && clip->isEmpty()) { return this->setEmpty(); } @@ -567,7 +583,11 @@ bool SkAAClip::setPath(const SkPath& path, const SkRegion* clip) { Builder builder(ibounds); BuilderBlitter blitter(&builder); - SkScan::AntiFillPath(path, *clip, &blitter, true); + if (doAA) { + SkScan::AntiFillPath(path, *clip, &blitter, true); + } else { + SkScan::FillPath(path, *clip, &blitter); + } this->freeRuns(); fBounds = ibounds; diff --git a/src/core/SkAAClip.h b/src/core/SkAAClip.h index dadf951e51..13f414d206 100644 --- a/src/core/SkAAClip.h +++ b/src/core/SkAAClip.h @@ -31,8 +31,9 @@ public: bool setEmpty(); bool setRect(const SkIRect&); - bool setRect(const SkRect&); - bool setPath(const SkPath&, const SkRegion* clip = NULL); + bool setRect(const SkRect&, bool doAA = true); + bool setPath(const SkPath&, const SkRegion* clip = NULL, bool doAA = true); + bool setRegion(const SkRegion&); bool set(const SkAAClip&); bool op(const SkAAClip&, const SkAAClip&, SkRegion::Op); -- cgit v1.2.3