OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkColorFilter.h" | 10 #include "SkColorFilter.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 canvas->drawRect(r, paint); | 185 canvas->drawRect(r, paint); |
186 } | 186 } |
187 | 187 |
188 void onDraw(SkCanvas* canvas) override { | 188 void onDraw(SkCanvas* canvas) override { |
189 void (*drawProc[])(SkCanvas*, const SkRect&, SkImageFilter*) = { | 189 void (*drawProc[])(SkCanvas*, const SkRect&, SkImageFilter*) = { |
190 draw_paint, | 190 draw_paint, |
191 draw_line, draw_rect, draw_path, draw_text, | 191 draw_line, draw_rect, draw_path, draw_text, |
192 draw_bitmap, | 192 draw_bitmap, |
193 }; | 193 }; |
194 | 194 |
195 auto cf = SkColorFilter::MakeModeFilter(SK_ColorRED, SkXfermode::kSrcIn_
Mode); | 195 SkColorFilter* cf = SkColorFilter::CreateModeFilter(SK_ColorRED, |
| 196 SkXfermode::kSrcIn_Mode); |
196 SkImageFilter* filters[] = { | 197 SkImageFilter* filters[] = { |
197 nullptr, | 198 nullptr, |
198 IdentityImageFilter::Create(), | 199 IdentityImageFilter::Create(), |
199 FailImageFilter::Create(), | 200 FailImageFilter::Create(), |
200 SkColorFilterImageFilter::Create(cf.get()), | 201 SkColorFilterImageFilter::Create(cf), |
201 SkBlurImageFilter::Create(12.0f, 0.0f), | 202 SkBlurImageFilter::Create(12.0f, 0.0f), |
202 SkDropShadowImageFilter::Create(10.0f, 5.0f, 3.0f, 3.0f, SK_ColorBLU
E, | 203 SkDropShadowImageFilter::Create(10.0f, 5.0f, 3.0f, 3.0f, SK_ColorBLU
E, |
203 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode), | 204 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode), |
204 }; | 205 }; |
| 206 cf->unref(); |
205 | 207 |
206 SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64)); | 208 SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64)); |
207 SkScalar MARGIN = SkIntToScalar(16); | 209 SkScalar MARGIN = SkIntToScalar(16); |
208 SkScalar DX = r.width() + MARGIN; | 210 SkScalar DX = r.width() + MARGIN; |
209 SkScalar DY = r.height() + MARGIN; | 211 SkScalar DY = r.height() + MARGIN; |
210 | 212 |
211 canvas->translate(MARGIN, MARGIN); | 213 canvas->translate(MARGIN, MARGIN); |
212 for (size_t i = 0; i < SK_ARRAY_COUNT(drawProc); ++i) { | 214 for (size_t i = 0; i < SK_ARRAY_COUNT(drawProc); ++i) { |
213 canvas->save(); | 215 canvas->save(); |
214 for (size_t j = 0; j < SK_ARRAY_COUNT(filters); ++j) { | 216 for (size_t j = 0; j < SK_ARRAY_COUNT(filters); ++j) { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 paint->setImageFilter(SkBlurImageFilter::Create(1.5f, 1.5f))->unref(); | 313 paint->setImageFilter(SkBlurImageFilter::Create(1.5f, 1.5f))->unref(); |
312 } | 314 } |
313 }; | 315 }; |
314 DEF_GM( return new ImageFiltersText_IF; ) | 316 DEF_GM( return new ImageFiltersText_IF; ) |
315 | 317 |
316 class ImageFiltersText_CF : public ImageFiltersTextBaseGM { | 318 class ImageFiltersText_CF : public ImageFiltersTextBaseGM { |
317 public: | 319 public: |
318 ImageFiltersText_CF() : ImageFiltersTextBaseGM("color") {} | 320 ImageFiltersText_CF() : ImageFiltersTextBaseGM("color") {} |
319 | 321 |
320 void installFilter(SkPaint* paint) override { | 322 void installFilter(SkPaint* paint) override { |
321 paint->setColorFilter(SkColorFilter::MakeModeFilter(SK_ColorBLUE, SkXfer
mode::kSrcIn_Mode)); | 323 paint->setColorFilter(SkColorFilter::CreateModeFilter(SK_ColorBLUE, SkXf
ermode::kSrcIn_Mode))->unref(); |
322 } | 324 } |
323 }; | 325 }; |
324 DEF_GM( return new ImageFiltersText_CF; ) | 326 DEF_GM( return new ImageFiltersText_CF; ) |
325 | 327 |
OLD | NEW |