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

Unified Diff: src/effects/SkGpuBlurUtils.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 | « src/effects/SkBlurImageFilter.cpp ('k') | tests/ImageFilterTest.cpp » ('j') | 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 6133db11d20e41bdf31a06d5d7379c4f44a3e348..9da08e6f71f0f32d84d21aef5d027e4ffa7bdcb4 100644
--- a/src/effects/SkGpuBlurUtils.cpp
+++ b/src/effects/SkGpuBlurUtils.cpp
@@ -28,11 +28,15 @@ static void scale_rect(SkRect* rect, float xScale, float yScale) {
rect->fBottom = SkScalarMul(rect->fBottom, yScale);
}
-static float adjust_sigma(float sigma, int *scaleFactor, int *radius) {
+static float adjust_sigma(float sigma, int maxTextureSize, int *scaleFactor, int *radius) {
*scaleFactor = 1;
while (sigma > MAX_BLUR_SIGMA) {
*scaleFactor *= 2;
sigma *= 0.5f;
+ if (*scaleFactor > maxTextureSize) {
+ *scaleFactor = maxTextureSize;
+ sigma = MAX_BLUR_SIGMA;
+ }
}
*radius = static_cast<int>(ceilf(sigma * 3.0f));
SkASSERT(*radius <= GrConvolutionEffect::kMaxKernelRadius);
@@ -129,8 +133,9 @@ GrTexture* GaussianBlur(GrContext* context,
SkIRect clearRect;
int scaleFactorX, radiusX;
int scaleFactorY, radiusY;
- sigmaX = adjust_sigma(sigmaX, &scaleFactorX, &radiusX);
- sigmaY = adjust_sigma(sigmaY, &scaleFactorY, &radiusY);
+ int maxTextureSize = context->getMaxTextureSize();
+ sigmaX = adjust_sigma(sigmaX, maxTextureSize, &scaleFactorX, &radiusX);
+ sigmaY = adjust_sigma(sigmaY, maxTextureSize, &scaleFactorY, &radiusY);
SkRect srcRect(rect);
scale_rect(&srcRect, 1.0f / scaleFactorX, 1.0f / scaleFactorY);
« no previous file with comments | « src/effects/SkBlurImageFilter.cpp ('k') | tests/ImageFilterTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698