diff options
author | Herbert Derby <herb@google.com> | 2017-12-01 15:36:00 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-12-01 22:21:20 +0000 |
commit | 65f6985a96ef631b033f299fc6796122013782b8 (patch) | |
tree | 7b4f9462234bd724b2bcdfe72e3c4ea5780309cb /src | |
parent | 6574921253197338f879130ed99fb9ce483976de (diff) |
Initialize dst image memory for small sigma
The GPU and CPU share the same code for layout; the layout is too large for CPU. So,
the CPU code must clear some of the destination even if there would be no work to do.
Change-Id: I29a04217b620b033a01db53487dc64e377661436
BUG=chromium:789812
Reviewed-on: https://skia-review.googlesource.com/79401
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkBlurImageFilter.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/core/SkBlurImageFilter.cpp b/src/core/SkBlurImageFilter.cpp index 088462b964..8c78504215 100644 --- a/src/core/SkBlurImageFilter.cpp +++ b/src/core/SkBlurImageFilter.cpp @@ -465,9 +465,10 @@ static sk_sp<SkSpecialImage> combined_pass_blur( auto intermediateWidth = srcW; if (windowW > 1) { - // For the horizontal blur, start part way down in anticipation of the vertical blur. - // If this is a horizontal only blur, then shift will be zero. auto shift = (srcBounds.top() - dstBounds.top()); + // For the horizontal blur, start part way down in anticipation of the vertical blur. + // For a vertical sigma of zero shift should be zero. But, for small sigma, + // shift may be > 0 but the vertical window could be 1. intermediateSrc = static_cast<uint32_t *>(dst.getPixels()) + (shift > 0 ? shift * dst.rowBytesAsPixels() : 0); intermediateRowBytesAsPixels = dst.rowBytesAsPixels(); @@ -486,6 +487,16 @@ static sk_sp<SkSpecialImage> combined_pass_blur( srcBounds.top(), srcBounds.bottom(), dstBounds.bottom(), intermediateSrc, intermediateRowBytesAsPixels, 1, intermediateWidth, static_cast<uint32_t *>(dst.getPixels()), dst.rowBytesAsPixels(), 1); + } else { + // This code is needed to account for the difference between border calculation of + // the GPU and CPU. Normally, a window of 1 would imply no border, but because the + // layout must be the same for CPU and GPU there can be a border. + for (int y = dstBounds.top(); y < srcBounds.top(); y++) { + sk_bzero(dst.getAddr32(0, y), dst.rowBytes()); + } + for (int y = srcBounds.bottom(); y < dstBounds.bottom(); y++) { + sk_bzero(dst.getAddr32(0, y), dst.rowBytes()); + } } } else { // There is no blurring to do, but we still need to copy the source while accounting for the |