aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-27 13:52:51 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-27 13:52:51 +0000
commit067fe482663de257c7c4e2887462269813ced255 (patch)
tree47755789468f1d1eaa0a2dc998a5e5d74480ec00
parentb0c769abe1e1a0e4aa6a8008d7f3c113bc3e7cf7 (diff)
Adding new filters to fuzzer
New image filters were added since the last time I worked on the fuzzer, so I added them to the fuzzer. Same changes will be made to the clusterfuzz fuzzer. BUG=skia: R=bsalomon@google.com Author: sugoi@chromium.org Review URL: https://codereview.chromium.org/300153002 git-svn-id: http://skia.googlecode.com/svn/trunk@14887 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--samplecode/SampleFilterFuzz.cpp56
1 files changed, 55 insertions, 1 deletions
diff --git a/samplecode/SampleFilterFuzz.cpp b/samplecode/SampleFilterFuzz.cpp
index 8d58b9b8de..11a5ec12e3 100644
--- a/samplecode/SampleFilterFuzz.cpp
+++ b/samplecode/SampleFilterFuzz.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
#include "SampleCode.h"
+#include "SkAlphaThresholdFilter.h"
#include "SkBicubicImageFilter.h"
#include "SkBitmapDevice.h"
#include "SkBitmapSource.h"
@@ -19,6 +20,8 @@
#include "SkFlattenableSerialization.h"
#include "SkLightingImageFilter.h"
#include "SkMagnifierImageFilter.h"
+#include "SkMatrixImageFilter.h"
+#include "SkMatrixConvolutionImageFilter.h"
#include "SkMergeImageFilter.h"
#include "SkMorphologyImageFilter.h"
#include "SkOffsetImageFilter.h"
@@ -26,6 +29,7 @@
#include "SkPictureImageFilter.h"
#include "SkRandom.h"
#include "SkRectShaderImageFilter.h"
+#include "SkTestImageFilters.h"
#include "SkTileImageFilter.h"
#include "SkView.h"
#include "SkXfermodeImageFilter.h"
@@ -95,6 +99,22 @@ static SkRect make_rect() {
SkIntToScalar(R(static_cast<float>(kBitmapSize))));
}
+static SkRegion make_region() {
+ SkIRect iRegion = SkIRect::MakeXYWH(SkIntToScalar(R(static_cast<float>(kBitmapSize))),
+ SkIntToScalar(R(static_cast<float>(kBitmapSize))),
+ SkIntToScalar(R(static_cast<float>(kBitmapSize))),
+ SkIntToScalar(R(static_cast<float>(kBitmapSize))));
+ return SkRegion(iRegion);
+}
+
+static SkMatrix make_matrix() {
+ SkMatrix m;
+ for (int i = 0; i < 9; ++i) {
+ m[i] = make_scalar();
+ }
+ return m;
+}
+
static SkXfermode::Mode make_xfermode() {
return static_cast<SkXfermode::Mode>(R(SkXfermode::kLastMode+1));
}
@@ -216,11 +236,15 @@ static SkImageFilter* make_image_filter(bool canBeNull = true) {
// Add a 1 in 3 chance to get a NULL input
if (canBeNull && (R(3) == 1)) { return filter; }
- enum { BICUBIC, MERGE, COLOR, BLUR, MAGNIFIER, XFERMODE, OFFSET, COMPOSE,
+ enum { ALPHA_THRESHOLD, BICUBIC, MERGE, COLOR, BLUR, MAGNIFIER,
+ DOWN_SAMPLE, XFERMODE, OFFSET, MATRIX, MATRIX_CONVOLUTION, COMPOSE,
DISTANT_LIGHT, POINT_LIGHT, SPOT_LIGHT, NOISE, DROP_SHADOW,
MORPHOLOGY, BITMAP, DISPLACE, TILE, PICTURE, NUM_FILTERS };
switch (R(NUM_FILTERS)) {
+ case ALPHA_THRESHOLD:
+ filter = SkAlphaThresholdFilter::Create(make_region(), make_scalar(), make_scalar());
+ break;
case BICUBIC:
// Scale is set to 1 here so that it can fit in the DAG without resizing the output
filter = SkBicubicImageFilter::CreateMitchell(SkSize::Make(1, 1), make_image_filter());
@@ -242,6 +266,9 @@ static SkImageFilter* make_image_filter(bool canBeNull = true) {
case MAGNIFIER:
filter = SkMagnifierImageFilter::Create(make_rect(), make_scalar(true));
break;
+ case DOWN_SAMPLE:
+ filter = SkDownSampleImageFilter::Create(make_scalar());
+ break;
case XFERMODE:
{
SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(make_xfermode()));
@@ -251,6 +278,33 @@ static SkImageFilter* make_image_filter(bool canBeNull = true) {
case OFFSET:
filter = SkOffsetImageFilter::Create(make_scalar(), make_scalar(), make_image_filter());
break;
+ case MATRIX:
+ filter = SkMatrixImageFilter::Create(make_matrix(),
+ (SkPaint::FilterLevel)R(4),
+ make_image_filter());
+ break;
+ case MATRIX_CONVOLUTION:
+ {
+ SkImageFilter::CropRect cropR(SkRect::MakeWH(SkIntToScalar(kBitmapSize),
+ SkIntToScalar(kBitmapSize)));
+ SkISize size = SkISize::Make(R(10)+1, R(10)+1);
+ int arraySize = size.width() * size.height();
+ SkTArray<SkScalar> kernel(arraySize);
+ for (int i = 0; i < arraySize; ++i) {
+ kernel.push_back() = make_scalar();
+ }
+ SkIPoint kernelOffset = SkIPoint::Make(R(size.width()), R(size.height()));
+ filter = SkMatrixConvolutionImageFilter::Create(size,
+ kernel.begin(),
+ make_scalar(),
+ make_scalar(),
+ kernelOffset,
+ (SkMatrixConvolutionImageFilter::TileMode)R(3),
+ R(2) == 1,
+ make_image_filter(),
+ &cropR);
+ }
+ break;
case COMPOSE:
filter = SkComposeImageFilter::Create(make_image_filter(), make_image_filter());
break;