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" |
11 #include "SkColorPriv.h" | 11 #include "SkColorPriv.h" |
12 #include "SkShader.h" | 12 #include "SkShader.h" |
13 | 13 |
14 #include "SkBlurImageFilter.h" | 14 #include "SkBlurImageFilter.h" |
15 #include "SkColorFilterImageFilter.h" | 15 #include "SkColorFilterImageFilter.h" |
16 #include "SkComposeImageFilter.h" | 16 #include "SkComposeImageFilter.h" |
17 #include "SkMergeImageFilter.h" | 17 #include "SkMergeImageFilter.h" |
18 #include "SkOffsetImageFilter.h" | 18 #include "SkOffsetImageFilter.h" |
19 #include "SkTestImageFilters.h" | 19 #include "SkTestImageFilters.h" |
20 | 20 |
21 #define FILTER_WIDTH SkIntToScalar(150) | 21 #define FILTER_WIDTH SkIntToScalar(150) |
22 #define FILTER_HEIGHT SkIntToScalar(200) | 22 #define FILTER_HEIGHT SkIntToScalar(200) |
23 | 23 |
24 static SkImageFilter* make0() { return SkDownSampleImageFilter::Create(SK_Scalar
1 / 5); } | 24 static SkImageFilter* make0() { return SkDownSampleImageFilter::Create(SK_Scalar
1 / 5); } |
25 static SkImageFilter* make1() { return SkOffsetImageFilter::Create(SkIntToScalar
(16), SkIntToScalar(16)); } | 25 static SkImageFilter* make1() { return SkOffsetImageFilter::Create(SkIntToScalar
(16), SkIntToScalar(16)); } |
26 static SkImageFilter* make2() { | 26 static SkImageFilter* make2() { |
27 auto cf = SkColorFilter::MakeModeFilter(SK_ColorBLUE, SkXfermode::kSrcIn_Mod
e); | 27 SkColorFilter* cf = SkColorFilter::CreateModeFilter(SK_ColorBLUE, |
28 return SkColorFilterImageFilter::Create(cf.get()); | 28 SkXfermode::kSrcIn_Mode)
; |
| 29 SkAutoUnref aur(cf); |
| 30 return SkColorFilterImageFilter::Create(cf); |
29 } | 31 } |
30 static SkImageFilter* make3() { | 32 static SkImageFilter* make3() { |
31 return SkBlurImageFilter::Create(8, 0); | 33 return SkBlurImageFilter::Create(8, 0); |
32 } | 34 } |
33 | 35 |
34 static SkImageFilter* make4() { | 36 static SkImageFilter* make4() { |
35 SkImageFilter* outer = SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntT
oScalar(16)); | 37 SkImageFilter* outer = SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntT
oScalar(16)); |
36 SkImageFilter* inner = SkDownSampleImageFilter::Create(SK_Scalar1 / 5); | 38 SkImageFilter* inner = SkDownSampleImageFilter::Create(SK_Scalar1 / 5); |
37 SkAutoUnref aur0(outer); | 39 SkAutoUnref aur0(outer); |
38 SkAutoUnref aur1(inner); | 40 SkAutoUnref aur1(inner); |
39 return SkComposeImageFilter::Create(outer, inner); | 41 return SkComposeImageFilter::Create(outer, inner); |
40 } | 42 } |
41 static SkImageFilter* make5() { | 43 static SkImageFilter* make5() { |
42 SkImageFilter* first = SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntT
oScalar(16)); | 44 SkImageFilter* first = SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntT
oScalar(16)); |
43 SkImageFilter* second = SkDownSampleImageFilter::Create(SK_Scalar1 / 5); | 45 SkImageFilter* second = SkDownSampleImageFilter::Create(SK_Scalar1 / 5); |
44 SkAutoUnref aur0(first); | 46 SkAutoUnref aur0(first); |
45 SkAutoUnref aur1(second); | 47 SkAutoUnref aur1(second); |
46 return SkMergeImageFilter::Create(first, second); | 48 return SkMergeImageFilter::Create(first, second); |
47 } | 49 } |
48 | 50 |
49 static SkImageFilter* make6() { | 51 static SkImageFilter* make6() { |
50 SkImageFilter* outer = SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntT
oScalar(16)); | 52 SkImageFilter* outer = SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntT
oScalar(16)); |
51 SkImageFilter* inner = SkDownSampleImageFilter::Create(SK_Scalar1 / 5); | 53 SkImageFilter* inner = SkDownSampleImageFilter::Create(SK_Scalar1 / 5); |
52 SkAutoUnref aur0(outer); | 54 SkAutoUnref aur0(outer); |
53 SkAutoUnref aur1(inner); | 55 SkAutoUnref aur1(inner); |
54 SkImageFilter* compose = SkComposeImageFilter::Create(outer, inner); | 56 SkImageFilter* compose = SkComposeImageFilter::Create(outer, inner); |
55 SkAutoUnref aur2(compose); | 57 SkAutoUnref aur2(compose); |
56 | 58 |
57 auto cf = SkColorFilter::MakeModeFilter(0x880000FF, SkXfermode::kSrcIn_Mode)
; | 59 SkColorFilter* cf = SkColorFilter::CreateModeFilter(0x880000FF, |
58 SkImageFilter* blue = SkColorFilterImageFilter::Create(cf.get()); | 60 SkXfermode::kSrcIn_Mode)
; |
| 61 SkAutoUnref aur3(cf); |
| 62 SkImageFilter* blue = SkColorFilterImageFilter::Create(cf); |
59 SkAutoUnref aur4(blue); | 63 SkAutoUnref aur4(blue); |
60 | 64 |
61 return SkMergeImageFilter::Create(compose, blue); | 65 return SkMergeImageFilter::Create(compose, blue); |
62 } | 66 } |
63 | 67 |
64 static SkImageFilter* make7() { | 68 static SkImageFilter* make7() { |
65 SkImageFilter* outer = SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntT
oScalar(16)); | 69 SkImageFilter* outer = SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntT
oScalar(16)); |
66 SkImageFilter* inner = make3(); | 70 SkImageFilter* inner = make3(); |
67 SkAutoUnref aur0(outer); | 71 SkAutoUnref aur0(outer); |
68 SkAutoUnref aur1(inner); | 72 SkAutoUnref aur1(inner); |
69 SkImageFilter* compose = SkComposeImageFilter::Create(outer, inner); | 73 SkImageFilter* compose = SkComposeImageFilter::Create(outer, inner); |
70 SkAutoUnref aur2(compose); | 74 SkAutoUnref aur2(compose); |
71 | 75 |
72 auto cf = SkColorFilter::MakeModeFilter(0x880000FF, SkXfermode::kSrcIn_Mode)
; | 76 SkColorFilter* cf = SkColorFilter::CreateModeFilter(0x880000FF, |
73 SkImageFilter* blue = SkColorFilterImageFilter::Create(cf.get()); | 77 SkXfermode::kSrcIn_Mode)
; |
| 78 SkAutoUnref aur3(cf); |
| 79 SkImageFilter* blue = SkColorFilterImageFilter::Create(cf); |
74 SkAutoUnref aur4(blue); | 80 SkAutoUnref aur4(blue); |
75 | 81 |
76 return SkMergeImageFilter::Create(compose, blue); | 82 return SkMergeImageFilter::Create(compose, blue); |
77 } | 83 } |
78 | 84 |
79 static void draw0(SkCanvas* canvas) { | 85 static void draw0(SkCanvas* canvas) { |
80 SkPaint p; | 86 SkPaint p; |
81 p.setAntiAlias(true); | 87 p.setAntiAlias(true); |
82 SkRect r = SkRect::MakeWH(FILTER_WIDTH, FILTER_HEIGHT); | 88 SkRect r = SkRect::MakeWH(FILTER_WIDTH, FILTER_HEIGHT); |
83 r.inset(SK_Scalar1 * 12, SK_Scalar1 * 12); | 89 r.inset(SK_Scalar1 * 12, SK_Scalar1 * 12); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 } | 135 } |
130 } | 136 } |
131 | 137 |
132 private: | 138 private: |
133 typedef GM INHERITED; | 139 typedef GM INHERITED; |
134 }; | 140 }; |
135 | 141 |
136 ////////////////////////////////////////////////////////////////////////////// | 142 ////////////////////////////////////////////////////////////////////////////// |
137 | 143 |
138 DEF_GM( return new TestImageFiltersGM; ) | 144 DEF_GM( return new TestImageFiltersGM; ) |
OLD | NEW |