diff options
author | 2011-10-10 19:35:47 +0000 | |
---|---|---|
committer | 2011-10-10 19:35:47 +0000 | |
commit | f3c1da1e977a0e02535af71749fe9e92665ed51e (patch) | |
tree | ee10dab8b361cf102c03a9655989ec0985344971 /src | |
parent | 82d344a28def5397cbe6dccad438e40fa7f39d0d (diff) |
add setRegion and doAA parameter to setPath
git-svn-id: http://skia.googlecode.com/svn/trunk@2450 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkAAClip.cpp | 28 | ||||
-rw-r--r-- | 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); |