Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1174)

Unified Diff: samplecode/SampleFilterFuzz.cpp

Issue 300153002: Adding new filters to fuzzer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SampleFilterFuzz.cpp
diff --git a/samplecode/SampleFilterFuzz.cpp b/samplecode/SampleFilterFuzz.cpp
index 8d58b9b8de5b984cb2609218325cdc1015205e53..11a5ec12e34c5ded3c86b83eac4f863494a0036b 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;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698