aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2018-04-13 14:26:00 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-04-13 19:14:42 +0000
commit28a142f213cf4d7dd4e6005a96cca6cb67a9887d (patch)
tree7137faec58a79f1846cb3afbd3c9604ab167a100 /src
parent010d39de0ca109aa8932de6e9712090cc750ca2e (diff)
Don't try to readback from the GPU for small blur sigmas
This should revert Ganesh's small sigma handling behavior to back before: https://skia-review.googlesource.com/c/skia/+/52400 (Reorganize blur filter to insert new implementation) BUG=skia:7787 BUG=skia:7751 BUG=832838 Change-Id: I0ce6b888be534afb60336abf561e97741fa34684 Reviewed-on: https://skia-review.googlesource.com/121331 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Herb Derby <herb@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/SkBlurImageFilter.cpp34
1 files changed, 14 insertions, 20 deletions
diff --git a/src/core/SkBlurImageFilter.cpp b/src/core/SkBlurImageFilter.cpp
index 3b59d3a9b7..abdf8cdc48 100644
--- a/src/core/SkBlurImageFilter.cpp
+++ b/src/core/SkBlurImageFilter.cpp
@@ -55,12 +55,12 @@ private:
typedef SkImageFilter INHERITED;
friend class SkImageFilter;
- #if SK_SUPPORT_GPU
+#if SK_SUPPORT_GPU
sk_sp<SkSpecialImage> gpuFilter(
- SkSpecialImage *source,
- SkVector sigma, const sk_sp<SkSpecialImage> &input,
- SkIRect inputBounds, SkIRect dstBounds, const OutputProperties& outProps) const;
- #endif
+ SkSpecialImage *source, SkVector sigma, const sk_sp<SkSpecialImage> &input,
+ SkIRect inputBounds, SkIRect dstBounds, SkIPoint inputOffset,
+ const OutputProperties& outProps, SkIPoint* offset) const;
+#endif
SkSize fSigma;
SkBlurImageFilter::TileMode fTileMode;
@@ -604,8 +604,8 @@ sk_sp<SkSpecialImage> SkBlurImageFilterImpl::onFilterImage(SkSpecialImage* sourc
// xform during the filter itself.
input = ImageToColorSpace(input.get(), ctx.outputProperties());
- result = this->gpuFilter(source, sigma, input, inputBounds, dstBounds,
- ctx.outputProperties());
+ result = this->gpuFilter(source, sigma, input, inputBounds, dstBounds, inputOffset,
+ ctx.outputProperties(), &resultOffset);
} else
#endif
{
@@ -621,20 +621,14 @@ sk_sp<SkSpecialImage> SkBlurImageFilterImpl::onFilterImage(SkSpecialImage* sourc
#if SK_SUPPORT_GPU
sk_sp<SkSpecialImage> SkBlurImageFilterImpl::gpuFilter(
- SkSpecialImage *source,
- SkVector sigma, const sk_sp<SkSpecialImage> &input,
- SkIRect inputBounds, SkIRect dstBounds, const OutputProperties& outProps) const
+ SkSpecialImage *source, SkVector sigma, const sk_sp<SkSpecialImage> &input,
+ SkIRect inputBounds, SkIRect dstBounds, SkIPoint inputOffset,
+ const OutputProperties& outProps, SkIPoint* offset) const
{
- // If both sigmas produce arms of the cross that are less than 1/2048, then they
- // do not contribute to the sum of the filter in a way to change a gamma corrected result.
- // Let s = 1/(2*sigma^2)
- // The normalizing value n = 1 + 4*E^(-s) + 4*E^(-2s)
- // The raw cross arm value c = E^-s
- // The normalized cross arm value = c/n
- // N[Solve[{c/n == 1/2048, sigma > 0}, sigma], 16]
- static constexpr double kZeroWindowGPU = 0.2561130112451658;
- if (sigma.x() < kZeroWindowGPU && sigma.y() < kZeroWindowGPU) {
- return copy_image_with_bounds(source, input, inputBounds, dstBounds);
+ if (0 == sigma.x() && 0 == sigma.y()) {
+ offset->fX = inputBounds.x() + inputOffset.fX;
+ offset->fY = inputBounds.y() + inputOffset.fY;
+ return input->makeSubset(inputBounds);
}
GrContext* context = source->getContext();