OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkBitmapSource.h" | 8 #include "SkBitmapSource.h" |
9 #include "SkDisplacementMapEffect.h" | 9 #include "SkDisplacementMapEffect.h" |
10 #include "gm.h" | 10 #include "gm.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 drawClippedBitmap(canvas, 300, 100, paint); | 111 drawClippedBitmap(canvas, 300, 100, paint); |
112 paint.setImageFilter(SkDisplacementMapEffect::Create( | 112 paint.setImageFilter(SkDisplacementMapEffect::Create( |
113 SkDisplacementMapEffect::kR_ChannelSelectorType, | 113 SkDisplacementMapEffect::kR_ChannelSelectorType, |
114 SkDisplacementMapEffect::kA_ChannelSelectorType, 40.0f, displ))->unr
ef(); | 114 SkDisplacementMapEffect::kA_ChannelSelectorType, 40.0f, displ))->unr
ef(); |
115 drawClippedBitmap(canvas, 400, 100, paint); | 115 drawClippedBitmap(canvas, 400, 100, paint); |
116 | 116 |
117 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(30, 30, 40, 40)); | 117 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(30, 30, 40, 40)); |
118 paint.setImageFilter(SkDisplacementMapEffect::Create( | 118 paint.setImageFilter(SkDisplacementMapEffect::Create( |
119 SkDisplacementMapEffect::kR_ChannelSelectorType, | 119 SkDisplacementMapEffect::kR_ChannelSelectorType, |
120 SkDisplacementMapEffect::kG_ChannelSelectorType, | 120 SkDisplacementMapEffect::kG_ChannelSelectorType, |
121 0.0f, displ, NULL, &cropRect))->unref(); | 121 0.0f, displ, nullptr, &cropRect))->unref(); |
122 drawClippedBitmap(canvas, 0, 200, paint); | 122 drawClippedBitmap(canvas, 0, 200, paint); |
123 paint.setImageFilter(SkDisplacementMapEffect::Create( | 123 paint.setImageFilter(SkDisplacementMapEffect::Create( |
124 SkDisplacementMapEffect::kB_ChannelSelectorType, | 124 SkDisplacementMapEffect::kB_ChannelSelectorType, |
125 SkDisplacementMapEffect::kA_ChannelSelectorType, | 125 SkDisplacementMapEffect::kA_ChannelSelectorType, |
126 16.0f, displ, NULL, &cropRect))->unref(); | 126 16.0f, displ, nullptr, &cropRect))->unref(); |
127 drawClippedBitmap(canvas, 100, 200, paint); | 127 drawClippedBitmap(canvas, 100, 200, paint); |
128 paint.setImageFilter(SkDisplacementMapEffect::Create( | 128 paint.setImageFilter(SkDisplacementMapEffect::Create( |
129 SkDisplacementMapEffect::kR_ChannelSelectorType, | 129 SkDisplacementMapEffect::kR_ChannelSelectorType, |
130 SkDisplacementMapEffect::kB_ChannelSelectorType, | 130 SkDisplacementMapEffect::kB_ChannelSelectorType, |
131 32.0f, displ, NULL, &cropRect))->unref(); | 131 32.0f, displ, nullptr, &cropRect))->unref(); |
132 drawClippedBitmap(canvas, 200, 200, paint); | 132 drawClippedBitmap(canvas, 200, 200, paint); |
133 paint.setImageFilter(SkDisplacementMapEffect::Create( | 133 paint.setImageFilter(SkDisplacementMapEffect::Create( |
134 SkDisplacementMapEffect::kG_ChannelSelectorType, | 134 SkDisplacementMapEffect::kG_ChannelSelectorType, |
135 SkDisplacementMapEffect::kA_ChannelSelectorType, | 135 SkDisplacementMapEffect::kA_ChannelSelectorType, |
136 48.0f, displ, NULL, &cropRect))->unref(); | 136 48.0f, displ, nullptr, &cropRect))->unref(); |
137 drawClippedBitmap(canvas, 300, 200, paint); | 137 drawClippedBitmap(canvas, 300, 200, paint); |
138 paint.setImageFilter(SkDisplacementMapEffect::Create( | 138 paint.setImageFilter(SkDisplacementMapEffect::Create( |
139 SkDisplacementMapEffect::kR_ChannelSelectorType, | 139 SkDisplacementMapEffect::kR_ChannelSelectorType, |
140 SkDisplacementMapEffect::kA_ChannelSelectorType, | 140 SkDisplacementMapEffect::kA_ChannelSelectorType, |
141 64.0f, displ, NULL, &cropRect))->unref(); | 141 64.0f, displ, nullptr, &cropRect))->unref(); |
142 drawClippedBitmap(canvas, 400, 200, paint); | 142 drawClippedBitmap(canvas, 400, 200, paint); |
143 | 143 |
144 paint.setImageFilter(SkDisplacementMapEffect::Create( | 144 paint.setImageFilter(SkDisplacementMapEffect::Create( |
145 SkDisplacementMapEffect::kR_ChannelSelectorType, | 145 SkDisplacementMapEffect::kR_ChannelSelectorType, |
146 SkDisplacementMapEffect::kG_ChannelSelectorType, | 146 SkDisplacementMapEffect::kG_ChannelSelectorType, |
147 40.0f, displ, NULL, &cropRect))->unref(); | 147 40.0f, displ, nullptr, &cropRect))->unref(); |
148 drawClippedBitmap(canvas, 0, 300, paint); | 148 drawClippedBitmap(canvas, 0, 300, paint); |
149 paint.setImageFilter(SkDisplacementMapEffect::Create( | 149 paint.setImageFilter(SkDisplacementMapEffect::Create( |
150 SkDisplacementMapEffect::kB_ChannelSelectorType, | 150 SkDisplacementMapEffect::kB_ChannelSelectorType, |
151 SkDisplacementMapEffect::kA_ChannelSelectorType, | 151 SkDisplacementMapEffect::kA_ChannelSelectorType, |
152 40.0f, displ, NULL, &cropRect))->unref(); | 152 40.0f, displ, nullptr, &cropRect))->unref(); |
153 drawClippedBitmap(canvas, 100, 300, paint); | 153 drawClippedBitmap(canvas, 100, 300, paint); |
154 paint.setImageFilter(SkDisplacementMapEffect::Create( | 154 paint.setImageFilter(SkDisplacementMapEffect::Create( |
155 SkDisplacementMapEffect::kR_ChannelSelectorType, | 155 SkDisplacementMapEffect::kR_ChannelSelectorType, |
156 SkDisplacementMapEffect::kB_ChannelSelectorType, | 156 SkDisplacementMapEffect::kB_ChannelSelectorType, |
157 40.0f, displ, NULL, &cropRect))->unref(); | 157 40.0f, displ, nullptr, &cropRect))->unref(); |
158 drawClippedBitmap(canvas, 200, 300, paint); | 158 drawClippedBitmap(canvas, 200, 300, paint); |
159 paint.setImageFilter(SkDisplacementMapEffect::Create( | 159 paint.setImageFilter(SkDisplacementMapEffect::Create( |
160 SkDisplacementMapEffect::kG_ChannelSelectorType, | 160 SkDisplacementMapEffect::kG_ChannelSelectorType, |
161 SkDisplacementMapEffect::kA_ChannelSelectorType, | 161 SkDisplacementMapEffect::kA_ChannelSelectorType, |
162 40.0f, displ, NULL, &cropRect))->unref(); | 162 40.0f, displ, nullptr, &cropRect))->unref(); |
163 drawClippedBitmap(canvas, 300, 300, paint); | 163 drawClippedBitmap(canvas, 300, 300, paint); |
164 paint.setImageFilter(SkDisplacementMapEffect::Create( | 164 paint.setImageFilter(SkDisplacementMapEffect::Create( |
165 SkDisplacementMapEffect::kR_ChannelSelectorType, | 165 SkDisplacementMapEffect::kR_ChannelSelectorType, |
166 SkDisplacementMapEffect::kA_ChannelSelectorType, | 166 SkDisplacementMapEffect::kA_ChannelSelectorType, |
167 40.0f, displ, NULL, &cropRect))->unref(); | 167 40.0f, displ, nullptr, &cropRect))->unref(); |
168 drawClippedBitmap(canvas, 400, 300, paint); | 168 drawClippedBitmap(canvas, 400, 300, paint); |
169 | 169 |
170 // Tests for images of different sizes | 170 // Tests for images of different sizes |
171 displ.reset(SkBitmapSource::Create(fSmall)); | 171 displ.reset(SkBitmapSource::Create(fSmall)); |
172 paint.setImageFilter(SkDisplacementMapEffect::Create( | 172 paint.setImageFilter(SkDisplacementMapEffect::Create( |
173 SkDisplacementMapEffect::kR_ChannelSelectorType, | 173 SkDisplacementMapEffect::kR_ChannelSelectorType, |
174 SkDisplacementMapEffect::kG_ChannelSelectorType, | 174 SkDisplacementMapEffect::kG_ChannelSelectorType, |
175 40.0f, displ))->unref(); | 175 40.0f, displ))->unref(); |
176 drawClippedBitmap(canvas, 0, 400, paint); | 176 drawClippedBitmap(canvas, 0, 400, paint); |
177 displ.reset(SkBitmapSource::Create(fLarge)); | 177 displ.reset(SkBitmapSource::Create(fLarge)); |
(...skipping 14 matching lines...) Expand all Loading... |
192 SkDisplacementMapEffect::kA_ChannelSelectorType, | 192 SkDisplacementMapEffect::kA_ChannelSelectorType, |
193 40.0f, displ))->unref(); | 193 40.0f, displ))->unref(); |
194 drawClippedBitmap(canvas, 300, 400, paint); | 194 drawClippedBitmap(canvas, 300, 400, paint); |
195 | 195 |
196 // Test for no given displacement input. In this case, both displacement | 196 // Test for no given displacement input. In this case, both displacement |
197 // and color should use the same bitmap, given to SkCanvas::drawBitmap() | 197 // and color should use the same bitmap, given to SkCanvas::drawBitmap() |
198 // as an input argument. | 198 // as an input argument. |
199 paint.setImageFilter(SkDisplacementMapEffect::Create( | 199 paint.setImageFilter(SkDisplacementMapEffect::Create( |
200 SkDisplacementMapEffect::kG_ChannelSelectorType, | 200 SkDisplacementMapEffect::kG_ChannelSelectorType, |
201 SkDisplacementMapEffect::kA_ChannelSelectorType, | 201 SkDisplacementMapEffect::kA_ChannelSelectorType, |
202 40.0f, NULL))->unref(); | 202 40.0f, nullptr))->unref(); |
203 drawClippedBitmap(canvas, 400, 400, paint); | 203 drawClippedBitmap(canvas, 400, 400, paint); |
204 } | 204 } |
205 | 205 |
206 private: | 206 private: |
207 typedef GM INHERITED; | 207 typedef GM INHERITED; |
208 SkBitmap fBitmap, fCheckerboard, fSmall, fLarge, fLargeW, fLargeH; | 208 SkBitmap fBitmap, fCheckerboard, fSmall, fLarge, fLargeW, fLargeH; |
209 bool fInitialized; | 209 bool fInitialized; |
210 }; | 210 }; |
211 | 211 |
212 ////////////////////////////////////////////////////////////////////////////// | 212 ////////////////////////////////////////////////////////////////////////////// |
213 | 213 |
214 static GM* MyFactory(void*) { return new DisplacementMapGM; } | 214 static GM* MyFactory(void*) { return new DisplacementMapGM; } |
215 static GMRegistry reg(MyFactory); | 215 static GMRegistry reg(MyFactory); |
216 | 216 |
217 } | 217 } |
OLD | NEW |