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 "gm.h" | 8 #include "gm.h" |
9 #include "SkDisplacementMapEffect.h" | 9 #include "SkDisplacementMapEffect.h" |
10 #include "SkBitmapSource.h" | 10 #include "SkBitmapSource.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 (SkDisplacementMapEffect::kG_ChannelSelectorType, | 176 (SkDisplacementMapEffect::kG_ChannelSelectorType, |
177 SkDisplacementMapEffect::kA_ChannelSelectorType, | 177 SkDisplacementMapEffect::kA_ChannelSelectorType, |
178 40.0f, displ, NULL, &cropRect)))->unref(); | 178 40.0f, displ, NULL, &cropRect)))->unref(); |
179 drawClippedBitmap(canvas, 300, 300, paint); | 179 drawClippedBitmap(canvas, 300, 300, paint); |
180 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect, | 180 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect, |
181 (SkDisplacementMapEffect::kR_ChannelSelectorType, | 181 (SkDisplacementMapEffect::kR_ChannelSelectorType, |
182 SkDisplacementMapEffect::kA_ChannelSelectorType, | 182 SkDisplacementMapEffect::kA_ChannelSelectorType, |
183 40.0f, displ, NULL, &cropRect)))->unref(); | 183 40.0f, displ, NULL, &cropRect)))->unref(); |
184 drawClippedBitmap(canvas, 400, 300, paint); | 184 drawClippedBitmap(canvas, 400, 300, paint); |
185 | 185 |
| 186 // Tests for images of different sizes |
186 displ.reset(SkNEW_ARGS(SkBitmapSource, (fSmall))); | 187 displ.reset(SkNEW_ARGS(SkBitmapSource, (fSmall))); |
187 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect, | 188 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect, |
188 (SkDisplacementMapEffect::kR_ChannelSelectorType, | 189 (SkDisplacementMapEffect::kR_ChannelSelectorType, |
189 SkDisplacementMapEffect::kG_ChannelSelectorType, | 190 SkDisplacementMapEffect::kG_ChannelSelectorType, |
190 40.0f, displ)))->unref(); | 191 40.0f, displ)))->unref(); |
191 drawClippedBitmap(canvas, 0, 400, paint); | 192 drawClippedBitmap(canvas, 0, 400, paint); |
192 displ.reset(SkNEW_ARGS(SkBitmapSource, (fLarge))); | 193 displ.reset(SkNEW_ARGS(SkBitmapSource, (fLarge))); |
193 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect, | 194 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect, |
194 (SkDisplacementMapEffect::kB_ChannelSelectorType, | 195 (SkDisplacementMapEffect::kB_ChannelSelectorType, |
195 SkDisplacementMapEffect::kA_ChannelSelectorType, | 196 SkDisplacementMapEffect::kA_ChannelSelectorType, |
196 40.0f, displ)))->unref(); | 197 40.0f, displ)))->unref(); |
197 drawClippedBitmap(canvas, 100, 400, paint); | 198 drawClippedBitmap(canvas, 100, 400, paint); |
198 displ.reset(SkNEW_ARGS(SkBitmapSource, (fLargeW))); | 199 displ.reset(SkNEW_ARGS(SkBitmapSource, (fLargeW))); |
199 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect, | 200 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect, |
200 (SkDisplacementMapEffect::kR_ChannelSelectorType, | 201 (SkDisplacementMapEffect::kR_ChannelSelectorType, |
201 SkDisplacementMapEffect::kB_ChannelSelectorType, | 202 SkDisplacementMapEffect::kB_ChannelSelectorType, |
202 40.0f, displ)))->unref(); | 203 40.0f, displ)))->unref(); |
203 drawClippedBitmap(canvas, 200, 400, paint); | 204 drawClippedBitmap(canvas, 200, 400, paint); |
204 displ.reset(SkNEW_ARGS(SkBitmapSource, (fLargeH))); | 205 displ.reset(SkNEW_ARGS(SkBitmapSource, (fLargeH))); |
205 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect, | 206 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect, |
206 (SkDisplacementMapEffect::kG_ChannelSelectorType, | 207 (SkDisplacementMapEffect::kG_ChannelSelectorType, |
207 SkDisplacementMapEffect::kA_ChannelSelectorType, | 208 SkDisplacementMapEffect::kA_ChannelSelectorType, |
208 40.0f, displ)))->unref(); | 209 40.0f, displ)))->unref(); |
209 drawClippedBitmap(canvas, 300, 400, paint); | 210 drawClippedBitmap(canvas, 300, 400, paint); |
| 211 |
| 212 // Test for no given displacement input. In this case, both displacement |
| 213 // and color should use the same bitmap, given to SkCanvas::drawBitmap() |
| 214 // as an input argument. |
| 215 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect, |
| 216 (SkDisplacementMapEffect::kG_ChannelSelectorType, |
| 217 SkDisplacementMapEffect::kA_ChannelSelectorType, |
| 218 40.0f, NULL)))->unref(); |
| 219 drawClippedBitmap(canvas, 400, 400, paint); |
210 } | 220 } |
211 | 221 |
212 private: | 222 private: |
213 typedef GM INHERITED; | 223 typedef GM INHERITED; |
214 SkBitmap fBitmap, fCheckerboard, fSmall, fLarge, fLargeW, fLargeH; | 224 SkBitmap fBitmap, fCheckerboard, fSmall, fLarge, fLargeW, fLargeH; |
215 bool fInitialized; | 225 bool fInitialized; |
216 }; | 226 }; |
217 | 227 |
218 ////////////////////////////////////////////////////////////////////////////// | 228 ////////////////////////////////////////////////////////////////////////////// |
219 | 229 |
220 static GM* MyFactory(void*) { return new DisplacementMapGM; } | 230 static GM* MyFactory(void*) { return new DisplacementMapGM; } |
221 static GMRegistry reg(MyFactory); | 231 static GMRegistry reg(MyFactory); |
222 | 232 |
223 } | 233 } |
OLD | NEW |