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

Unified Diff: src/effects/SkGpuBlurUtils.cpp

Issue 1529313003: Fix gaussian blur for small sigma. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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 | « gm/imagefilterscropexpand.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkGpuBlurUtils.cpp
diff --git a/src/effects/SkGpuBlurUtils.cpp b/src/effects/SkGpuBlurUtils.cpp
index 8ab05dd8621669caee837cb3d10875a1a0574eac..13b6b0a3bc165ffbe58f597856ea042c4e7db106 100644
--- a/src/effects/SkGpuBlurUtils.cpp
+++ b/src/effects/SkGpuBlurUtils.cpp
@@ -60,21 +60,21 @@ static void convolve_gaussian_1d(GrDrawContext* drawContext,
texture, direction, radius, sigma, useBounds, bounds));
paint.addColorFragmentProcessor(conv);
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
- SkMatrix localMatrix = SkMatrix::MakeTrans(srcOffset.x(), srcOffset.y());
+ SkMatrix localMatrix = SkMatrix::MakeTrans(-srcOffset.x(), -srcOffset.y());
drawContext->fillRectWithLocalMatrix(clip, paint, SkMatrix::I(), dstRect, localMatrix);
}
static void convolve_gaussian_2d(GrDrawContext* drawContext,
const GrClip& clip,
- const SkRect& srcRect,
+ const SkRect& dstRect,
+ const SkPoint& srcOffset,
GrTexture* texture,
int radiusX,
int radiusY,
SkScalar sigmaX,
SkScalar sigmaY,
const SkRect* srcBounds) {
- SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
- SkMatrix localMatrix = SkMatrix::MakeTrans(srcRect.x(), srcRect.y());
+ SkMatrix localMatrix = SkMatrix::MakeTrans(-srcOffset.x(), -srcOffset.y());
SkISize size = SkISize::Make(2 * radiusX + 1, 2 * radiusY + 1);
SkIPoint kernelOffset = SkIPoint::Make(radiusX, radiusY);
GrPaint paint;
@@ -148,15 +148,15 @@ static void convolve_gaussian(GrDrawContext* drawContext,
}
if (midRect.isEmpty()) {
// Blur radius covers srcBounds; use bounds over entire draw
- convolve_gaussian_1d(drawContext, clip, dstRect, -srcOffset, texture,
+ convolve_gaussian_1d(drawContext, clip, dstRect, srcOffset, texture,
direction, radius, sigma, true, bounds);
} else {
// Draw right and left margins with bounds; middle without.
- convolve_gaussian_1d(drawContext, clip, leftRect, -srcOffset, texture,
+ convolve_gaussian_1d(drawContext, clip, leftRect, srcOffset, texture,
direction, radius, sigma, true, bounds);
- convolve_gaussian_1d(drawContext, clip, rightRect, -srcOffset, texture,
+ convolve_gaussian_1d(drawContext, clip, rightRect, srcOffset, texture,
direction, radius, sigma, true, bounds);
- convolve_gaussian_1d(drawContext, clip, midRect, -srcOffset, texture,
+ convolve_gaussian_1d(drawContext, clip, midRect, srcOffset, texture,
direction, radius, sigma, false, bounds);
}
}
@@ -269,6 +269,7 @@ GrTexture* GaussianBlur(GrContext* context,
// For really small blurs (certainly no wider than 5x5 on desktop gpus) it is faster to just
// launch a single non separable kernel vs two launches
+ srcRect = localDstBounds;
if (sigmaX > 0.0f && sigmaY > 0.0f &&
(2 * radiusX + 1) * (2 * radiusY + 1) <= MAX_KERNEL_SIZE) {
// We shouldn't be scaling because this is a small size blur
@@ -279,7 +280,7 @@ GrTexture* GaussianBlur(GrContext* context,
if (!dstDrawContext) {
return nullptr;
}
- convolve_gaussian_2d(dstDrawContext, clip, srcRect,
+ convolve_gaussian_2d(dstDrawContext, clip, srcRect, srcOffset,
srcTexture, radiusX, radiusY, sigmaX, sigmaY, srcBounds);
srcDrawContext.swap(dstDrawContext);
@@ -288,7 +289,6 @@ GrTexture* GaussianBlur(GrContext* context,
SkTSwap(dstTexture, tempTexture);
} else {
- srcRect = localDstBounds;
scale_rect(&srcRect, 1.0f / scaleFactorX, 1.0f / scaleFactorY);
srcRect.roundOut(&srcRect);
const SkIRect srcIRect = srcRect.roundOut();
« no previous file with comments | « gm/imagefilterscropexpand.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698