diff options
author | xidachen <xidachen@chromium.org> | 2015-12-10 12:08:44 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-10 12:08:44 -0800 |
commit | 467ddc0b24a63ee1525fa18d1dcf62e47975588a (patch) | |
tree | da2da65b17a5faab7305f46d822a222a45c77809 /gm | |
parent | 671c06f9798d44fcb1cff741880dff07fed71a36 (diff) |
SkBlurImageFilter returns input when sigma = 0
In the current implementation, a blur filter is always created even in the
case when sigma.fX == 0 && sigma.fY == 0. This CL makes the blur filter
return input in this case.
BUG=568393
Review URL: https://codereview.chromium.org/1518643002
Diffstat (limited to 'gm')
-rw-r--r-- | gm/imageblur.cpp | 3 | ||||
-rw-r--r-- | gm/imageblur2.cpp | 3 | ||||
-rw-r--r-- | gm/imageblurtiled.cpp | 3 | ||||
-rw-r--r-- | gm/imagefilters.cpp | 13 |
4 files changed, 13 insertions, 9 deletions
diff --git a/gm/imageblur.cpp b/gm/imageblur.cpp index 575f02c095..22ea408e27 100644 --- a/gm/imageblur.cpp +++ b/gm/imageblur.cpp @@ -14,7 +14,8 @@ void imageblurgm_draw(SkScalar fSigmaX, SkScalar fSigmaY, SkCanvas* canvas) { SkPaint paint; - paint.setImageFilter(SkBlurImageFilter::Create(fSigmaX, fSigmaY))->unref(); + SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(fSigmaX, fSigmaY)); + paint.setImageFilter(blur); canvas->saveLayer(nullptr, &paint); const char* str = "The quick brown fox jumped over the lazy dog."; diff --git a/gm/imageblur2.cpp b/gm/imageblur2.cpp index 223582f120..2b95c02ab1 100644 --- a/gm/imageblur2.cpp +++ b/gm/imageblur2.cpp @@ -58,7 +58,8 @@ protected: SkScalar sigmaY = kBlurSigmas[y]; SkPaint paint; - paint.setImageFilter(SkBlurImageFilter::Create(sigmaX, sigmaY))->unref(); + SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(sigmaX, sigmaY)); + paint.setImageFilter(blur); canvas->saveLayer(nullptr, &paint); SkRandom rand; diff --git a/gm/imageblurtiled.cpp b/gm/imageblurtiled.cpp index 68e5785ddf..9f8bfe510f 100644 --- a/gm/imageblurtiled.cpp +++ b/gm/imageblurtiled.cpp @@ -31,7 +31,8 @@ protected: virtual void onDraw(SkCanvas* canvas) { SkPaint paint; - paint.setImageFilter(SkBlurImageFilter::Create(fSigmaX, fSigmaY))->unref(); + SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(fSigmaX, fSigmaY)); + paint.setImageFilter(blur); const SkScalar tile_size = SkIntToScalar(128); SkRect bounds; if (!canvas->getClipBounds(&bounds)) { diff --git a/gm/imagefilters.cpp b/gm/imagefilters.cpp index af2c776ce1..5f1ae84949 100644 --- a/gm/imagefilters.cpp +++ b/gm/imagefilters.cpp @@ -22,7 +22,7 @@ static void do_draw(SkCanvas* canvas, SkXfermode::Mode mode, SkImageFilter* imf) { SkAutoCanvasRestore acr(canvas, true); canvas->clipRect(SkRect::MakeWH(220, 220)); - + // want to force a layer, so modes like DstIn can combine meaningfully, but the final // image can still be shown against our default (opaque) background. non-opaque GMs // are a lot more trouble to compare/triage. @@ -31,10 +31,10 @@ static void do_draw(SkCanvas* canvas, SkXfermode::Mode mode, SkImageFilter* imf) SkPaint paint; paint.setAntiAlias(true); - + SkRect r0 = SkRect::MakeXYWH(10, 60, 200, 100); SkRect r1 = SkRect::MakeXYWH(60, 10, 100, 200); - + paint.setColor(SK_ColorRED); canvas->drawOval(r0, paint); @@ -54,14 +54,14 @@ DEF_SIMPLE_GM(imagefilters_xfermodes, canvas, 480, 480) { const SkXfermode::Mode modes[] = { SkXfermode::kSrcATop_Mode, SkXfermode::kDstIn_Mode }; - + for (size_t i = 0; i < SK_ARRAY_COUNT(modes); ++i) { canvas->save(); do_draw(canvas, modes[i], nullptr); canvas->translate(240, 0); do_draw(canvas, modes[i], imf); canvas->restore(); - + canvas->translate(0, 240); } } @@ -87,7 +87,8 @@ DEF_SIMPLE_GM(fast_slow_blurimagefilter, canvas, 620, 260) { canvas->translate(10, 10); for (SkScalar sigma = 8; sigma <= 128; sigma *= 2) { SkPaint paint; - paint.setImageFilter(SkBlurImageFilter::Create(sigma, sigma))->unref(); + SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(sigma, sigma)); + paint.setImageFilter(blur); canvas->save(); // we outset the clip by 1, to fall out of the fast-case in drawImage |