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 #include "SampleCode.h" | 7 #include "SampleCode.h" |
8 #include "SkAlphaThresholdFilter.h" | 8 #include "SkAlphaThresholdFilter.h" |
9 #include "SkBicubicImageFilter.h" | |
10 #include "SkBitmapDevice.h" | 9 #include "SkBitmapDevice.h" |
11 #include "SkBitmapSource.h" | 10 #include "SkBitmapSource.h" |
12 #include "SkBlurImageFilter.h" | 11 #include "SkBlurImageFilter.h" |
13 #include "SkCanvas.h" | 12 #include "SkCanvas.h" |
14 #include "SkColorFilter.h" | 13 #include "SkColorFilter.h" |
15 #include "SkColorFilterImageFilter.h" | 14 #include "SkColorFilterImageFilter.h" |
16 #include "SkComposeImageFilter.h" | 15 #include "SkComposeImageFilter.h" |
17 #include "SkData.h" | 16 #include "SkData.h" |
18 #include "SkDisplacementMapEffect.h" | 17 #include "SkDisplacementMapEffect.h" |
19 #include "SkDropShadowImageFilter.h" | 18 #include "SkDropShadowImageFilter.h" |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 paint.setTextSize(SkIntToScalar(kBitmapSize/3)); | 227 paint.setTextSize(SkIntToScalar(kBitmapSize/3)); |
229 canvas->drawText("Picture", 7, SkIntToScalar(kBitmapSize/2), SkIntToScalar(k
BitmapSize/4), paint); | 228 canvas->drawText("Picture", 7, SkIntToScalar(kBitmapSize/2), SkIntToScalar(k
BitmapSize/4), paint); |
230 } | 229 } |
231 | 230 |
232 static SkImageFilter* make_image_filter(bool canBeNull = true) { | 231 static SkImageFilter* make_image_filter(bool canBeNull = true) { |
233 SkImageFilter* filter = 0; | 232 SkImageFilter* filter = 0; |
234 | 233 |
235 // Add a 1 in 3 chance to get a NULL input | 234 // Add a 1 in 3 chance to get a NULL input |
236 if (canBeNull && (R(3) == 1)) { return filter; } | 235 if (canBeNull && (R(3) == 1)) { return filter; } |
237 | 236 |
238 enum { ALPHA_THRESHOLD, BICUBIC, MERGE, COLOR, BLUR, MAGNIFIER, | 237 enum { ALPHA_THRESHOLD, MERGE, COLOR, BLUR, MAGNIFIER, |
239 DOWN_SAMPLE, XFERMODE, OFFSET, MATRIX, MATRIX_CONVOLUTION, COMPOSE, | 238 DOWN_SAMPLE, XFERMODE, OFFSET, MATRIX, MATRIX_CONVOLUTION, COMPOSE, |
240 DISTANT_LIGHT, POINT_LIGHT, SPOT_LIGHT, NOISE, DROP_SHADOW, | 239 DISTANT_LIGHT, POINT_LIGHT, SPOT_LIGHT, NOISE, DROP_SHADOW, |
241 MORPHOLOGY, BITMAP, DISPLACE, TILE, PICTURE, NUM_FILTERS }; | 240 MORPHOLOGY, BITMAP, DISPLACE, TILE, PICTURE, NUM_FILTERS }; |
242 | 241 |
243 switch (R(NUM_FILTERS)) { | 242 switch (R(NUM_FILTERS)) { |
244 case ALPHA_THRESHOLD: | 243 case ALPHA_THRESHOLD: |
245 filter = SkAlphaThresholdFilter::Create(make_region(), make_scalar(), ma
ke_scalar()); | 244 filter = SkAlphaThresholdFilter::Create(make_region(), make_scalar(), ma
ke_scalar()); |
246 break; | 245 break; |
247 case BICUBIC: | |
248 // Scale is set to 1 here so that it can fit in the DAG without resizing
the output | |
249 filter = SkBicubicImageFilter::CreateMitchell(SkSize::Make(1, 1), make_i
mage_filter()); | |
250 break; | |
251 case MERGE: | 246 case MERGE: |
252 filter = SkMergeImageFilter::Create(make_image_filter(), make_image_filt
er(), make_xfermode()); | 247 filter = SkMergeImageFilter::Create(make_image_filter(), make_image_filt
er(), make_xfermode()); |
253 break; | 248 break; |
254 case COLOR: | 249 case COLOR: |
255 { | 250 { |
256 SkAutoTUnref<SkColorFilter> cf((R(2) == 1) ? | 251 SkAutoTUnref<SkColorFilter> cf((R(2) == 1) ? |
257 SkColorFilter::CreateModeFilter(make_color(), make_xfermode())
: | 252 SkColorFilter::CreateModeFilter(make_color(), make_xfermode())
: |
258 SkColorFilter::CreateLightingFilter(make_color(), make_color())
); | 253 SkColorFilter::CreateLightingFilter(make_color(), make_color())
); |
259 filter = cf.get() ? SkColorFilterImageFilter::Create(cf, make_image_filt
er()) : 0; | 254 filter = cf.get() ? SkColorFilterImageFilter::Create(cf, make_image_filt
er()) : 0; |
260 } | 255 } |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 } | 474 } |
480 | 475 |
481 private: | 476 private: |
482 typedef SkView INHERITED; | 477 typedef SkView INHERITED; |
483 }; | 478 }; |
484 | 479 |
485 ////////////////////////////////////////////////////////////////////////////// | 480 ////////////////////////////////////////////////////////////////////////////// |
486 | 481 |
487 static SkView* MyFactory() { return new ImageFilterFuzzView; } | 482 static SkView* MyFactory() { return new ImageFilterFuzzView; } |
488 static SkViewRegister reg(MyFactory); | 483 static SkViewRegister reg(MyFactory); |
OLD | NEW |