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

Unified Diff: src/effects/SkBlurImageFilter.cpp

Issue 1657773002: Fix zero-sized blur with crop rect. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Do all early-outs before allocating dst Created 4 years, 11 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
« gm/imagefilterscropped.cpp ('K') | « gm/imagefilterscropped.cpp ('k') | no next file » | 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 5d58369bc765cd561f6836a702145c7b4af0b6f1..631cd35f8c05276afcc35da1d3162cc0e25c997b 100644
--- a/src/effects/SkBlurImageFilter.cpp
+++ b/src/effects/SkBlurImageFilter.cpp
@@ -90,18 +90,6 @@ bool SkBlurImageFilter::onFilterImage(Proxy* proxy,
return false;
}
- SkAutoLockPixels alp(src);
- if (!src.getPixels()) {
- return false;
- }
-
- SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(dstBounds.width(), dstBounds.height()));
- if (!device) {
- return false;
- }
- *dst = device->accessBitmap(false);
- SkAutoLockPixels alp_dst(*dst);
-
SkVector sigma = mapSigma(fSigma, ctx.ctm());
int kernelSizeX, kernelSizeX3, lowOffsetX, highOffsetX;
@@ -114,12 +102,24 @@ bool SkBlurImageFilter::onFilterImage(Proxy* proxy,
}
if (kernelSizeX == 0 && kernelSizeY == 0) {
- src.copyTo(dst, dst->colorType());
- offset->fX = dstBounds.x() + srcOffset.x();
- offset->fY = dstBounds.y() + srcOffset.y();
+ src.extractSubset(dst, srcBounds);
+ offset->fX = srcBounds.x();
+ offset->fY = srcBounds.y();
return true;
}
+ SkAutoLockPixels alp(src);
+ if (!src.getPixels()) {
+ return false;
+ }
+
+ SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(dstBounds.width(), dstBounds.height()));
+ if (!device) {
+ return false;
+ }
+ *dst = device->accessBitmap(false);
+ SkAutoLockPixels alp_dst(*dst);
+
SkAutoTUnref<SkBaseDevice> tempDevice(proxy->createDevice(dst->width(), dst->height()));
if (!tempDevice) {
return false;
@@ -211,15 +211,21 @@ bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
if (!srcBounds.intersect(dstBounds)) {
return false;
}
- GrTexture* source = input.getTexture();
SkVector sigma = mapSigma(fSigma, ctx.ctm());
robertphillips 2016/02/01 17:41:35 Do we need/want an epsilon-based comparison here ?
Stephen White 2016/02/01 18:20:03 Since GaussianBlur() does exact comparisons as wel
+ if (sigma.x() == 0 && sigma.y() == 0) {
+ input.extractSubset(result, srcBounds);
+ offset->fX = srcBounds.x();
+ offset->fY = srcBounds.y();
+ return true;
+ }
offset->fX = dstBounds.fLeft;
offset->fY = dstBounds.fTop;
srcBounds.offset(-srcOffset);
dstBounds.offset(-srcOffset);
SkRect srcBoundsF(SkRect::Make(srcBounds));
- SkAutoTUnref<GrTexture> tex(SkGpuBlurUtils::GaussianBlur(source->getContext(),
- source,
+ GrTexture* inputTexture = input.getTexture();
+ SkAutoTUnref<GrTexture> tex(SkGpuBlurUtils::GaussianBlur(inputTexture->getContext(),
+ inputTexture,
false,
SkRect::Make(dstBounds),
&srcBoundsF,
« gm/imagefilterscropped.cpp ('K') | « gm/imagefilterscropped.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698