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

Unified Diff: src/effects/SkBlurImageFilter.cpp

Issue 555603002: Allow negative values in SkBlurImageFilter sigma. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix re: sugoi's comment Created 6 years, 3 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 | tests/ImageFilterTest.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 8590400003eba2ffb8aae2eb255abcc00e207f0a..4166d200355632e6ef8374ac4eb018e7460519a8 100644
--- a/src/effects/SkBlurImageFilter.cpp
+++ b/src/effects/SkBlurImageFilter.cpp
@@ -23,6 +23,14 @@
// raster paths.
#define MAX_SIGMA SkIntToScalar(532)
+static SkVector mapSigma(const SkSize& localSigma, const SkMatrix& ctm) {
+ SkVector sigma = SkVector::Make(localSigma.width(), localSigma.height());
+ ctm.mapVectors(&sigma, 1);
+ sigma.fX = SkMinScalar(SkScalarAbs(sigma.fX), MAX_SIGMA);
+ sigma.fY = SkMinScalar(SkScalarAbs(sigma.fY), MAX_SIGMA);
+ return sigma;
+}
+
#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
SkBlurImageFilter::SkBlurImageFilter(SkReadBuffer& buffer)
: INHERITED(1, buffer) {
@@ -177,10 +185,7 @@ bool SkBlurImageFilter::onFilterImage(Proxy* proxy,
}
dst->getBounds(&dstBounds);
- SkVector sigma = SkVector::Make(fSigma.width(), fSigma.height());
- ctx.ctm().mapVectors(&sigma, 1);
- sigma.fX = SkMinScalar(sigma.fX, MAX_SIGMA);
- sigma.fY = SkMinScalar(sigma.fY, MAX_SIGMA);
+ SkVector sigma = mapSigma(fSigma, ctx.ctm());
int kernelSizeX, kernelSizeX3, lowOffsetX, highOffsetX;
int kernelSizeY, kernelSizeY3, lowOffsetY, highOffsetY;
@@ -253,8 +258,7 @@ void SkBlurImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const
bool SkBlurImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
SkIRect* dst) const {
SkIRect bounds = src;
- SkVector sigma = SkVector::Make(fSigma.width(), fSigma.height());
- ctm.mapVectors(&sigma, 1);
+ SkVector sigma = mapSigma(fSigma, ctm);
bounds.outset(SkScalarCeilToInt(SkScalarMul(sigma.x(), SkIntToScalar(3))),
SkScalarCeilToInt(SkScalarMul(sigma.y(), SkIntToScalar(3))));
if (getInput(0) && !getInput(0)->filterBounds(bounds, ctm, &bounds)) {
@@ -277,10 +281,7 @@ bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
return false;
}
GrTexture* source = input.getTexture();
- SkVector sigma = SkVector::Make(fSigma.width(), fSigma.height());
- ctx.ctm().mapVectors(&sigma, 1);
- sigma.fX = SkMinScalar(sigma.fX, MAX_SIGMA);
- sigma.fY = SkMinScalar(sigma.fY, MAX_SIGMA);
+ SkVector sigma = mapSigma(fSigma, ctx.ctm());
offset->fX = rect.fLeft;
offset->fY = rect.fTop;
rect.offset(-srcOffset);
« no previous file with comments | « no previous file | tests/ImageFilterTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698