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

Side by Side Diff: samplecode/SampleFilterFuzz.cpp

Issue 140993004: Adding SkPictureImageFilter to the fuzzer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkBicubicImageFilter.h" 8 #include "SkBicubicImageFilter.h"
9 #include "SkBitmapDevice.h" 9 #include "SkBitmapDevice.h"
10 #include "SkBitmapSource.h" 10 #include "SkBitmapSource.h"
11 #include "SkBlurImageFilter.h" 11 #include "SkBlurImageFilter.h"
12 #include "SkCanvas.h" 12 #include "SkCanvas.h"
13 #include "SkColorFilter.h" 13 #include "SkColorFilter.h"
14 #include "SkColorFilterImageFilter.h" 14 #include "SkColorFilterImageFilter.h"
15 #include "SkComposeImageFilter.h" 15 #include "SkComposeImageFilter.h"
16 #include "SkData.h" 16 #include "SkData.h"
17 #include "SkDisplacementMapEffect.h" 17 #include "SkDisplacementMapEffect.h"
18 #include "SkDropShadowImageFilter.h" 18 #include "SkDropShadowImageFilter.h"
19 #include "SkFlattenableSerialization.h" 19 #include "SkFlattenableSerialization.h"
20 #include "SkLightingImageFilter.h" 20 #include "SkLightingImageFilter.h"
21 #include "SkMagnifierImageFilter.h" 21 #include "SkMagnifierImageFilter.h"
22 #include "SkMergeImageFilter.h" 22 #include "SkMergeImageFilter.h"
23 #include "SkMorphologyImageFilter.h" 23 #include "SkMorphologyImageFilter.h"
24 #include "SkOffsetImageFilter.h" 24 #include "SkOffsetImageFilter.h"
25 #include "SkPerlinNoiseShader.h" 25 #include "SkPerlinNoiseShader.h"
26 #include "SkPictureImageFilter.h"
26 #include "SkRandom.h" 27 #include "SkRandom.h"
27 #include "SkRectShaderImageFilter.h" 28 #include "SkRectShaderImageFilter.h"
28 #include "SkTileImageFilter.h" 29 #include "SkTileImageFilter.h"
29 #include "SkView.h" 30 #include "SkView.h"
30 #include "SkXfermodeImageFilter.h" 31 #include "SkXfermodeImageFilter.h"
31 #include <stdio.h> 32 #include <stdio.h>
32 #include <time.h> 33 #include <time.h>
33 34
34 //#define SK_ADD_RANDOM_BIT_FLIPS 35 //#define SK_ADD_RANDOM_BIT_FLIPS
35 //#define SK_FUZZER_IS_VERBOSE 36 //#define SK_FUZZER_IS_VERBOSE
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 167 }
167 168
168 static SkImageFilter* make_image_filter(bool canBeNull = true) { 169 static SkImageFilter* make_image_filter(bool canBeNull = true) {
169 SkImageFilter* filter = 0; 170 SkImageFilter* filter = 0;
170 171
171 // Add a 1 in 3 chance to get a NULL input 172 // Add a 1 in 3 chance to get a NULL input
172 if (canBeNull && (R(3) == 1)) { return filter; } 173 if (canBeNull && (R(3) == 1)) { return filter; }
173 174
174 enum { BICUBIC, MERGE, COLOR, BLUR, MAGNIFIER, XFERMODE, OFFSET, COMPOSE, 175 enum { BICUBIC, MERGE, COLOR, BLUR, MAGNIFIER, XFERMODE, OFFSET, COMPOSE,
175 DISTANT_LIGHT, POINT_LIGHT, SPOT_LIGHT, NOISE, DROP_SHADOW, 176 DISTANT_LIGHT, POINT_LIGHT, SPOT_LIGHT, NOISE, DROP_SHADOW,
176 MORPHOLOGY, BITMAP, DISPLACE, TILE, NUM_FILTERS }; 177 MORPHOLOGY, BITMAP, DISPLACE, TILE, PICTURE, NUM_FILTERS };
177 178
178 switch (R(NUM_FILTERS)) { 179 switch (R(NUM_FILTERS)) {
179 case BICUBIC: 180 case BICUBIC:
180 // Scale is set to 1 here so that it can fit in the DAG without resizing the output 181 // Scale is set to 1 here so that it can fit in the DAG without resizing the output
181 filter = SkBicubicImageFilter::CreateMitchell(SkSize::Make(1, 1), make_i mage_filter()); 182 filter = SkBicubicImageFilter::CreateMitchell(SkSize::Make(1, 1), make_i mage_filter());
182 break; 183 break;
183 case MERGE: 184 case MERGE:
184 filter = new SkMergeImageFilter(make_image_filter(), make_image_filter() , make_xfermode()); 185 filter = new SkMergeImageFilter(make_image_filter(), make_image_filter() , make_xfermode());
185 break; 186 break;
186 case COLOR: 187 case COLOR:
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 } 268 }
268 break; 269 break;
269 case DISPLACE: 270 case DISPLACE:
270 filter = new SkDisplacementMapEffect(make_channel_selector_type(), 271 filter = new SkDisplacementMapEffect(make_channel_selector_type(),
271 make_channel_selector_type(), make_scalar(), 272 make_channel_selector_type(), make_scalar(),
272 make_image_filter(false), make_image_filter()); 273 make_image_filter(false), make_image_filter());
273 break; 274 break;
274 case TILE: 275 case TILE:
275 filter = new SkTileImageFilter(make_rect(), make_rect(), make_image_filt er(false)); 276 filter = new SkTileImageFilter(make_rect(), make_rect(), make_image_filt er(false));
276 break; 277 break;
278 case PICTURE:
279 filter = new SkPictureImageFilter(NULL, make_rect());
280 break;
277 default: 281 default:
278 break; 282 break;
279 } 283 }
280 return (filter || canBeNull) ? filter : make_image_filter(canBeNull); 284 return (filter || canBeNull) ? filter : make_image_filter(canBeNull);
281 } 285 }
282 286
283 static SkImageFilter* make_serialized_image_filter() { 287 static SkImageFilter* make_serialized_image_filter() {
284 SkAutoTUnref<SkImageFilter> filter(make_image_filter(false)); 288 SkAutoTUnref<SkImageFilter> filter(make_image_filter(false));
285 SkAutoTUnref<SkData> data(SkValidatingSerializeFlattenable(filter)); 289 SkAutoTUnref<SkData> data(SkValidatingSerializeFlattenable(filter));
286 const unsigned char* ptr = static_cast<const unsigned char*>(data->data()); 290 const unsigned char* ptr = static_cast<const unsigned char*>(data->data());
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 } 374 }
371 375
372 private: 376 private:
373 typedef SkView INHERITED; 377 typedef SkView INHERITED;
374 }; 378 };
375 379
376 ////////////////////////////////////////////////////////////////////////////// 380 //////////////////////////////////////////////////////////////////////////////
377 381
378 static SkView* MyFactory() { return new ImageFilterFuzzView; } 382 static SkView* MyFactory() { return new ImageFilterFuzzView; }
379 static SkViewRegister reg(MyFactory); 383 static SkViewRegister reg(MyFactory);
OLDNEW
« 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