Add a method in SkCanvas to set "hard" clip bounds.
Add SkCanvas::setBoundRect, which sets the max clip rectangle,
which can be replaced by clipRect, clipRRect and clipPath.
BUG=skia:
Change-Id: Ie39eb1715214971576e7a1dda760c6997a7e0208
Reviewed-on: https://skia-review.googlesource.com/5359
Commit-Queue: Stan Iliev <stani@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
diff --git a/src/core/SkRasterClip.cpp b/src/core/SkRasterClip.cpp
index 1090c66..a9e043f 100644
--- a/src/core/SkRasterClip.cpp
+++ b/src/core/SkRasterClip.cpp
@@ -21,6 +21,7 @@
fIsEmpty = src.isEmpty();
fIsRect = src.isRect();
+ fClipRestrictionRect = src.fClipRestrictionRect;
SkDEBUGCODE(this->validate();)
}
@@ -185,8 +186,10 @@
return this->updateCacheAndReturnNonEmpty();
}
-bool SkRasterClip::op(const SkRRect& rrect, const SkMatrix& matrix, const SkIRect& bounds,
+bool SkRasterClip::op(const SkRRect& rrect, const SkMatrix& matrix, const SkIRect& devBounds,
SkRegion::Op op, bool doAA) {
+ SkIRect bounds(devBounds);
+ this->applyClipRestriction(op, &bounds);
if (fForceConservativeRects) {
return this->op(rrect.getBounds(), matrix, bounds, op, doAA);
}
@@ -197,9 +200,11 @@
return this->op(path, matrix, bounds, op, doAA);
}
-bool SkRasterClip::op(const SkPath& path, const SkMatrix& matrix, const SkIRect& bounds,
+bool SkRasterClip::op(const SkPath& path, const SkMatrix& matrix, const SkIRect& devBounds,
SkRegion::Op op, bool doAA) {
AUTO_RASTERCLIP_VALIDATE(*this);
+ SkIRect bounds(devBounds);
+ this->applyClipRestriction(op, &bounds);
if (fForceConservativeRects) {
SkIRect ir;
@@ -321,12 +326,14 @@
return x - SkScalarFloorToScalar(x) < domain;
}
-bool SkRasterClip::op(const SkRect& localRect, const SkMatrix& matrix, const SkIRect& bounds,
+bool SkRasterClip::op(const SkRect& localRect, const SkMatrix& matrix, const SkIRect& devBounds,
SkRegion::Op op, bool doAA) {
AUTO_RASTERCLIP_VALIDATE(*this);
SkRect devRect;
if (fForceConservativeRects) {
+ SkIRect bounds(devBounds);
+ this->applyClipRestriction(op, &bounds);
SkIRect ir;
switch (mutate_conservative_op(&op, false)) {
case kDoNothing_MutateResult:
@@ -346,7 +353,7 @@
SkPath path;
path.addRect(localRect);
path.setIsVolatile(true);
- return this->op(path, matrix, bounds, op, doAA);
+ return this->op(path, matrix, devBounds, op, doAA);
}
matrix.mapRect(&devRect, localRect);
@@ -363,11 +370,13 @@
if (fIsBW && !doAA) {
SkIRect ir;
devRect.round(&ir);
+ this->applyClipRestriction(op, &ir);
(void)fBW.op(ir, op);
} else {
if (fIsBW) {
this->convertToAA();
}
+ this->applyClipRestriction(op, &devRect);
(void)fAA.op(devRect, op, doAA);
}
return this->updateCacheAndReturnNonEmpty();