aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkRasterClip.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/SkRasterClip.h')
-rw-r--r--src/core/SkRasterClip.h40
1 files changed, 35 insertions, 5 deletions
diff --git a/src/core/SkRasterClip.h b/src/core/SkRasterClip.h
index 0dc84e491f..1e50e04539 100644
--- a/src/core/SkRasterClip.h
+++ b/src/core/SkRasterClip.h
@@ -13,6 +13,39 @@
class SkRRect;
+class SkConservativeClip {
+ SkIRect fBounds;
+ const SkIRect* fClipRestrictionRect;
+
+ inline void applyClipRestriction(SkRegion::Op op, SkIRect* bounds) {
+ if (op >= SkRegion::kUnion_Op && fClipRestrictionRect
+ && !fClipRestrictionRect->isEmpty()) {
+ if (!bounds->intersect(*fClipRestrictionRect)) {
+ bounds->setEmpty();
+ }
+ }
+ }
+
+public:
+ SkConservativeClip() : fBounds(SkIRect::MakeEmpty()), fClipRestrictionRect(nullptr) {}
+
+ bool isEmpty() const { return fBounds.isEmpty(); }
+ bool isRect() const { return true; }
+ const SkIRect& getBounds() const { return fBounds; }
+
+ void setEmpty() { fBounds.setEmpty(); }
+ void setRect(const SkIRect& r) { fBounds = r; }
+ void setDeviceClipRestriction(const SkIRect* rect) {
+ fClipRestrictionRect = rect;
+ }
+
+ void op(const SkRect&, const SkMatrix&, const SkIRect& limit, SkRegion::Op, bool isAA);
+ void op(const SkRRect&, const SkMatrix&, const SkIRect& limit, SkRegion::Op, bool isAA);
+ void op(const SkPath&, const SkMatrix&, const SkIRect& limit, SkRegion::Op, bool isAA);
+ void op(const SkRegion&, SkRegion::Op);
+ void op(const SkIRect&, SkRegion::Op);
+};
+
/**
* Wraps a SkRegion and SkAAClip, so we have a single object that can represent either our
* BW or antialiased clips.
@@ -24,8 +57,8 @@ class SkRRect;
*/
class SkRasterClip {
public:
- SkRasterClip(bool forceConservativeRects = false);
- SkRasterClip(const SkIRect&, bool forceConservativeRects = false);
+ SkRasterClip();
+ SkRasterClip(const SkIRect&);
SkRasterClip(const SkRegion&);
SkRasterClip(const SkRasterClip&);
~SkRasterClip();
@@ -37,8 +70,6 @@ public:
return !(*this == other);
}
- bool isForceConservativeRects() const { return fForceConservativeRects; }
-
bool isBW() const { return fIsBW; }
bool isAA() const { return !fIsBW; }
const SkRegion& bwRgn() const { SkASSERT(fIsBW); return fBW; }
@@ -101,7 +132,6 @@ public:
private:
SkRegion fBW;
SkAAClip fAA;
- bool fForceConservativeRects;
bool fIsBW;
// these 2 are caches based on querying the right obj based on fIsBW
bool fIsEmpty;