OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 | 9 |
10 #include "SkArithmeticMode.h" | 10 #include "SkArithmeticMode.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 fImage = SkImage::MakeFromBitmap( | 114 fImage = SkImage::MakeFromBitmap( |
115 sk_tool_utils::create_string_bitmap(100, 100, SK_ColorWHITE, 20, 70,
96, "e")); | 115 sk_tool_utils::create_string_bitmap(100, 100, SK_ColorWHITE, 20, 70,
96, "e")); |
116 } | 116 } |
117 | 117 |
118 void onDraw(SkCanvas* canvas) override { | 118 void onDraw(SkCanvas* canvas) override { |
119 canvas->clear(SK_ColorBLACK); | 119 canvas->clear(SK_ColorBLACK); |
120 { | 120 { |
121 sk_sp<SkImageFilter> bitmapSource(SkImageSource::Make(fImage)); | 121 sk_sp<SkImageFilter> bitmapSource(SkImageSource::Make(fImage)); |
122 sk_sp<SkColorFilter> cf(SkColorFilter::MakeModeFilter(SK_ColorRED, | 122 sk_sp<SkColorFilter> cf(SkColorFilter::MakeModeFilter(SK_ColorRED, |
123 SkXfermode::kS
rcIn_Mode)); | 123 SkXfermode::kS
rcIn_Mode)); |
124 sk_sp<SkImageFilter> blur(SkBlurImageFilter::Create(4.0f, 4.0f, bitm
apSource.get())); | 124 sk_sp<SkImageFilter> blur(SkBlurImageFilter::Make(4.0f, 4.0f, std::m
ove(bitmapSource))); |
125 sk_sp<SkImageFilter> erode(SkErodeImageFilter::Create(4, 4, blur.get
())); | 125 sk_sp<SkImageFilter> erode(SkErodeImageFilter::Create(4, 4, blur.get
())); |
126 sk_sp<SkImageFilter> color(SkColorFilterImageFilter::Create(cf.get()
, erode.get())); | 126 sk_sp<SkImageFilter> color(SkColorFilterImageFilter::Create(cf.get()
, erode.get())); |
127 sk_sp<SkImageFilter> merge(SkMergeImageFilter::Make(blur, color)); | 127 sk_sp<SkImageFilter> merge(SkMergeImageFilter::Make(blur, color)); |
128 | 128 |
129 SkPaint paint; | 129 SkPaint paint; |
130 paint.setImageFilter(std::move(merge)); | 130 paint.setImageFilter(std::move(merge)); |
131 canvas->drawPaint(paint); | 131 canvas->drawPaint(paint); |
132 canvas->translate(SkIntToScalar(100), 0); | 132 canvas->translate(SkIntToScalar(100), 0); |
133 } | 133 } |
134 { | 134 { |
(...skipping 25 matching lines...) Expand all Loading... |
160 | 160 |
161 SkPaint paint; | 161 SkPaint paint; |
162 paint.setImageFilter( | 162 paint.setImageFilter( |
163 SkXfermodeImageFilter::Make(SkArithmeticMode::Make(0, SK_Scalar1
, SK_Scalar1, 0), | 163 SkXfermodeImageFilter::Make(SkArithmeticMode::Make(0, SK_Scalar1
, SK_Scalar1, 0), |
164 matrixFilter, offsetFilter, nullptr)
); | 164 matrixFilter, offsetFilter, nullptr)
); |
165 | 165 |
166 DrawClippedImage(canvas, fImage.get(), paint); | 166 DrawClippedImage(canvas, fImage.get(), paint); |
167 canvas->translate(SkIntToScalar(100), 0); | 167 canvas->translate(SkIntToScalar(100), 0); |
168 } | 168 } |
169 { | 169 { |
170 SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create( | 170 sk_sp<SkImageFilter> blur(SkBlurImageFilter::Make(SkIntToScalar(10), |
171 SkIntToScalar(10), SkIntToScalar(10))); | 171 SkIntToScalar(10), |
| 172 nullptr)); |
172 | 173 |
173 SkImageFilter::CropRect cropRect(SkRect::MakeWH(SkIntToScalar(95), S
kIntToScalar(100))); | 174 SkImageFilter::CropRect cropRect(SkRect::MakeWH(SkIntToScalar(95), S
kIntToScalar(100))); |
174 SkPaint paint; | 175 SkPaint paint; |
175 paint.setImageFilter( | 176 paint.setImageFilter( |
176 SkXfermodeImageFilter::Make(SkXfermode::Make(SkXfermode::kSrcIn_
Mode), blur, | 177 SkXfermodeImageFilter::Make(SkXfermode::Make(SkXfermode::kSrcIn_
Mode), blur.get(), |
177 nullptr, &cropRect)); | 178 nullptr, &cropRect)); |
178 DrawClippedImage(canvas, fImage.get(), paint); | 179 DrawClippedImage(canvas, fImage.get(), paint); |
179 canvas->translate(SkIntToScalar(100), 0); | 180 canvas->translate(SkIntToScalar(100), 0); |
180 } | 181 } |
181 { | 182 { |
182 // Dilate -> matrix convolution. | 183 // Dilate -> matrix convolution. |
183 // This tests that a filter using asFragmentProcessor (matrix | 184 // This tests that a filter using asFragmentProcessor (matrix |
184 // convolution) correctly handles a non-zero source offset | 185 // convolution) correctly handles a non-zero source offset |
185 // (supplied by the dilate). | 186 // (supplied by the dilate). |
186 SkAutoTUnref<SkImageFilter> dilate(SkDilateImageFilter::Create(5, 5)
); | 187 SkAutoTUnref<SkImageFilter> dilate(SkDilateImageFilter::Create(5, 5)
); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 } | 239 } |
239 | 240 |
240 sk_sp<SkImage> fImage; | 241 sk_sp<SkImage> fImage; |
241 | 242 |
242 typedef GM INHERITED; | 243 typedef GM INHERITED; |
243 }; | 244 }; |
244 | 245 |
245 /////////////////////////////////////////////////////////////////////////////// | 246 /////////////////////////////////////////////////////////////////////////////// |
246 | 247 |
247 DEF_GM(return new ImageFiltersGraphGM;) | 248 DEF_GM(return new ImageFiltersGraphGM;) |
OLD | NEW |