diff options
Diffstat (limited to 'src/core')
-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 |
7 files changed, 51 insertions, 73 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; |