Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Unified Diff: src/effects/SkBlurImageFilter.cpp

Issue 209353014: Fix for crash on large image blur sigma values. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Tweak Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/effects/SkGpuBlurUtils.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkBlurImageFilter.cpp
diff --git a/src/effects/SkBlurImageFilter.cpp b/src/effects/SkBlurImageFilter.cpp
index ffebe54225ee37f348f97011c3447889780a389c..363691abfea5cf70f630afe8639233dcf111af6a 100644
--- a/src/effects/SkBlurImageFilter.cpp
+++ b/src/effects/SkBlurImageFilter.cpp
@@ -16,6 +16,13 @@
#include "GrContext.h"
#endif
+// This rather arbitrary-looking value results in a maximum box blur kernel size
+// of 1000 pixels on the raster path, which matches the WebKit and Firefox
+// implementations. Since the GPU path does not compute a box blur, putting
+// the limit on sigma ensures consistent behaviour between the GPU and
+// raster paths.
+#define MAX_SIGMA SkIntToScalar(532)
+
SkBlurImageFilter::SkBlurImageFilter(SkReadBuffer& buffer)
: INHERITED(1, buffer) {
fSigma.fWidth = buffer.readScalar();
@@ -164,6 +171,8 @@ bool SkBlurImageFilter::onFilterImage(Proxy* proxy,
SkVector sigma, localSigma = SkVector::Make(fSigma.width(), fSigma.height());
ctx.ctm().mapVectors(&sigma, &localSigma, 1);
+ sigma.fX = SkMinScalar(sigma.fX, MAX_SIGMA);
+ sigma.fY = SkMinScalar(sigma.fY, MAX_SIGMA);
int kernelSizeX, kernelSizeX3, lowOffsetX, highOffsetX;
int kernelSizeY, kernelSizeY3, lowOffsetY, highOffsetY;
@@ -263,6 +272,8 @@ bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
GrTexture* source = input.getTexture();
SkVector sigma, localSigma = SkVector::Make(fSigma.width(), fSigma.height());
ctx.ctm().mapVectors(&sigma, &localSigma, 1);
+ sigma.fX = SkMinScalar(sigma.fX, MAX_SIGMA);
+ sigma.fY = SkMinScalar(sigma.fY, MAX_SIGMA);
offset->fX = rect.fLeft;
offset->fY = rect.fTop;
rect.offset(-srcOffset);
« no previous file with comments | « no previous file | src/effects/SkGpuBlurUtils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698