diff options
-rw-r--r-- | src/core/SkMaskBlurFilter.cpp | 6 | ||||
-rw-r--r-- | src/core/SkMaskBlurFilter.h | 3 | ||||
-rw-r--r-- | src/effects/SkBlurMask.cpp | 3 |
3 files changed, 11 insertions, 1 deletions
diff --git a/src/core/SkMaskBlurFilter.cpp b/src/core/SkMaskBlurFilter.cpp index 0f0286354c..42837f79a9 100644 --- a/src/core/SkMaskBlurFilter.cpp +++ b/src/core/SkMaskBlurFilter.cpp @@ -70,6 +70,10 @@ SkMaskBlurFilter::SkMaskBlurFilter(double sigmaW, double sigmaH) , fBuffer2{skstd::make_unique_default<uint32_t[]>(bufferSize(2))} { } +bool SkMaskBlurFilter::hasNoBlur() const { + return fInfoW.weight() <= 1 && fInfoH.weight() <= 1; +} + SkIPoint SkMaskBlurFilter::blur(const SkMask& src, SkMask* dst) const { uint64_t weightW = fInfoW.weight(); @@ -146,7 +150,7 @@ SkIPoint SkMaskBlurFilter::blur(const SkMask& src, SkMask* dst) const { } } else { // Copy to dst. No Blur. - + SkASSERT(false); // should not get here for (size_t y = 0; y < srcH; y++) { std::memcpy(&dst->fImage[y * dst->fRowBytes], &src.fImage[y * src.fRowBytes], dstW); } diff --git a/src/core/SkMaskBlurFilter.h b/src/core/SkMaskBlurFilter.h index 9becadca39..c530488efb 100644 --- a/src/core/SkMaskBlurFilter.h +++ b/src/core/SkMaskBlurFilter.h @@ -46,6 +46,9 @@ public: // height sigmaH. SkMaskBlurFilter(double sigmaW, double sigmaH); + // returns true iff the sigmas will result in an identity mask (no blurring) + bool hasNoBlur() const; + // Given a src SkMask, generate dst SkMask returning the border width and height. SkIPoint blur(const SkMask& src, SkMask* dst) const; diff --git a/src/effects/SkBlurMask.cpp b/src/effects/SkBlurMask.cpp index fe59ab8269..937087e728 100644 --- a/src/effects/SkBlurMask.cpp +++ b/src/effects/SkBlurMask.cpp @@ -590,6 +590,9 @@ bool SkBlurMask::BoxBlur(SkMask* dst, const SkMask& src, } #else SkMaskBlurFilter blurFilter{sigma, sigma}; + if (blurFilter.hasNoBlur()) { + return false; + } border = blurFilter.blur(src, dst); #endif // SK_SUPPORT_LEGACY_MASK_BLUR |