diff options
author | Florin Malita <fmalita@google.com> | 2017-07-12 02:52:48 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-07-12 02:52:56 +0000 |
commit | a30d407b4fe95335598f62644010d017195e6aac (patch) | |
tree | 9c14fa544a6d6d2b628364cf2c157794775a074c /src/effects | |
parent | d96ed9d0def2d660f537e4ab5c79e9e66470ee22 (diff) |
Revert "Experimental blur code."
This reverts commit d96ed9d0def2d660f537e4ab5c79e9e66470ee22.
Reason for revert: dm crashing
https://luci-milo.appspot.com/swarming/task/374d82c1d1263910/steps/symbolized_dm/0/stdout
Likely culprit:
unit test BlurDrawing
Stack trace:
/mnt/pd0/s/w/ir/out/Debug/dm(+0x2440eb) [0x568770eb]
linux-gate.so.1(__kernel_sigreturn+0) [0xf7714ca0]
/mnt/pd0/s/w/ir/out/Debug/dm(_ZNK16SkMaskBlurFilter11blurOneScanENS_10FilterInfoEPKhjS2_PhjS3_+0x236) [0x5766301e]
/mnt/pd0/s/w/ir/out/Debug/dm(_ZNK16SkMaskBlurFilter4blurERK6SkMaskPS0_+0x285) [0x57663491]
/mnt/pd0/s/w/ir/out/Debug/dm(_ZN10SkBlurMask7BoxBlurEP6SkMaskRKS0_f11SkBlurStyle13SkBlurQualityP8SkIPointb+0x5c) [0x5720d48e]
/mnt/pd0/s/w/ir/out/Debug/dm(_ZNK20SkBlurMaskFilterImpl10filterMaskEP6SkMaskRKS0_RK8SkMatrixP8SkIPoint+0x67) [0x5720e427]
/mnt/pd0/s/w/ir/out/Debug/dm(_ZNK20SkBlurMaskFilterImpl17filterRectsToNineEPK6SkRectiRK8SkMatrixRK7SkIRectPN12SkMaskFilter9NinePatchE+0x579) [0x5721a247]
/mnt/pd0/s/w/ir/out/Debug/dm(_ZNK12SkMaskFilter10filterPathERK6SkPathRK8SkMatrixRK12SkRasterClipP9SkBlitterN11SkStrokeRec9InitStyleE+0xf6) [0x5706c2bc]
/mnt/pd0/s/w/ir/out/Debug/dm(_ZNK6SkDraw11drawDevPathERK6SkPathRK7SkPaintbP9SkBlitterb+0x1bb) [0x57034f1b]
/mnt/pd0/s/w/ir/out/Debug/dm(_ZNK6SkDraw8drawPathERK6SkPathRK7SkPaintPK8SkMatrixbbP9SkBlitter+0x47f) [0x57035dd3]
/mnt/pd0/s/w/ir/out/Debug/dm(_ZN14SkBitmapDevice8drawPathERK6SkPathRK7SkPaintPK8SkMatrixb+0x6e) [0x56f937fc]
/mnt/pd0/s/w/ir/out/Debug/dm(_ZN8SkCanvas10onDrawPathERK6SkPathRK7SkPaint+0x39d) [0x56fb12e5]
/mnt/pd0/s/w/ir/out/Debug/dm(_ZN8SkCanvas8drawPathERK6SkPathRK7SkPaint+0x18) [0x56fad926]
/mnt/pd0/s/w/ir/out/Debug/dm(+0x3f71b3) [0x56a2a1b3]
/mnt/pd0/s/w/ir/out/Debug/dm(+0x2450bd) [0x568780bd]
/mnt/pd0/s/w/ir/out/Debug/dm(+0x2450fb) [0x568780fb]
/mnt/pd0/s/w/ir/out/Debug/dm(+0xae53e7) [0x571183e7]
/mnt/pd0/s/w/ir/out/Debug/dm(_ZNKSt8functionIFvvEEclEv+0x20) [0x569f98de]
/mnt/pd0/s/w/ir/out/Debug/dm(_ZN12SkThreadPool4LoopEPv+0x298) [0x57045b2f]
/mnt/pd0/s/w/ir/out/Debug/dm(+0xbbd92c) [0x571f092c]
/lib/i386-linux-gnu/libpthread.so.0(+0x627a) [0xf76e827a]
/lib/i386-linux-gnu/libc.so.6(clone+0x66) [0xf70ecb56]
Segmentation fault
Original change's description:
> Experimental blur code.
>
> This uses a new method of blurring that runs the three
> passes of the box filter in a single pass. This implementation
> currently only does 1x1 pixel at a time, but it should be simple
> to expand to 4x4 pixels at a time.
>
> On the blur_10_normal_high_quality benchmark, the new is 7% faster
> than the old code. For the blur_100.50_normal_high_quality
> benchmark, the new code is 11% slower.
>
> Change-Id: Iea37294abc7c27de5ad569adf8bc62df77eafd02
> Reviewed-on: https://skia-review.googlesource.com/21739
> Commit-Queue: Herb Derby <herb@google.com>
> Reviewed-by: Mike Reed <reed@google.com>
TBR=herb@google.com,reed@google.com
Change-Id: I9e896c548d0a4cd3308d6a311c8bd16719a08a85
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/22421
Reviewed-by: Florin Malita <fmalita@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
Diffstat (limited to 'src/effects')
-rw-r--r-- | src/effects/SkBlurMask.cpp | 96 |
1 files changed, 38 insertions, 58 deletions
diff --git a/src/effects/SkBlurMask.cpp b/src/effects/SkBlurMask.cpp index fe59ab8269..eee16313f6 100644 --- a/src/effects/SkBlurMask.cpp +++ b/src/effects/SkBlurMask.cpp @@ -7,7 +7,6 @@ #include "SkBlurMask.h" -#include "SkMaskBlurFilter.h" #include "SkMath.h" #include "SkTemplates.h" #include "SkEndian.h" @@ -407,7 +406,13 @@ static int boxBlurInterp(const uint8_t* src, int src_y_stride, uint8_t* dst, return new_width; } - +static void get_adjusted_radii(SkScalar passRadius, int *loRadius, int *hiRadius) +{ + *loRadius = *hiRadius = SkScalarCeilToInt(passRadius); + if (SkIntToScalar(*hiRadius) - passRadius > 0.5f) { + *loRadius = *hiRadius - 1; + } +} #include "SkColorPriv.h" @@ -482,17 +487,6 @@ bool SkBlurMask::BoxBlur(SkMask* dst, const SkMask& src, return false; } - SkIPoint border; - -#ifdef SK_SUPPORT_LEGACY_MASK_BLUR - - auto get_adjusted_radii = [](SkScalar passRadius, int *loRadius, int *hiRadius) { - *loRadius = *hiRadius = SkScalarCeilToInt(passRadius); - if (SkIntToScalar(*hiRadius) - passRadius > 0.5f) { - *loRadius = *hiRadius - 1; - } - }; - // Force high quality off for small radii (performance) if (!force_quality && sigma <= SkIntToScalar(2)) { quality = kLow_SkBlurQuality; @@ -502,12 +496,12 @@ bool SkBlurMask::BoxBlur(SkMask* dst, const SkMask& src, if (kHigh_SkBlurQuality == quality) { // For the high quality path the 3 pass box blur kernel width is // 6*rad+1 while the full Gaussian width is 6*sigma. - passRadius = sigma - (1 / 6.0f); + passRadius = sigma - (1/6.0f); } else { // For the low quality path we only attempt to cover 3*sigma of the // Gaussian blur area (1.5*sigma on each side). The single pass box // blur's kernel size is 2*rad+1. - passRadius = 1.5f * sigma - 0.5f; + passRadius = 1.5f*sigma - 0.5f; } // highQuality: use three box blur passes as a cheap way @@ -528,8 +522,9 @@ bool SkBlurMask::BoxBlur(SkMask* dst, const SkMask& src, int padx = passCount * rx; int pady = passCount * ry; - border = {padx, pady}; - + if (margin) { + margin->set(padx, pady); + } dst->fBounds.set(src.fBounds.fLeft - padx, src.fBounds.fTop - pady, src.fBounds.fRight + padx, src.fBounds.fBottom + pady); @@ -543,15 +538,15 @@ bool SkBlurMask::BoxBlur(SkMask* dst, const SkMask& src, return false; // too big to allocate, abort } - int sw = src.fBounds.width(); - int sh = src.fBounds.height(); - const uint8_t* sp = src.fImage; - uint8_t* dp = SkMask::AllocImage(dstSize); + int sw = src.fBounds.width(); + int sh = src.fBounds.height(); + const uint8_t* sp = src.fImage; + uint8_t* dp = SkMask::AllocImage(dstSize); SkAutoTCallVProc<uint8_t, SkMask_FreeImage> autoCall(dp); // build the blurry destination - SkAutoTMalloc<uint8_t> tmpBuffer(dstSize); - uint8_t* tp = tmpBuffer.get(); + SkAutoTMalloc<uint8_t> tmpBuffer(dstSize); + uint8_t* tp = tmpBuffer.get(); int w = sw, h = sh; if (outerWeight == 255) { @@ -560,40 +555,33 @@ bool SkBlurMask::BoxBlur(SkMask* dst, const SkMask& src, if (kHigh_SkBlurQuality == quality) { // Do three X blurs, with a transpose on the final one. w = boxBlur<false>(sp, src.fRowBytes, tp, loRadius, hiRadius, w, h); - w = boxBlur<false>(tp, w, dp, hiRadius, loRadius, w, h); - w = boxBlur<true>(dp, w, tp, hiRadius, hiRadius, w, h); + w = boxBlur<false>(tp, w, dp, hiRadius, loRadius, w, h); + w = boxBlur<true>(dp, w, tp, hiRadius, hiRadius, w, h); // Do three Y blurs, with a transpose on the final one. - h = boxBlur<false>(tp, h, dp, loRadius, hiRadius, h, w); - h = boxBlur<false>(dp, h, tp, hiRadius, loRadius, h, w); - h = boxBlur<true>(tp, h, dp, hiRadius, hiRadius, h, w); + h = boxBlur<false>(tp, h, dp, loRadius, hiRadius, h, w); + h = boxBlur<false>(dp, h, tp, hiRadius, loRadius, h, w); + h = boxBlur<true>(tp, h, dp, hiRadius, hiRadius, h, w); } else { w = boxBlur<true>(sp, src.fRowBytes, tp, rx, rx, w, h); - h = boxBlur<true>(tp, h, dp, ry, ry, h, w); + h = boxBlur<true>(tp, h, dp, ry, ry, h, w); } } else { if (kHigh_SkBlurQuality == quality) { // Do three X blurs, with a transpose on the final one. w = boxBlurInterp<false>(sp, src.fRowBytes, tp, rx, w, h, outerWeight); - w = boxBlurInterp<false>(tp, w, dp, rx, w, h, outerWeight); - w = boxBlurInterp<true>(dp, w, tp, rx, w, h, outerWeight); + w = boxBlurInterp<false>(tp, w, dp, rx, w, h, outerWeight); + w = boxBlurInterp<true>(dp, w, tp, rx, w, h, outerWeight); // Do three Y blurs, with a transpose on the final one. - h = boxBlurInterp<false>(tp, h, dp, ry, h, w, outerWeight); - h = boxBlurInterp<false>(dp, h, tp, ry, h, w, outerWeight); - h = boxBlurInterp<true>(tp, h, dp, ry, h, w, outerWeight); + h = boxBlurInterp<false>(tp, h, dp, ry, h, w, outerWeight); + h = boxBlurInterp<false>(dp, h, tp, ry, h, w, outerWeight); + h = boxBlurInterp<true>(tp, h, dp, ry, h, w, outerWeight); } else { w = boxBlurInterp<true>(sp, src.fRowBytes, tp, rx, w, h, outerWeight); - h = boxBlurInterp<true>(tp, h, dp, ry, h, w, outerWeight); + h = boxBlurInterp<true>(tp, h, dp, ry, h, w, outerWeight); } } - dst->fImage = autoCall.release(); - } -#else - SkMaskBlurFilter blurFilter{sigma, sigma}; - border = blurFilter.blur(src, dst); -#endif // SK_SUPPORT_LEGACY_MASK_BLUR - - if (src.fImage != nullptr) { + dst->fImage = dp; // if need be, alloc the "real" dst (same size as src) and copy/merge // the blur into it (applying the src) if (style == kInner_SkBlurStyle) { @@ -602,21 +590,17 @@ bool SkBlurMask::BoxBlur(SkMask* dst, const SkMask& src, if (0 == srcSize) { return false; // too big to allocate, abort } - auto blur = dst->fImage; dst->fImage = SkMask::AllocImage(srcSize); - auto blurStart = &blur[border.x() + border.y() * dst->fRowBytes]; merge_src_with_blur(dst->fImage, src.fRowBytes, - src.fImage, src.fRowBytes, - blurStart, - dst->fRowBytes, - src.fBounds.width(), src.fBounds.height()); - SkMask::FreeImage(blur); + sp, src.fRowBytes, + dp + passCount * (rx + ry * dst->fRowBytes), + dst->fRowBytes, sw, sh); + SkMask::FreeImage(dp); } else if (style != kNormal_SkBlurStyle) { - auto dstStart = &dst->fImage[border.x() + border.y() * dst->fRowBytes]; - clamp_with_orig(dstStart, - dst->fRowBytes, src.fImage, src.fRowBytes, - src.fBounds.width(), src.fBounds.height(), style); + clamp_with_orig(dp + passCount * (rx + ry * dst->fRowBytes), + dst->fRowBytes, sp, src.fRowBytes, sw, sh, style); } + (void)autoCall.release(); } if (style == kInner_SkBlurStyle) { @@ -624,10 +608,6 @@ bool SkBlurMask::BoxBlur(SkMask* dst, const SkMask& src, dst->fRowBytes = src.fRowBytes; } - if (margin != nullptr) { - *margin = border; - } - return true; } |