aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-08-01 21:20:31 +0000
committerGravatar senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-08-01 21:20:31 +0000
commit68c4d1288aeda7810b74f44e066f9534216148b1 (patch)
treecb7b790270f29d97d992a5ed52af172ceea8c873 /src/gpu
parent099d22dbce650abdda0c5c5a7ee89ee0850897f1 (diff)
Clip GPU blur against clip bounds. Clip the size of the FBOs used for blurs
to the bounds of the clipping region, inflated by the blur radius. This is a little tricky, since we want the rect we use for downsampling to be an integer multiple of the scale factor, so we scale down the clip rect to downsampled space, inflate by the (scaled) kernel width, and intersect the rects there. Also check the blur radius against 0 and abort early, to prevent the fuzzer blowing up on a missing uniform. Review URL: http://codereview.appspot.com/4841043/ git-svn-id: http://skia.googlecode.com/svn/trunk@2020 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/SkGpuDevice.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 4294e49072..c3754dcada 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -843,6 +843,9 @@ static bool drawWithGPUMaskFilter(GrContext* context, const SkPath& path,
SkScalar radius = info.fIgnoreTransform ? info.fRadius
: matrix.mapRadius(info.fRadius);
radius = SkMinScalar(radius, MAX_BLUR_RADIUS);
+ if (radius <= 0) {
+ return false;
+ }
float sigma = SkScalarToFloat(radius) * BLUR_SIGMA_SCALE;
SkRect srcRect = path.getBounds();
@@ -852,15 +855,22 @@ static bool drawWithGPUMaskFilter(GrContext* context, const SkPath& path,
scaleFactor *= 2;
sigma *= 0.5f;
}
- scaleRect(&srcRect, 1.0f / scaleFactor);
int halfWidth = static_cast<int>(ceilf(sigma * 3.0f));
int kernelWidth = halfWidth * 2 + 1;
- SkIRect srcIRect;
- srcRect.roundOut(&srcIRect);
- srcRect.set(srcIRect);
+ float invScale = 1.0f / scaleFactor;
+ scaleRect(&srcRect, invScale);
+ srcRect.roundOut();
srcRect.inset(-halfWidth, -halfWidth);
+ SkRect clipBounds;
+ clipBounds.set(clip.getBounds());
+ scaleRect(&clipBounds, invScale);
+ clipBounds.roundOut();
+ clipBounds.inset(-halfWidth, -halfWidth);
+
+ srcRect.intersect(clipBounds);
+
scaleRect(&srcRect, scaleFactor);
SkRect finalRect = srcRect;