| 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 "Fuzz.h" | 7 #include "Fuzz.h" |
| 8 #include "Sk1DPathEffect.h" | 8 #include "Sk1DPathEffect.h" |
| 9 #include "Sk2DPathEffect.h" | 9 #include "Sk2DPathEffect.h" |
| 10 #include "SkAlphaThresholdFilter.h" | 10 #include "SkAlphaThresholdFilter.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "SkMergeImageFilter.h" | 34 #include "SkMergeImageFilter.h" |
| 35 #include "SkMorphologyImageFilter.h" | 35 #include "SkMorphologyImageFilter.h" |
| 36 #include "SkOffsetImageFilter.h" | 36 #include "SkOffsetImageFilter.h" |
| 37 #include "SkPaintImageFilter.h" | 37 #include "SkPaintImageFilter.h" |
| 38 #include "SkPerlinNoiseShader.h" | 38 #include "SkPerlinNoiseShader.h" |
| 39 #include "SkPictureImageFilter.h" | 39 #include "SkPictureImageFilter.h" |
| 40 #include "SkPictureRecorder.h" | 40 #include "SkPictureRecorder.h" |
| 41 #include "SkPoint3.h" | 41 #include "SkPoint3.h" |
| 42 #include "SkRandom.h" | 42 #include "SkRandom.h" |
| 43 #include "SkTableColorFilter.h" | 43 #include "SkTableColorFilter.h" |
| 44 #include "SkTestImageFilters.h" | |
| 45 #include "SkTileImageFilter.h" | 44 #include "SkTileImageFilter.h" |
| 46 #include "SkTypeface.h" | 45 #include "SkTypeface.h" |
| 47 #include "SkXfermodeImageFilter.h" | 46 #include "SkXfermodeImageFilter.h" |
| 48 #include <stdio.h> | 47 #include <stdio.h> |
| 49 #include <time.h> | 48 #include <time.h> |
| 50 | 49 |
| 51 #define SK_ADD_RANDOM_BIT_FLIPS | 50 #define SK_ADD_RANDOM_BIT_FLIPS |
| 52 | 51 |
| 53 static Fuzz* fuzz; | 52 static Fuzz* fuzz; |
| 54 static const int kBitmapSize = 24; | 53 static const int kBitmapSize = 24; |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 | 533 |
| 535 static sk_sp<SkImageFilter> make_image_filter(bool canBeNull) { | 534 static sk_sp<SkImageFilter> make_image_filter(bool canBeNull) { |
| 536 sk_sp<SkImageFilter> filter; | 535 sk_sp<SkImageFilter> filter; |
| 537 | 536 |
| 538 // Add a 1 in 3 chance to get a nullptr input | 537 // Add a 1 in 3 chance to get a nullptr input |
| 539 if (canBeNull && (R(3) == 1)) { | 538 if (canBeNull && (R(3) == 1)) { |
| 540 return filter; | 539 return filter; |
| 541 } | 540 } |
| 542 | 541 |
| 543 enum { ALPHA_THRESHOLD, MERGE, COLOR, LUT3D, BLUR, MAGNIFIER, | 542 enum { ALPHA_THRESHOLD, MERGE, COLOR, LUT3D, BLUR, MAGNIFIER, |
| 544 DOWN_SAMPLE, XFERMODE, OFFSET, MATRIX, MATRIX_CONVOLUTION, COMPOSE, | 543 XFERMODE, OFFSET, MATRIX, MATRIX_CONVOLUTION, COMPOSE, |
| 545 DISTANT_LIGHT, POINT_LIGHT, SPOT_LIGHT, NOISE, DROP_SHADOW, | 544 DISTANT_LIGHT, POINT_LIGHT, SPOT_LIGHT, NOISE, DROP_SHADOW, |
| 546 MORPHOLOGY, BITMAP, DISPLACE, TILE, PICTURE, PAINT, NUM_FILTERS }; | 545 MORPHOLOGY, BITMAP, DISPLACE, TILE, PICTURE, PAINT, NUM_FILTERS }; |
| 547 | 546 |
| 548 switch (R(NUM_FILTERS)) { | 547 switch (R(NUM_FILTERS)) { |
| 549 case ALPHA_THRESHOLD: | 548 case ALPHA_THRESHOLD: |
| 550 filter = SkAlphaThresholdFilter::Make(make_region(), | 549 filter = SkAlphaThresholdFilter::Make(make_region(), |
| 551 make_scalar(), | 550 make_scalar(), |
| 552 make_scalar(), | 551 make_scalar(), |
| 553 make_image_filter()); | 552 make_image_filter()); |
| 554 break; | 553 break; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 574 case BLUR: | 573 case BLUR: |
| 575 filter = SkBlurImageFilter::Make(make_scalar(true), | 574 filter = SkBlurImageFilter::Make(make_scalar(true), |
| 576 make_scalar(true), | 575 make_scalar(true), |
| 577 make_image_filter()); | 576 make_image_filter()); |
| 578 break; | 577 break; |
| 579 case MAGNIFIER: | 578 case MAGNIFIER: |
| 580 filter = SkMagnifierImageFilter::Make(make_rect(), | 579 filter = SkMagnifierImageFilter::Make(make_rect(), |
| 581 make_scalar(true), | 580 make_scalar(true), |
| 582 make_image_filter()); | 581 make_image_filter()); |
| 583 break; | 582 break; |
| 584 case DOWN_SAMPLE: | |
| 585 filter = SkDownSampleImageFilter::Make(make_scalar(), make_image_filter(
)); | |
| 586 break; | |
| 587 case XFERMODE: | 583 case XFERMODE: |
| 588 filter = SkXfermodeImageFilter::Make(SkXfermode::Make(make_xfermode()), | 584 filter = SkXfermodeImageFilter::Make(SkXfermode::Make(make_xfermode()), |
| 589 make_image_filter(), | 585 make_image_filter(), |
| 590 make_image_filter(), | 586 make_image_filter(), |
| 591 nullptr); | 587 nullptr); |
| 592 break; | 588 break; |
| 593 case OFFSET: | 589 case OFFSET: |
| 594 filter = SkOffsetImageFilter::Make(make_scalar(), make_scalar(), make_im
age_filter()); | 590 filter = SkOffsetImageFilter::Make(make_scalar(), make_scalar(), make_im
age_filter()); |
| 595 break; | 591 break; |
| 596 case MATRIX: | 592 case MATRIX: |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 DEF_FUZZ(SerializedImageFilter, f) { | 775 DEF_FUZZ(SerializedImageFilter, f) { |
| 780 fuzz = f; | 776 fuzz = f; |
| 781 SkImageFilter* filter = make_serialized_image_filter(); | 777 SkImageFilter* filter = make_serialized_image_filter(); |
| 782 | 778 |
| 783 SkPaint paint; | 779 SkPaint paint; |
| 784 SkSafeUnref(paint.setImageFilter(filter)); | 780 SkSafeUnref(paint.setImageFilter(filter)); |
| 785 SkBitmap bitmap; | 781 SkBitmap bitmap; |
| 786 SkCanvas canvas(bitmap); | 782 SkCanvas canvas(bitmap); |
| 787 drawClippedBitmap(&canvas, 0, 0, paint); | 783 drawClippedBitmap(&canvas, 0, 0, paint); |
| 788 } | 784 } |
| OLD | NEW |