OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "gm.h" | 8 #include "gm.h" |
9 #include "SkBlurImageFilter.h" | 9 #include "SkBlurImageFilter.h" |
10 #include "SkColorMatrixFilter.h" | 10 #include "SkColorMatrixFilter.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // | 80 // |
81 // Expect the two to draw the same (modulo the extra border of pixels when the c
lip is larger) | 81 // Expect the two to draw the same (modulo the extra border of pixels when the c
lip is larger) |
82 // | 82 // |
83 DEF_SIMPLE_GM(fast_slow_blurimagefilter, canvas, 620, 260) { | 83 DEF_SIMPLE_GM(fast_slow_blurimagefilter, canvas, 620, 260) { |
84 SkAutoTUnref<SkImage> image(make_image(canvas)); | 84 SkAutoTUnref<SkImage> image(make_image(canvas)); |
85 const SkRect r = SkRect::MakeIWH(image->width(), image->height()); | 85 const SkRect r = SkRect::MakeIWH(image->width(), image->height()); |
86 | 86 |
87 canvas->translate(10, 10); | 87 canvas->translate(10, 10); |
88 for (SkScalar sigma = 8; sigma <= 128; sigma *= 2) { | 88 for (SkScalar sigma = 8; sigma <= 128; sigma *= 2) { |
89 SkPaint paint; | 89 SkPaint paint; |
90 paint.setImageFilter(SkBlurImageFilter::Create(sigma, sigma))->unref(); | 90 SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(sigma, sigma)
); |
| 91 paint.setImageFilter(blur.get()); |
91 | 92 |
92 canvas->save(); | 93 canvas->save(); |
93 // we outset the clip by 1, to fall out of the fast-case in drawImage | 94 // we outset the clip by 1, to fall out of the fast-case in drawImage |
94 // i.e. the clip is larger than the image | 95 // i.e. the clip is larger than the image |
95 for (SkScalar outset = 0; outset <= 1; ++outset) { | 96 for (SkScalar outset = 0; outset <= 1; ++outset) { |
96 canvas->save(); | 97 canvas->save(); |
97 canvas->clipRect(r.makeOutset(outset, outset)); | 98 canvas->clipRect(r.makeOutset(outset, outset)); |
98 canvas->drawImage(image, 0, 0, &paint); | 99 canvas->drawImage(image, 0, 0, &paint); |
99 canvas->restore(); | 100 canvas->restore(); |
100 canvas->translate(0, r.height() + 20); | 101 canvas->translate(0, r.height() + 20); |
101 } | 102 } |
102 canvas->restore(); | 103 canvas->restore(); |
103 canvas->translate(r.width() + 20, 0); | 104 canvas->translate(r.width() + 20, 0); |
104 } | 105 } |
105 } | 106 } |
OLD | NEW |