diff --git a/src/core/SkRasterClip.cpp b/src/core/SkRasterClip.cpp index 0f9d3f9d1b..b6a8926684 100644 --- a/src/core/SkRasterClip.cpp +++ b/src/core/SkRasterClip.cpp @@ -12,6 +12,12 @@ SkRasterClip::SkRasterClip() { fIsBW = true; } +SkRasterClip::SkRasterClip(const SkIRect& bounds) : fBW(bounds) { + fIsBW = true; +} + +SkRasterClip::~SkRasterClip() {} + bool SkRasterClip::isEmpty() const { return fIsBW ? fBW.isEmpty() : fAA.isEmpty(); } @@ -35,7 +41,7 @@ bool SkRasterClip::setEmpty() { return false; } -bool SkRasterClip::setIRect(const SkIRect& rect) { +bool SkRasterClip::setRect(const SkIRect& rect) { fIsBW = true; fAA.setEmpty(); return fBW.setRect(rect); @@ -76,6 +82,16 @@ bool SkRasterClip::op(const SkIRect& rect, SkRegion::Op op) { return fIsBW ? fBW.op(rect, op) : fAA.op(rect, op); } +bool SkRasterClip::op(const SkRegion& rgn, SkRegion::Op op) { + if (fIsBW) { + return fBW.op(rgn, op); + } else { + SkAAClip tmp; + tmp.setRegion(rgn); + return fAA.op(tmp, op); + } +} + bool SkRasterClip::op(const SkRasterClip& clip, SkRegion::Op op) { if (this->isBW() && clip.isBW()) { return fBW.op(clip.fBW, op); @@ -96,6 +112,13 @@ bool SkRasterClip::op(const SkRasterClip& clip, SkRegion::Op op) { } } +const SkRegion& SkRasterClip::forceGetBW() { + if (!fIsBW) { + fBW.setRect(fAA.getBounds()); + } + return fBW; +} + void SkRasterClip::convertToAA() { SkASSERT(fIsBW); fAA.setRegion(fBW); diff --git a/src/core/SkRasterClip.h b/src/core/SkRasterClip.h index 77e6baa975..9a335d6e13 100644 --- a/src/core/SkRasterClip.h +++ b/src/core/SkRasterClip.h @@ -14,6 +14,7 @@ class SkRasterClip { public: SkRasterClip(); + SkRasterClip(const SkIRect&); SkRasterClip(const SkRasterClip&); ~SkRasterClip(); @@ -26,18 +27,21 @@ public: const SkIRect& getBounds() const; bool setEmpty(); - bool setIRect(const SkIRect&); + bool setRect(const SkIRect&); bool setPath(const SkPath& path, const SkRegion& clip, bool doAA); bool setPath(const SkPath& path, const SkIRect& clip, bool doAA); bool setPath(const SkPath& path, const SkRasterClip&, bool doAA); bool op(const SkIRect&, SkRegion::Op); + bool op(const SkRegion&, SkRegion::Op); bool op(const SkRasterClip&, SkRegion::Op); const SkRegion& bwRgn() const { SkASSERT(fIsBW); return fBW; } const SkAAClip& aaRgn() const { SkASSERT(!fIsBW); return fAA; } + const SkRegion& forceGetBW(); + private: SkRegion fBW; SkAAClip fAA;