Change signatures of filter bounds methods to return a rect.
Change filterBounds(), onFilterBounds() and onFilterNodeBounds() and computeFastBounds() to
return the destination rectangle. There was no code path that could
return false, and returning rects by value is ok now.
BUG=skia:5094
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1823573003
Review URL: https://codereview.chromium.org/1823573003
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index 7940203..ab4767c 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -265,32 +265,27 @@
return true;
}
-void SkDisplacementMapEffect::computeFastBounds(const SkRect& src, SkRect* dst) const {
- if (this->getColorInput()) {
- this->getColorInput()->computeFastBounds(src, dst);
- } else {
- *dst = src;
- }
- dst->outset(SkScalarAbs(fScale) * SK_ScalarHalf, SkScalarAbs(fScale) * SK_ScalarHalf);
+SkRect SkDisplacementMapEffect::computeFastBounds(const SkRect& src) const {
+ SkRect bounds = this->getColorInput() ? this->getColorInput()->computeFastBounds(src) : src;
+ bounds.outset(SkScalarAbs(fScale) * SK_ScalarHalf, SkScalarAbs(fScale) * SK_ScalarHalf);
+ return bounds;
}
-void SkDisplacementMapEffect::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
- SkIRect* dst, MapDirection) const {
- *dst = src;
+SkIRect SkDisplacementMapEffect::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
+ MapDirection) const {
SkVector scale = SkVector::Make(fScale, fScale);
ctm.mapVectors(&scale, 1);
- dst->outset(SkScalarCeilToInt(SkScalarAbs(scale.fX) * SK_ScalarHalf),
- SkScalarCeilToInt(SkScalarAbs(scale.fY) * SK_ScalarHalf));
+ return src.makeOutset(SkScalarCeilToInt(SkScalarAbs(scale.fX) * SK_ScalarHalf),
+ SkScalarCeilToInt(SkScalarAbs(scale.fY) * SK_ScalarHalf));
}
-bool SkDisplacementMapEffect::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
- SkIRect* dst, MapDirection direction) const {
+SkIRect SkDisplacementMapEffect::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
+ MapDirection direction) const {
// Recurse only into color input.
if (this->getColorInput()) {
- return this->getColorInput()->filterBounds(src, ctm, dst, direction);
+ return this->getColorInput()->filterBounds(src, ctm, direction);
}
- *dst = src;
- return true;
+ return src;
}
#ifndef SK_IGNORE_TO_STRING