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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkBlurImageFilter.h" | 10 #include "SkBlurImageFilter.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 surface = SkSurface::MakeRaster(info); | 21 surface = SkSurface::MakeRaster(info); |
22 } | 22 } |
23 | 23 |
24 SkPaint paint; | 24 SkPaint paint; |
25 paint.setAntiAlias(true); | 25 paint.setAntiAlias(true); |
26 paint.setColor(SK_ColorRED); | 26 paint.setColor(SK_ColorRED); |
27 surface->getCanvas()->drawCircle(50, 50, 50, paint); | 27 surface->getCanvas()->drawCircle(50, 50, 50, paint); |
28 return surface->makeImageSnapshot(); | 28 return surface->makeImageSnapshot(); |
29 } | 29 } |
30 | 30 |
31 typedef SkImageFilter* (*ImageFilterFactory)(); | 31 typedef sk_sp<SkImageFilter> (*ImageFilterFactory)(); |
32 | 32 |
33 // +[]{...} did not work on windows (VS) | 33 // +[]{...} did not work on windows (VS) |
34 // (ImageFilterFactory)[]{...} did not work on linux (gcc) | 34 // (ImageFilterFactory)[]{...} did not work on linux (gcc) |
35 // hence this cast function | 35 // hence this cast function |
36 template <typename T> ImageFilterFactory IFCCast(T arg) { return arg; } | 36 template <typename T> ImageFilterFactory IFCCast(T arg) { return arg; } |
37 | 37 |
38 // Show the effect of localmatriximagefilter with various matrices, on various f
ilters | 38 // Show the effect of localmatriximagefilter with various matrices, on various f
ilters |
39 class LocalMatrixImageFilterGM : public skiagm::GM { | 39 class LocalMatrixImageFilterGM : public skiagm::GM { |
40 public: | 40 public: |
41 LocalMatrixImageFilterGM() {} | 41 LocalMatrixImageFilterGM() {} |
(...skipping 16 matching lines...) Expand all Loading... |
58 | 58 |
59 paint.setStyle(SkPaint::kFill_Style); | 59 paint.setStyle(SkPaint::kFill_Style); |
60 paint.setImageFilter(filter); | 60 paint.setImageFilter(filter); |
61 canvas->drawImage(image, 0, 0, &paint); | 61 canvas->drawImage(image, 0, 0, &paint); |
62 } | 62 } |
63 | 63 |
64 void onDraw(SkCanvas* canvas) override { | 64 void onDraw(SkCanvas* canvas) override { |
65 sk_sp<SkImage> image0(make_image(canvas)); | 65 sk_sp<SkImage> image0(make_image(canvas)); |
66 | 66 |
67 const ImageFilterFactory factories[] = { | 67 const ImageFilterFactory factories[] = { |
68 IFCCast([]{ return SkBlurImageFilter::Make(8, 8, nullptr).release();
}), | 68 IFCCast([]{ return SkBlurImageFilter::Make(8, 8, nullptr); }), |
69 IFCCast([]{ return SkDilateImageFilter::Create(8, 8); }), | 69 IFCCast([]{ return SkDilateImageFilter::Make(8, 8, nullptr); }), |
70 IFCCast([]{ return SkErodeImageFilter::Create(8, 8); }), | 70 IFCCast([]{ return SkErodeImageFilter::Make(8, 8, nullptr); }), |
71 IFCCast([]{ return SkOffsetImageFilter::Make(8, 8, nullptr).release(
); }), | 71 IFCCast([]{ return SkOffsetImageFilter::Make(8, 8, nullptr); }), |
72 }; | 72 }; |
73 | 73 |
74 const SkMatrix matrices[] = { | 74 const SkMatrix matrices[] = { |
75 SkMatrix::MakeScale(SK_ScalarHalf, SK_ScalarHalf), | 75 SkMatrix::MakeScale(SK_ScalarHalf, SK_ScalarHalf), |
76 SkMatrix::MakeScale(2, 2), | 76 SkMatrix::MakeScale(2, 2), |
77 SkMatrix::MakeTrans(10, 10) | 77 SkMatrix::MakeTrans(10, 10) |
78 }; | 78 }; |
79 | 79 |
80 const SkScalar spacer = image0->width() * 3.0f / 2; | 80 const SkScalar spacer = image0->width() * 3.0f / 2; |
81 | 81 |
(...skipping 10 matching lines...) Expand all Loading... |
92 } | 92 } |
93 canvas->restore(); | 93 canvas->restore(); |
94 canvas->translate(0, spacer); | 94 canvas->translate(0, spacer); |
95 } | 95 } |
96 } | 96 } |
97 | 97 |
98 private: | 98 private: |
99 typedef GM INHERITED; | 99 typedef GM INHERITED; |
100 }; | 100 }; |
101 DEF_GM( return new LocalMatrixImageFilterGM; ) | 101 DEF_GM( return new LocalMatrixImageFilterGM; ) |
OLD | NEW |