diff options
author | 2016-03-21 14:51:59 -0700 | |
---|---|---|
committer | 2016-03-21 14:51:59 -0700 | |
commit | e5e79840ef38ab1d3f03abcf1b2df66fb9940018 (patch) | |
tree | 1401c257dfc5f6658c5911499d9037eaee9bacb5 /src | |
parent | 989da4a32cd6823359f31c971c3b3f31425e905e (diff) |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkCanvas.cpp | 2 | ||||
-rw-r--r-- | src/core/SkImageFilter.cpp | 82 | ||||
-rw-r--r-- | src/core/SkLocalMatrixImageFilter.cpp | 6 | ||||
-rw-r--r-- | src/core/SkLocalMatrixImageFilter.h | 3 | ||||
-rw-r--r-- | src/core/SkMatrixImageFilter.cpp | 24 | ||||
-rw-r--r-- | src/core/SkMatrixImageFilter.h | 5 | ||||
-rw-r--r-- | src/core/SkPaint.cpp | 2 | ||||
-rw-r--r-- | src/effects/SkBlurImageFilter.cpp | 23 | ||||
-rw-r--r-- | src/effects/SkComposeImageFilter.cpp | 18 | ||||
-rw-r--r-- | src/effects/SkDisplacementMapEffect.cpp | 29 | ||||
-rw-r--r-- | src/effects/SkDropShadowImageFilter.cpp | 30 | ||||
-rw-r--r-- | src/effects/SkImageSource.cpp | 4 | ||||
-rw-r--r-- | src/effects/SkMatrixConvolutionImageFilter.cpp | 15 | ||||
-rw-r--r-- | src/effects/SkMorphologyImageFilter.cpp | 18 | ||||
-rw-r--r-- | src/effects/SkOffsetImageFilter.cpp | 18 | ||||
-rw-r--r-- | src/effects/SkTileImageFilter.cpp | 16 | ||||
-rw-r--r-- | src/gpu/GrLayerHoister.cpp | 2 |
17 files changed, 123 insertions, 174 deletions
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index 3acb9136e2..3efb44cc54 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -1077,7 +1077,7 @@ bool SkCanvas::clipRectBounds(const SkRect* bounds, SaveLayerFlags saveLayerFlag const SkMatrix& ctm = fMCRec->fMatrix; // this->getTotalMatrix() if (imageFilter) { - imageFilter->filterBounds(clipBounds, ctm, &clipBounds); + clipBounds = imageFilter->filterBounds(clipBounds, ctm); if (bounds && !imageFilter->canComputeFastBounds()) { bounds = nullptr; } diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp index 4ae839c3d4..1c223a5b28 100644 --- a/src/core/SkImageFilter.cpp +++ b/src/core/SkImageFilter.cpp @@ -290,47 +290,42 @@ bool SkImageFilter::filterInputDeprecated(int index, Proxy* proxy, const SkBitma return tmp->internal_getBM(result); } +#ifdef SK_SUPPORT_LEGACY_FILTERBOUNDS_RETURN bool SkImageFilter::filterBounds(const SkIRect& src, const SkMatrix& ctm, SkIRect* dst, MapDirection direction) const { - SkASSERT(dst); - SkIRect bounds; + *dst = filterBounds(src, ctm, direction); + return true; +} +#endif + +SkIRect SkImageFilter::filterBounds(const SkIRect& src, const SkMatrix& ctm, + MapDirection direction) const { if (kReverse_MapDirection == direction) { - this->onFilterNodeBounds(src, ctm, &bounds, direction); - return this->onFilterBounds(bounds, ctm, dst, direction); + SkIRect bounds = this->onFilterNodeBounds(src, ctm, direction); + return this->onFilterBounds(bounds, ctm, direction); } else { - SkIRect temp; - if (!this->onFilterBounds(src, ctm, &bounds, direction)) { - return false; - } - this->onFilterNodeBounds(bounds, ctm, &temp, direction); - this->getCropRect().applyTo(temp, ctm, dst); - return true; + SkIRect bounds = this->onFilterBounds(src, ctm, direction); + bounds = this->onFilterNodeBounds(bounds, ctm, direction); + SkIRect dst; + this->getCropRect().applyTo(bounds, ctm, &dst); + return dst; } } -void SkImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const { +SkRect SkImageFilter::computeFastBounds(const SkRect& src) const { if (0 == fInputCount) { - *dst = src; - return; - } - // We can't work directly on dst, since src and dst may alias. - SkRect combinedBounds; - if (this->getInput(0)) { - this->getInput(0)->computeFastBounds(src, &combinedBounds); - } else { - combinedBounds = src; + return src; } + SkRect combinedBounds = this->getInput(0) ? this->getInput(0)->computeFastBounds(src) : src; for (int i = 1; i < fInputCount; i++) { SkImageFilter* input = this->getInput(i); if (input) { - SkRect bounds; - input->computeFastBounds(src, &bounds); - combinedBounds.join(bounds); + combinedBounds.join(input->computeFastBounds(src)); } else { combinedBounds.join(src); } } - *dst = combinedBounds; + return combinedBounds; } bool SkImageFilter::canComputeFastBounds() const { @@ -442,8 +437,8 @@ bool SkImageFilter::asAColorFilter(SkColorFilter** filterPtr) const { bool SkImageFilter::applyCropRect(const Context& ctx, const SkIRect& srcBounds, SkIRect* dstBounds) const { - this->onFilterNodeBounds(srcBounds, ctx.ctm(), dstBounds, kForward_MapDirection); - fCropRect.applyTo(*dstBounds, ctx.ctm(), dstBounds); + SkIRect temp = this->onFilterNodeBounds(srcBounds, ctx.ctm(), kForward_MapDirection); + fCropRect.applyTo(temp, ctx.ctm(), dstBounds); // Intersect against the clip bounds, in case the crop rect has // grown the bounds beyond the original clip. This can happen for // example in tiling, where the clip is much smaller than the filtered @@ -458,8 +453,7 @@ bool SkImageFilter::applyCropRectDeprecated(const Context& ctx, Proxy* proxy, co SkIRect srcBounds; src.getBounds(&srcBounds); srcBounds.offset(*srcOffset); - SkIRect dstBounds; - this->onFilterNodeBounds(srcBounds, ctx.ctm(), &dstBounds, kForward_MapDirection); + SkIRect dstBounds = this->onFilterNodeBounds(srcBounds, ctx.ctm(), kForward_MapDirection); fCropRect.applyTo(dstBounds, ctx.ctm(), bounds); if (!bounds->intersect(ctx.clipBounds())) { return false; @@ -510,8 +504,7 @@ SkSpecialImage* SkImageFilter::applyCropRect(const Context& ctx, SkIRect srcBounds; srcBounds = SkIRect::MakeXYWH(srcOffset->fX, srcOffset->fY, src->width(), src->height()); - SkIRect dstBounds; - this->onFilterNodeBounds(srcBounds, ctx.ctm(), &dstBounds, kForward_MapDirection); + SkIRect dstBounds = this->onFilterNodeBounds(srcBounds, ctx.ctm(), kForward_MapDirection); fCropRect.applyTo(dstBounds, ctx.ctm(), bounds); if (!bounds->intersect(ctx.clipBounds())) { return nullptr; @@ -529,20 +522,16 @@ SkSpecialImage* SkImageFilter::applyCropRect(const Context& ctx, } } -bool SkImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm, - SkIRect* dst, MapDirection direction) const { +SkIRect SkImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm, + MapDirection direction) const { if (fInputCount < 1) { - *dst = src; - return true; + return src; } SkIRect totalBounds; for (int i = 0; i < fInputCount; ++i) { SkImageFilter* filter = this->getInput(i); - SkIRect rect = src; - if (filter && !filter->filterBounds(src, ctm, &rect, direction)) { - return false; - } + SkIRect rect = filter ? filter->filterBounds(src, ctm, direction) : src; if (0 == i) { totalBounds = rect; } else { @@ -550,22 +539,17 @@ bool SkImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm, } } - // don't modify dst until now, so we don't accidentally change it in the - // loop, but then return false on the next filter. - *dst = totalBounds; - return true; + return totalBounds; } -void SkImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix&, - SkIRect* dst, MapDirection) const { - *dst = src; +SkIRect SkImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix&, MapDirection) const { + return src; } SkImageFilter::Context SkImageFilter::mapContext(const Context& ctx) const { - SkIRect clipBounds; - this->onFilterNodeBounds(ctx.clipBounds(), ctx.ctm(), &clipBounds, - MapDirection::kReverse_MapDirection); + SkIRect clipBounds = this->onFilterNodeBounds(ctx.clipBounds(), ctx.ctm(), + MapDirection::kReverse_MapDirection); return Context(ctx.ctm(), clipBounds, ctx.cache()); } diff --git a/src/core/SkLocalMatrixImageFilter.cpp b/src/core/SkLocalMatrixImageFilter.cpp index 4a9dea35bb..3214d2d93b 100644 --- a/src/core/SkLocalMatrixImageFilter.cpp +++ b/src/core/SkLocalMatrixImageFilter.cpp @@ -45,9 +45,9 @@ bool SkLocalMatrixImageFilter::onFilterImageDeprecated(Proxy* proxy, const SkBit return this->filterInputDeprecated(0, proxy, src, localCtx, result, offset); } -bool SkLocalMatrixImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& matrix, - SkIRect* dst, MapDirection direction) const { - return this->getInput(0)->filterBounds(src, SkMatrix::Concat(matrix, fLocalM), dst, direction); +SkIRect SkLocalMatrixImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& matrix, + MapDirection direction) const { + return this->getInput(0)->filterBounds(src, SkMatrix::Concat(matrix, fLocalM), direction); } #ifndef SK_IGNORE_TO_STRING diff --git a/src/core/SkLocalMatrixImageFilter.h b/src/core/SkLocalMatrixImageFilter.h index f2fd062f6c..da49df4932 100644 --- a/src/core/SkLocalMatrixImageFilter.h +++ b/src/core/SkLocalMatrixImageFilter.h @@ -27,8 +27,7 @@ protected: void flatten(SkWriteBuffer&) const override; bool onFilterImageDeprecated(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result, SkIPoint* offset) const override; - bool onFilterBounds(const SkIRect& src, const SkMatrix&, SkIRect* dst, - MapDirection) const override; + SkIRect onFilterBounds(const SkIRect& src, const SkMatrix&, MapDirection) const override; private: SkLocalMatrixImageFilter(const SkMatrix& localM, SkImageFilter* input); diff --git a/src/core/SkMatrixImageFilter.cpp b/src/core/SkMatrixImageFilter.cpp index 5a585efffc..ec221fdcac 100644 --- a/src/core/SkMatrixImageFilter.cpp +++ b/src/core/SkMatrixImageFilter.cpp @@ -91,36 +91,32 @@ bool SkMatrixImageFilter::onFilterImageDeprecated(Proxy* proxy, return true; } -void SkMatrixImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const { - SkRect bounds = src; - if (getInput(0)) { - getInput(0)->computeFastBounds(src, &bounds); - } - fTransform.mapRect(dst, bounds); +SkRect SkMatrixImageFilter::computeFastBounds(const SkRect& src) const { + SkRect bounds = this->getInput(0) ? this->getInput(0)->computeFastBounds(src) : src; + SkRect dst; + fTransform.mapRect(&dst, bounds); + return dst; } -void SkMatrixImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm, - SkIRect* dst, MapDirection direction) const { +SkIRect SkMatrixImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm, + MapDirection direction) const { SkMatrix matrix; if (!ctm.invert(&matrix)) { - *dst = src; - return; + return src; } if (kForward_MapDirection == direction) { matrix.postConcat(fTransform); } else { SkMatrix transformInverse; if (!fTransform.invert(&transformInverse)) { - *dst = src; - return; + return src; } matrix.postConcat(transformInverse); } matrix.postConcat(ctm); SkRect floatBounds; matrix.mapRect(&floatBounds, SkRect::Make(src)); - SkIRect bounds = floatBounds.roundOut(); - *dst = bounds; + return floatBounds.roundOut(); } #ifndef SK_IGNORE_TO_STRING diff --git a/src/core/SkMatrixImageFilter.h b/src/core/SkMatrixImageFilter.h index 4d5b52d127..0631a8b8c4 100644 --- a/src/core/SkMatrixImageFilter.h +++ b/src/core/SkMatrixImageFilter.h @@ -33,7 +33,7 @@ public: SkImageFilter* input = nullptr); virtual ~SkMatrixImageFilter(); - void computeFastBounds(const SkRect&, SkRect*) const override; + SkRect computeFastBounds(const SkRect&) const override; SK_TO_STRING_OVERRIDE() SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMatrixImageFilter) @@ -46,8 +46,7 @@ protected: bool onFilterImageDeprecated(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result, SkIPoint* loc) const override; - void onFilterNodeBounds(const SkIRect& src, const SkMatrix&, - SkIRect* dst, MapDirection) const override; + SkIRect onFilterNodeBounds(const SkIRect& src, const SkMatrix&, MapDirection) const override; private: SkMatrix fTransform; diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp index 5baabd3f1d..19bdcaf0aa 100644 --- a/src/core/SkPaint.cpp +++ b/src/core/SkPaint.cpp @@ -2044,7 +2044,7 @@ const SkRect& SkPaint::doComputeFastBounds(const SkRect& origSrc, } if (this->getImageFilter()) { - this->getImageFilter()->computeFastBounds(*storage, storage); + *storage = this->getImageFilter()->computeFastBounds(*storage); } return *storage; diff --git a/src/effects/SkBlurImageFilter.cpp b/src/effects/SkBlurImageFilter.cpp index 249e69779d..80467063bc 100644 --- a/src/effects/SkBlurImageFilter.cpp +++ b/src/effects/SkBlurImageFilter.cpp @@ -179,23 +179,18 @@ bool SkBlurImageFilter::onFilterImageDeprecated(Proxy* proxy, } -void SkBlurImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const { - if (this->getInput(0)) { - this->getInput(0)->computeFastBounds(src, dst); - } else { - *dst = src; - } - - dst->outset(SkScalarMul(fSigma.width(), SkIntToScalar(3)), - SkScalarMul(fSigma.height(), SkIntToScalar(3))); +SkRect SkBlurImageFilter::computeFastBounds(const SkRect& src) const { + SkRect bounds = this->getInput(0) ? this->getInput(0)->computeFastBounds(src) : src; + bounds.outset(SkScalarMul(fSigma.width(), SkIntToScalar(3)), + SkScalarMul(fSigma.height(), SkIntToScalar(3))); + return bounds; } -void SkBlurImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm, - SkIRect* dst, MapDirection) const { - *dst = src; +SkIRect SkBlurImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm, + MapDirection) const { SkVector sigma = map_sigma(fSigma, ctm); - dst->outset(SkScalarCeilToInt(SkScalarMul(sigma.x(), SkIntToScalar(3))), - SkScalarCeilToInt(SkScalarMul(sigma.y(), SkIntToScalar(3)))); + return src.makeOutset(SkScalarCeilToInt(SkScalarMul(sigma.x(), SkIntToScalar(3))), + SkScalarCeilToInt(SkScalarMul(sigma.y(), SkIntToScalar(3)))); } bool SkBlurImageFilter::filterImageGPUDeprecated(Proxy* proxy, const SkBitmap& src, diff --git a/src/effects/SkComposeImageFilter.cpp b/src/effects/SkComposeImageFilter.cpp index b9216611ab..86a4d50389 100644 --- a/src/effects/SkComposeImageFilter.cpp +++ b/src/effects/SkComposeImageFilter.cpp @@ -12,13 +12,11 @@ #include "SkWriteBuffer.h" -void SkComposeImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const { +SkRect SkComposeImageFilter::computeFastBounds(const SkRect& src) const { SkImageFilter* outer = getInput(0); SkImageFilter* inner = getInput(1); - SkRect tmp; - inner->computeFastBounds(src, &tmp); - outer->computeFastBounds(tmp, dst); + return outer->computeFastBounds(inner->computeFastBounds(src)); } SkSpecialImage* SkComposeImageFilter::onFilterImage(SkSpecialImage* source, const Context& ctx, @@ -27,7 +25,7 @@ SkSpecialImage* SkComposeImageFilter::onFilterImage(SkSpecialImage* source, cons // filter, so that the inner filter produces the pixels that the outer // filter requires as input. This matters if the outer filter moves pixels. SkIRect innerClipBounds; - getInput(0)->filterBounds(ctx.clipBounds(), ctx.ctm(), &innerClipBounds); + innerClipBounds = getInput(0)->filterBounds(ctx.clipBounds(), ctx.ctm()); Context innerContext(ctx.ctm(), innerClipBounds, ctx.cache()); SkIPoint innerOffset = SkIPoint::Make(0, 0); SkAutoTUnref<SkSpecialImage> inner(this->filterInput(1, source, innerContext, &innerOffset)); @@ -51,16 +49,12 @@ SkSpecialImage* SkComposeImageFilter::onFilterImage(SkSpecialImage* source, cons return outer.release(); } -bool SkComposeImageFilter::onFilterBounds(const SkIRect& src, - const SkMatrix& ctm, - SkIRect* dst, - MapDirection direction) const { +SkIRect SkComposeImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm, + MapDirection direction) const { SkImageFilter* outer = this->getInput(0); SkImageFilter* inner = this->getInput(1); - SkIRect tmp; - return inner->filterBounds(src, ctm, &tmp, direction) && - outer->filterBounds(tmp, ctm, dst, direction); + return outer->filterBounds(inner->filterBounds(src, ctm, direction), ctm, direction); } SkFlattenable* SkComposeImageFilter::CreateProc(SkReadBuffer& buffer) { diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp index 7940203bdd..ab4767c64b 100644 --- a/src/effects/SkDisplacementMapEffect.cpp +++ b/src/effects/SkDisplacementMapEffect.cpp @@ -265,32 +265,27 @@ bool SkDisplacementMapEffect::onFilterImageDeprecated(Proxy* proxy, 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 diff --git a/src/effects/SkDropShadowImageFilter.cpp b/src/effects/SkDropShadowImageFilter.cpp index e2e72c1097..deece35b38 100644 --- a/src/effects/SkDropShadowImageFilter.cpp +++ b/src/effects/SkDropShadowImageFilter.cpp @@ -99,41 +99,37 @@ bool SkDropShadowImageFilter::onFilterImageDeprecated(Proxy* proxy, const SkBitm return true; } -void SkDropShadowImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const { - if (getInput(0)) { - getInput(0)->computeFastBounds(src, dst); - } else { - *dst = src; - } - - SkRect shadowBounds = *dst; +SkRect SkDropShadowImageFilter::computeFastBounds(const SkRect& src) const { + SkRect bounds = this->getInput(0) ? this->getInput(0)->computeFastBounds(src) : src; + SkRect shadowBounds = bounds; shadowBounds.offset(fDx, fDy); shadowBounds.outset(SkScalarMul(fSigmaX, SkIntToScalar(3)), SkScalarMul(fSigmaY, SkIntToScalar(3))); if (fShadowMode == kDrawShadowAndForeground_ShadowMode) { - dst->join(shadowBounds); + bounds.join(shadowBounds); } else { - *dst = shadowBounds; + bounds = shadowBounds; } + return bounds; } -void SkDropShadowImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm, - SkIRect* dst, MapDirection direction) const { - *dst = src; +SkIRect SkDropShadowImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm, + MapDirection direction) const { SkVector offsetVec = SkVector::Make(fDx, fDy); if (kReverse_MapDirection == direction) { offsetVec.negate(); } ctm.mapVectors(&offsetVec, 1); - dst->offset(SkScalarCeilToInt(offsetVec.x()), - SkScalarCeilToInt(offsetVec.y())); + SkIRect dst = src.makeOffset(SkScalarCeilToInt(offsetVec.x()), + SkScalarCeilToInt(offsetVec.y())); SkVector sigma = SkVector::Make(fSigmaX, fSigmaY); ctm.mapVectors(&sigma, 1); - dst->outset(SkScalarCeilToInt(SkScalarMul(sigma.x(), SkIntToScalar(3))), + dst.outset(SkScalarCeilToInt(SkScalarMul(sigma.x(), SkIntToScalar(3))), SkScalarCeilToInt(SkScalarMul(sigma.y(), SkIntToScalar(3)))); if (fShadowMode == kDrawShadowAndForeground_ShadowMode) { - dst->join(src); + dst.join(src); } + return dst; } #ifndef SK_IGNORE_TO_STRING diff --git a/src/effects/SkImageSource.cpp b/src/effects/SkImageSource.cpp index c0a8deebf9..d63eda989f 100644 --- a/src/effects/SkImageSource.cpp +++ b/src/effects/SkImageSource.cpp @@ -113,8 +113,8 @@ SkSpecialImage* SkImageSource::onFilterImage(SkSpecialImage* source, const Conte return surf->makeImageSnapshot().release(); } -void SkImageSource::computeFastBounds(const SkRect& src, SkRect* dst) const { - *dst = fDstRect; +SkRect SkImageSource::computeFastBounds(const SkRect& src) const { + return fDstRect; } #ifndef SK_IGNORE_TO_STRING diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp index 0d14caf131..7a25f5f7eb 100644 --- a/src/effects/SkMatrixConvolutionImageFilter.cpp +++ b/src/effects/SkMatrixConvolutionImageFilter.cpp @@ -323,17 +323,18 @@ bool SkMatrixConvolutionImageFilter::onFilterImageDeprecated(Proxy* proxy, return true; } -void SkMatrixConvolutionImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm, - SkIRect* dst, MapDirection direction) const { - *dst = src; +SkIRect SkMatrixConvolutionImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm, + MapDirection direction) const { + SkIRect dst = src; int w = fKernelSize.width() - 1, h = fKernelSize.height() - 1; - dst->fRight += w; - dst->fBottom += h; + dst.fRight += w; + dst.fBottom += h; if (kReverse_MapDirection == direction) { - dst->offset(-fKernelOffset); + dst.offset(-fKernelOffset); } else { - dst->offset(fKernelOffset - SkIPoint::Make(w, h)); + dst.offset(fKernelOffset - SkIPoint::Make(w, h)); } + return dst; } bool SkMatrixConvolutionImageFilter::canComputeFastBounds() const { diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp index 61b0c339c9..204f4f3a62 100644 --- a/src/effects/SkMorphologyImageFilter.cpp +++ b/src/effects/SkMorphologyImageFilter.cpp @@ -142,22 +142,18 @@ bool SkDilateImageFilter::onFilterImageDeprecated(Proxy* proxy, proxy, source, ctx, dst, offset); } -void SkMorphologyImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const { - if (this->getInput(0)) { - this->getInput(0)->computeFastBounds(src, dst); - } else { - *dst = src; - } - dst->outset(SkIntToScalar(fRadius.width()), SkIntToScalar(fRadius.height())); +SkRect SkMorphologyImageFilter::computeFastBounds(const SkRect& src) const { + SkRect bounds = this->getInput(0) ? this->getInput(0)->computeFastBounds(src) : src; + bounds.outset(SkIntToScalar(fRadius.width()), SkIntToScalar(fRadius.height())); + return bounds; } -void SkMorphologyImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm, - SkIRect* dst, MapDirection) const { - *dst = src; +SkIRect SkMorphologyImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm, + MapDirection) const { SkVector radius = SkVector::Make(SkIntToScalar(this->radius().width()), SkIntToScalar(this->radius().height())); ctm.mapVectors(&radius, 1); - dst->outset(SkScalarCeilToInt(radius.x()), SkScalarCeilToInt(radius.y())); + return src.makeOutset(SkScalarCeilToInt(radius.x()), SkScalarCeilToInt(radius.y())); } SkFlattenable* SkErodeImageFilter::CreateProc(SkReadBuffer& buffer) { diff --git a/src/effects/SkOffsetImageFilter.cpp b/src/effects/SkOffsetImageFilter.cpp index f3d2bb0c58..8e4b87881d 100644 --- a/src/effects/SkOffsetImageFilter.cpp +++ b/src/effects/SkOffsetImageFilter.cpp @@ -65,25 +65,21 @@ SkSpecialImage* SkOffsetImageFilter::onFilterImage(SkSpecialImage* source, } } -void SkOffsetImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const { - if (getInput(0)) { - getInput(0)->computeFastBounds(src, dst); - } else { - *dst = src; - } - dst->offset(fOffset.fX, fOffset.fY); +SkRect SkOffsetImageFilter::computeFastBounds(const SkRect& src) const { + SkRect bounds = this->getInput(0) ? this->getInput(0)->computeFastBounds(src) : src; + bounds.offset(fOffset.fX, fOffset.fY); + return bounds; } -void SkOffsetImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm, - SkIRect* dst, MapDirection direction) const { +SkIRect SkOffsetImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm, + MapDirection direction) const { SkVector vec; ctm.mapVectors(&vec, &fOffset, 1); if (kReverse_MapDirection == direction) { vec.negate(); } - *dst = src; - dst->offset(SkScalarCeilToInt(vec.fX), SkScalarCeilToInt(vec.fY)); + return src.makeOffset(SkScalarCeilToInt(vec.fX), SkScalarCeilToInt(vec.fY)); } SkFlattenable* SkOffsetImageFilter::CreateProc(SkReadBuffer& buffer) { diff --git a/src/effects/SkTileImageFilter.cpp b/src/effects/SkTileImageFilter.cpp index dff8e9bbfc..e6b561dec4 100644 --- a/src/effects/SkTileImageFilter.cpp +++ b/src/effects/SkTileImageFilter.cpp @@ -106,22 +106,20 @@ bool SkTileImageFilter::onFilterImageDeprecated(Proxy* proxy, const SkBitmap& sr return true; } -void SkTileImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm, - SkIRect* dst, MapDirection direction) const { +SkIRect SkTileImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm, + MapDirection direction) const { SkRect rect = kReverse_MapDirection == direction ? fSrcRect : fDstRect; ctm.mapRect(&rect); - rect.roundOut(dst); + return rect.roundOut(); } -bool SkTileImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm, - SkIRect* dst, MapDirection direction) const { +SkIRect SkTileImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix&, MapDirection) const { // Don't recurse into inputs. - *dst = src; - return true; + return src; } -void SkTileImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const { - *dst = fDstRect; +SkRect SkTileImageFilter::computeFastBounds(const SkRect& src) const { + return fDstRect; } SkFlattenable* SkTileImageFilter::CreateProc(SkReadBuffer& buffer) { diff --git a/src/gpu/GrLayerHoister.cpp b/src/gpu/GrLayerHoister.cpp index 0fef0ef335..5638d8a6b2 100644 --- a/src/gpu/GrLayerHoister.cpp +++ b/src/gpu/GrLayerHoister.cpp @@ -93,7 +93,7 @@ static bool compute_source_rect(const SkLayerInfo::BlockInfo& info, const SkMatr totMat.preConcat(info.fLocalMat); if (info.fPaint && info.fPaint->getImageFilter()) { - info.fPaint->getImageFilter()->filterBounds(clipBounds, totMat, &clipBounds); + clipBounds = info.fPaint->getImageFilter()->filterBounds(clipBounds, totMat); } if (!info.fSrcBounds.isEmpty()) { |