blob: 103d8c4a56db4d717db2bf36c2b5383d6ef4c28f [file] [log] [blame]
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +00001/*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7#include "SampleCode.h"
ajuma77b6ba32016-01-08 14:58:35 -08008#include "Sk1DPathEffect.h"
9#include "Sk2DPathEffect.h"
commit-bot@chromium.org067fe482014-05-27 13:52:51 +000010#include "SkAlphaThresholdFilter.h"
ajuma77b6ba32016-01-08 14:58:35 -080011#include "SkArcToPathEffect.h"
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +000012#include "SkBlurImageFilter.h"
ajuma77b6ba32016-01-08 14:58:35 -080013#include "SkBlurMaskFilter.h"
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +000014#include "SkCanvas.h"
sugoif11c5742014-10-27 08:03:56 -070015#include "SkColorCubeFilter.h"
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +000016#include "SkColorFilter.h"
17#include "SkColorFilterImageFilter.h"
ajuma77b6ba32016-01-08 14:58:35 -080018#include "SkColorMatrixFilter.h"
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +000019#include "SkComposeImageFilter.h"
ajuma77b6ba32016-01-08 14:58:35 -080020#include "SkCornerPathEffect.h"
21#include "SkDashPathEffect.h"
commit-bot@chromium.org77e079a2013-10-28 15:52:02 +000022#include "SkData.h"
ajuma77b6ba32016-01-08 14:58:35 -080023#include "SkDiscretePathEffect.h"
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +000024#include "SkDisplacementMapEffect.h"
25#include "SkDropShadowImageFilter.h"
ajuma77b6ba32016-01-08 14:58:35 -080026#include "SkEmbossMaskFilter.h"
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +000027#include "SkFlattenableSerialization.h"
fmalita5598b632015-09-15 11:26:13 -070028#include "SkImageSource.h"
ajuma77b6ba32016-01-08 14:58:35 -080029#include "SkLayerRasterizer.h"
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +000030#include "SkLightingImageFilter.h"
ajuma77b6ba32016-01-08 14:58:35 -080031#include "SkLumaColorFilter.h"
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +000032#include "SkMagnifierImageFilter.h"
commit-bot@chromium.org067fe482014-05-27 13:52:51 +000033#include "SkMatrixConvolutionImageFilter.h"
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +000034#include "SkMergeImageFilter.h"
35#include "SkMorphologyImageFilter.h"
36#include "SkOffsetImageFilter.h"
ajuma77b6ba32016-01-08 14:58:35 -080037#include "SkPaintImageFilter.h"
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +000038#include "SkPerlinNoiseShader.h"
commit-bot@chromium.org7b8d72d2014-01-16 22:54:41 +000039#include "SkPictureImageFilter.h"
senorblanco@chromium.org97f5fc62014-05-30 20:50:56 +000040#include "SkPictureRecorder.h"
robertphillips3d32d762015-07-13 13:16:44 -070041#include "SkPoint3.h"
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +000042#include "SkRandom.h"
ajuma77b6ba32016-01-08 14:58:35 -080043#include "SkTableColorFilter.h"
commit-bot@chromium.org067fe482014-05-27 13:52:51 +000044#include "SkTestImageFilters.h"
commit-bot@chromium.orgcd3b15c2013-12-04 17:06:49 +000045#include "SkTileImageFilter.h"
ajuma77b6ba32016-01-08 14:58:35 -080046#include "SkTypeface.h"
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +000047#include "SkView.h"
48#include "SkXfermodeImageFilter.h"
commit-bot@chromium.orgcd3b15c2013-12-04 17:06:49 +000049#include <stdio.h>
50#include <time.h>
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +000051
commit-bot@chromium.orgc2e9db32013-12-06 20:14:46 +000052//#define SK_ADD_RANDOM_BIT_FLIPS
53//#define SK_FUZZER_IS_VERBOSE
54
halcanary96fcdcc2015-08-27 07:41:13 -070055static const uint32_t kSeed = (uint32_t)(time(nullptr));
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +000056static SkRandom gRand(kSeed);
57static bool return_large = false;
58static bool return_undef = false;
59
60static const int kBitmapSize = 24;
61
62static int R(float x) {
63 return (int)floor(SkScalarToFloat(gRand.nextUScalar1()) * x);
64}
65
66#if defined _WIN32
67#pragma warning ( push )
68// we are intentionally causing an overflow here
69// (warning C4756: overflow in constant arithmetic)
70#pragma warning ( disable : 4756 )
71#endif
72
73static float huge() {
74 double d = 1e100;
75 float f = (float)d;
76 return f;
77}
78
79#if defined _WIN32
80#pragma warning ( pop )
81#endif
82
83static float make_number(bool positiveOnly) {
84 float f = positiveOnly ? 1.0f : 0.0f;
85 float v = f;
86 int sel;
87
88 if (return_large) sel = R(6); else sel = R(4);
89 if (!return_undef && sel == 0) sel = 1;
90
91 if (R(2) == 1) v = (float)(R(100)+f); else
92
93 switch (sel) {
94 case 0: break;
95 case 1: v = f; break;
96 case 2: v = 0.000001f; break;
97 case 3: v = 10000.0f; break;
98 case 4: v = 2000000000.0f; break;
99 case 5: v = huge(); break;
100 }
101
102 if (!positiveOnly && (R(4) == 1)) v = -v;
103 return v;
104}
105
106static SkScalar make_scalar(bool positiveOnly = false) {
commit-bot@chromium.org4b413c82013-11-25 19:44:07 +0000107 return make_number(positiveOnly);
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +0000108}
109
ajuma77b6ba32016-01-08 14:58:35 -0800110static SkString make_string() {
111 int length = R(1000);
112 SkString str(length);
113 for (int i = 0; i < length; ++i) {
114 str[i] = static_cast<char>(R(256));
115 }
116 return str;
117}
118
119static SkString make_font_name() {
120 int sel = R(8);
121
122 switch(sel) {
123 case 0: return SkString("Courier New");
124 case 1: return SkString("Helvetica");
125 case 2: return SkString("monospace");
126 case 3: return SkString("sans-serif");
127 case 4: return SkString("serif");
128 case 5: return SkString("Times");
129 case 6: return SkString("Times New Roman");
130 case 7:
131 default:
132 return make_string();
133 }
134}
135
136static bool make_bool() {
137 return R(2) == 1;
138}
139
commit-bot@chromium.orgcd3b15c2013-12-04 17:06:49 +0000140static SkRect make_rect() {
141 return SkRect::MakeWH(SkIntToScalar(R(static_cast<float>(kBitmapSize))),
142 SkIntToScalar(R(static_cast<float>(kBitmapSize))));
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +0000143}
144
commit-bot@chromium.org067fe482014-05-27 13:52:51 +0000145static SkRegion make_region() {
commit-bot@chromium.orgb859fe62014-05-27 17:03:25 +0000146 SkIRect iRegion = SkIRect::MakeXYWH(R(static_cast<float>(kBitmapSize)),
147 R(static_cast<float>(kBitmapSize)),
148 R(static_cast<float>(kBitmapSize)),
149 R(static_cast<float>(kBitmapSize)));
commit-bot@chromium.org067fe482014-05-27 13:52:51 +0000150 return SkRegion(iRegion);
151}
152
153static SkMatrix make_matrix() {
154 SkMatrix m;
155 for (int i = 0; i < 9; ++i) {
156 m[i] = make_scalar();
157 }
158 return m;
159}
160
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +0000161static SkXfermode::Mode make_xfermode() {
162 return static_cast<SkXfermode::Mode>(R(SkXfermode::kLastMode+1));
163}
164
ajuma77b6ba32016-01-08 14:58:35 -0800165static SkPaint::Align make_paint_align() {
166 return static_cast<SkPaint::Align>(R(SkPaint::kRight_Align+1));
167}
168
169static SkPaint::Hinting make_paint_hinting() {
170 return static_cast<SkPaint::Hinting>(R(SkPaint::kFull_Hinting+1));
171}
172
173static SkPaint::Style make_paint_style() {
174 return static_cast<SkPaint::Style>(R(SkPaint::kStrokeAndFill_Style+1));
175}
176
177static SkPaint::Cap make_paint_cap() {
178 return static_cast<SkPaint::Cap>(R(SkPaint::kDefault_Cap+1));
179}
180
181static SkPaint::Join make_paint_join() {
182 return static_cast<SkPaint::Join>(R(SkPaint::kDefault_Join+1));
183}
184
185static SkPaint::TextEncoding make_paint_text_encoding() {
186 return static_cast<SkPaint::TextEncoding>(R(SkPaint::kGlyphID_TextEncoding+1));
187}
188
189static SkBlurStyle make_blur_style() {
190 return static_cast<SkBlurStyle>(R(kLastEnum_SkBlurStyle+1));
191}
192
193static SkBlurMaskFilter::BlurFlags make_blur_mask_filter_flag() {
194 return static_cast<SkBlurMaskFilter::BlurFlags>(R(SkBlurMaskFilter::kAll_BlurFlag+1));
195}
196
197static SkFilterQuality make_filter_quality() {
198 return static_cast<SkFilterQuality>(R(kHigh_SkFilterQuality+1));
199}
200
201static SkTypeface::Style make_typeface_style() {
202 return static_cast<SkTypeface::Style>(R(SkTypeface::kBoldItalic+1));
203}
204
205static SkPath1DPathEffect::Style make_path_1d_path_effect_style() {
reedca726ab2016-02-22 12:50:25 -0800206 return static_cast<SkPath1DPathEffect::Style>(R((int)SkPath1DPathEffect::kLastEnum_Style + 1));
ajuma77b6ba32016-01-08 14:58:35 -0800207}
208
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +0000209static SkColor make_color() {
210 return (R(2) == 1) ? 0xFFC0F0A0 : 0xFF000090;
211}
212
sugoi234f0362014-10-23 13:59:52 -0700213static SkDropShadowImageFilter::ShadowMode make_shadow_mode() {
214 return (R(2) == 1) ? SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode :
215 SkDropShadowImageFilter::kDrawShadowOnly_ShadowMode;
216}
217
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +0000218static SkPoint3 make_point() {
robertphillips3d32d762015-07-13 13:16:44 -0700219 return SkPoint3::Make(make_scalar(), make_scalar(), make_scalar(true));
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +0000220}
221
222static SkDisplacementMapEffect::ChannelSelectorType make_channel_selector_type() {
223 return static_cast<SkDisplacementMapEffect::ChannelSelectorType>(R(4)+1);
224}
225
commit-bot@chromium.orga8c18312014-02-17 02:55:57 +0000226static bool valid_for_raster_canvas(const SkImageInfo& info) {
227 switch (info.colorType()) {
228 case kAlpha_8_SkColorType:
229 case kRGB_565_SkColorType:
230 return true;
commit-bot@chromium.org28fcae22014-04-11 17:15:40 +0000231 case kN32_SkColorType:
commit-bot@chromium.orga8c18312014-02-17 02:55:57 +0000232 return kPremul_SkAlphaType == info.alphaType() ||
233 kOpaque_SkAlphaType == info.alphaType();
234 default:
235 break;
commit-bot@chromium.orgef74fa12013-12-17 20:49:46 +0000236 }
commit-bot@chromium.orga8c18312014-02-17 02:55:57 +0000237 return false;
238}
239
240static SkColorType rand_colortype() {
241 return (SkColorType)R(kLastEnum_SkColorType + 1);
242}
243
244static void rand_bitmap_for_canvas(SkBitmap* bitmap) {
245 SkImageInfo info;
246 do {
247 info = SkImageInfo::Make(kBitmapSize, kBitmapSize, rand_colortype(),
248 kPremul_SkAlphaType);
reed84825042014-09-02 12:50:45 -0700249 } while (!valid_for_raster_canvas(info) || !bitmap->tryAllocPixels(info));
commit-bot@chromium.orga8c18312014-02-17 02:55:57 +0000250}
251
252static void make_g_bitmap(SkBitmap& bitmap) {
253 rand_bitmap_for_canvas(&bitmap);
254
255 SkCanvas canvas(bitmap);
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +0000256 canvas.clear(0x00000000);
257 SkPaint paint;
258 paint.setAntiAlias(true);
259 paint.setColor(0xFF884422);
260 paint.setTextSize(SkIntToScalar(kBitmapSize/2));
261 const char* str = "g";
262 canvas.drawText(str, strlen(str), SkIntToScalar(kBitmapSize/8),
263 SkIntToScalar(kBitmapSize/4), paint);
264}
265
266static void make_checkerboard_bitmap(SkBitmap& bitmap) {
commit-bot@chromium.orga8c18312014-02-17 02:55:57 +0000267 rand_bitmap_for_canvas(&bitmap);
268
269 SkCanvas canvas(bitmap);
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +0000270 canvas.clear(0x00000000);
271 SkPaint darkPaint;
272 darkPaint.setColor(0xFF804020);
273 SkPaint lightPaint;
274 lightPaint.setColor(0xFF244484);
275 const int i = kBitmapSize / 8;
276 const SkScalar f = SkIntToScalar(i);
277 for (int y = 0; y < kBitmapSize; y += i) {
278 for (int x = 0; x < kBitmapSize; x += i) {
279 canvas.save();
280 canvas.translate(SkIntToScalar(x), SkIntToScalar(y));
281 canvas.drawRect(SkRect::MakeXYWH(0, 0, f, f), darkPaint);
282 canvas.drawRect(SkRect::MakeXYWH(f, 0, f, f), lightPaint);
283 canvas.drawRect(SkRect::MakeXYWH(0, f, f, f), lightPaint);
284 canvas.drawRect(SkRect::MakeXYWH(f, f, f, f), darkPaint);
285 canvas.restore();
286 }
287 }
288}
289
290static const SkBitmap& make_bitmap() {
291 static SkBitmap bitmap[2];
292 static bool initialized = false;
293 if (!initialized) {
294 make_g_bitmap(bitmap[0]);
295 make_checkerboard_bitmap(bitmap[1]);
296 initialized = true;
297 }
298 return bitmap[R(2)];
299}
300
reedd053ce92016-03-22 10:17:23 -0700301static sk_sp<SkData> make_3Dlut(int* cubeDimension, bool invR, bool invG, bool invB) {
sugoif11c5742014-10-27 08:03:56 -0700302 int size = 4 << R(5);
reedd053ce92016-03-22 10:17:23 -0700303 auto data = SkData::MakeUninitialized(sizeof(SkColor) * size * size * size);
sugoif11c5742014-10-27 08:03:56 -0700304 SkColor* pixels = (SkColor*)(data->writable_data());
scroggo565901d2015-12-10 10:44:13 -0800305 SkAutoTMalloc<uint8_t> lutMemory(size);
306 SkAutoTMalloc<uint8_t> invLutMemory(size);
307 uint8_t* lut = lutMemory.get();
308 uint8_t* invLut = invLutMemory.get();
sugoif11c5742014-10-27 08:03:56 -0700309 const int maxIndex = size - 1;
310 for (int i = 0; i < size; i++) {
311 lut[i] = (i * 255) / maxIndex;
312 invLut[i] = ((maxIndex - i) * 255) / maxIndex;
313 }
314 for (int r = 0; r < size; ++r) {
315 for (int g = 0; g < size; ++g) {
316 for (int b = 0; b < size; ++b) {
317 pixels[(size * ((size * b) + g)) + r] = SkColorSetARGB(0xFF,
318 invR ? invLut[r] : lut[r],
319 invG ? invLut[g] : lut[g],
320 invB ? invLut[b] : lut[b]);
321 }
322 }
323 }
324 if (cubeDimension) {
325 *cubeDimension = size;
326 }
327 return data;
328}
329
commit-bot@chromium.org5e0995e2014-02-07 12:20:04 +0000330static void drawSomething(SkCanvas* canvas) {
331 SkPaint paint;
332
333 canvas->save();
334 canvas->scale(0.5f, 0.5f);
halcanary96fcdcc2015-08-27 07:41:13 -0700335 canvas->drawBitmap(make_bitmap(), 0, 0, nullptr);
commit-bot@chromium.org5e0995e2014-02-07 12:20:04 +0000336 canvas->restore();
337
commit-bot@chromium.org5e0995e2014-02-07 12:20:04 +0000338 paint.setAntiAlias(true);
339
340 paint.setColor(SK_ColorRED);
commit-bot@chromium.org5e0995e2014-02-07 12:20:04 +0000341 canvas->drawCircle(SkIntToScalar(kBitmapSize/2), SkIntToScalar(kBitmapSize/2), SkIntToScalar(kBitmapSize/3), paint);
commit-bot@chromium.org5e0995e2014-02-07 12:20:04 +0000342 paint.setColor(SK_ColorBLACK);
343 paint.setTextSize(SkIntToScalar(kBitmapSize/3));
344 canvas->drawText("Picture", 7, SkIntToScalar(kBitmapSize/2), SkIntToScalar(kBitmapSize/4), paint);
345}
commit-bot@chromium.org5e0995e2014-02-07 12:20:04 +0000346
ajuma77b6ba32016-01-08 14:58:35 -0800347static void rand_color_table(uint8_t* table) {
348 for (int i = 0; i < 256; ++i) {
349 table[i] = R(256);
350 }
351}
352
reedd053ce92016-03-22 10:17:23 -0700353static sk_sp<SkColorFilter> make_color_filter() {
ajuma77b6ba32016-01-08 14:58:35 -0800354 switch (R(6)) {
355 case 0: {
356 SkScalar array[20];
357 for (int i = 0; i < 20; ++i) {
358 array[i] = make_scalar();
359 }
reedd053ce92016-03-22 10:17:23 -0700360 return SkColorFilter::MakeMatrixFilterRowMajor255(array);
ajuma77b6ba32016-01-08 14:58:35 -0800361 }
362 case 1:
reedd053ce92016-03-22 10:17:23 -0700363 return SkLumaColorFilter::Make();
ajuma77b6ba32016-01-08 14:58:35 -0800364 case 2: {
365 uint8_t tableA[256];
366 uint8_t tableR[256];
367 uint8_t tableG[256];
368 uint8_t tableB[256];
369 rand_color_table(tableA);
370 rand_color_table(tableR);
371 rand_color_table(tableG);
372 rand_color_table(tableB);
reedd053ce92016-03-22 10:17:23 -0700373 return SkTableColorFilter::MakeARGB(tableA, tableR, tableG, tableB);
ajuma77b6ba32016-01-08 14:58:35 -0800374 }
375 case 3:
reedd053ce92016-03-22 10:17:23 -0700376 return SkColorFilter::MakeModeFilter(make_color(), make_xfermode());
ajuma77b6ba32016-01-08 14:58:35 -0800377 case 4:
reedd053ce92016-03-22 10:17:23 -0700378 return SkColorMatrixFilter::MakeLightingFilter(make_color(), make_color());
ajuma77b6ba32016-01-08 14:58:35 -0800379 case 5:
380 default:
ajuma77b6ba32016-01-08 14:58:35 -0800381 break;
382 }
reedd053ce92016-03-22 10:17:23 -0700383 return nullptr;
ajuma77b6ba32016-01-08 14:58:35 -0800384}
385
386static SkPath make_path() {
387 SkPath path;
388 int numOps = R(30);
389 for (int i = 0; i < numOps; ++i) {
390 switch (R(6)) {
391 case 0:
392 path.moveTo(make_scalar(), make_scalar());
393 break;
394 case 1:
395 path.lineTo(make_scalar(), make_scalar());
396 break;
397 case 2:
398 path.quadTo(make_scalar(), make_scalar(), make_scalar(), make_scalar());
399 break;
400 case 3:
401 path.conicTo(make_scalar(), make_scalar(), make_scalar(), make_scalar(), make_scalar());
402 break;
403 case 4:
404 path.cubicTo(make_scalar(), make_scalar(), make_scalar(),
405 make_scalar(), make_scalar(), make_scalar());
406 break;
407 case 5:
408 default:
409 path.arcTo(make_scalar(), make_scalar(), make_scalar(), make_scalar(), make_scalar());
410 break;
411
412 }
413 }
414 path.close();
415 return path;
416}
417
reeda4393342016-03-18 11:22:57 -0700418static sk_sp<SkPathEffect> make_path_effect(bool canBeNull = true) {
419 sk_sp<SkPathEffect> pathEffect;
ajuma77b6ba32016-01-08 14:58:35 -0800420 if (canBeNull && (R(3) == 1)) { return pathEffect; }
421
422 switch (R(9)) {
423 case 0:
reeda4393342016-03-18 11:22:57 -0700424 pathEffect = SkArcToPathEffect::Make(make_scalar(true));
ajuma77b6ba32016-01-08 14:58:35 -0800425 break;
reeda4393342016-03-18 11:22:57 -0700426 case 1:
427 pathEffect = SkComposePathEffect::Make(make_path_effect(false),
428 make_path_effect(false));
ajuma77b6ba32016-01-08 14:58:35 -0800429 break;
ajuma77b6ba32016-01-08 14:58:35 -0800430 case 2:
reeda4393342016-03-18 11:22:57 -0700431 pathEffect = SkCornerPathEffect::Make(make_scalar());
ajuma77b6ba32016-01-08 14:58:35 -0800432 break;
433 case 3: {
434 int count = R(10);
435 SkScalar intervals[10];
436 for (int i = 0; i < count; ++i) {
437 intervals[i] = make_scalar();
438 }
reeda4393342016-03-18 11:22:57 -0700439 pathEffect = SkDashPathEffect::Make(intervals, count, make_scalar());
ajuma77b6ba32016-01-08 14:58:35 -0800440 break;
441 }
442 case 4:
reeda4393342016-03-18 11:22:57 -0700443 pathEffect = SkDiscretePathEffect::Make(make_scalar(), make_scalar());
ajuma77b6ba32016-01-08 14:58:35 -0800444 break;
445 case 5:
reeda4393342016-03-18 11:22:57 -0700446 pathEffect = SkPath1DPathEffect::Make(make_path(), make_scalar(), make_scalar(),
447 make_path_1d_path_effect_style());
ajuma77b6ba32016-01-08 14:58:35 -0800448 break;
449 case 6:
reeda4393342016-03-18 11:22:57 -0700450 pathEffect = SkLine2DPathEffect::Make(make_scalar(), make_matrix());
ajuma77b6ba32016-01-08 14:58:35 -0800451 break;
452 case 7:
reeda4393342016-03-18 11:22:57 -0700453 pathEffect = SkPath2DPathEffect::Make(make_matrix(), make_path());
ajuma77b6ba32016-01-08 14:58:35 -0800454 break;
455 case 8:
456 default:
reeda4393342016-03-18 11:22:57 -0700457 pathEffect = SkSumPathEffect::Make(make_path_effect(false),
458 make_path_effect(false));
ajuma77b6ba32016-01-08 14:58:35 -0800459 break;
460 }
461 return pathEffect;
462}
463
464static SkMaskFilter* make_mask_filter() {
465 SkMaskFilter* maskFilter;
466 switch (R(3)) {
467 case 0:
468 maskFilter = SkBlurMaskFilter::Create(make_blur_style(),
469 make_scalar(),
470 make_blur_mask_filter_flag());
471 case 1: {
472 SkEmbossMaskFilter::Light light;
473 for (int i = 0; i < 3; ++i) {
474 light.fDirection[i] = make_scalar();
475 }
476 light.fPad = R(65536);
477 light.fAmbient = R(256);
478 light.fSpecular = R(256);
479 maskFilter = SkEmbossMaskFilter::Create(make_scalar(),
480 light);
481 }
482 case 2:
483 default:
484 maskFilter = nullptr;
485 break;
486 }
487 return maskFilter;
488}
489
robertphillips372177e2016-03-30 07:32:28 -0700490static sk_sp<SkImageFilter> make_image_filter(bool canBeNull = true);
ajuma77b6ba32016-01-08 14:58:35 -0800491
492static SkPaint make_paint() {
493 SkPaint paint;
494 paint.setHinting(make_paint_hinting());
495 paint.setAntiAlias(make_bool());
496 paint.setDither(make_bool());
497 paint.setLinearText(make_bool());
498 paint.setSubpixelText(make_bool());
499 paint.setLCDRenderText(make_bool());
500 paint.setEmbeddedBitmapText(make_bool());
501 paint.setAutohinted(make_bool());
502 paint.setVerticalText(make_bool());
503 paint.setUnderlineText(make_bool());
504 paint.setStrikeThruText(make_bool());
505 paint.setFakeBoldText(make_bool());
506 paint.setDevKernText(make_bool());
507 paint.setFilterQuality(make_filter_quality());
508 paint.setStyle(make_paint_style());
509 paint.setColor(make_color());
510 paint.setStrokeWidth(make_scalar());
511 paint.setStrokeMiter(make_scalar());
512 paint.setStrokeCap(make_paint_cap());
513 paint.setStrokeJoin(make_paint_join());
514 paint.setColorFilter(make_color_filter());
515 paint.setXfermodeMode(make_xfermode());
516 paint.setPathEffect(make_path_effect());
517 paint.setMaskFilter(make_mask_filter());
reedca726ab2016-02-22 12:50:25 -0800518
519 if (false) {
520 // our validating buffer does not support typefaces yet, so skip this for now
521 SkAutoTUnref<SkTypeface> typeface(
522 SkTypeface::CreateFromName(make_font_name().c_str(), make_typeface_style()));
523 paint.setTypeface(typeface);
524 }
525
ajuma77b6ba32016-01-08 14:58:35 -0800526 SkLayerRasterizer::Builder rasterizerBuilder;
527 SkPaint paintForRasterizer;
528 if (R(2) == 1) {
529 paintForRasterizer = make_paint();
530 }
531 rasterizerBuilder.addLayer(paintForRasterizer);
reed7b380d02016-03-21 13:25:16 -0700532 paint.setRasterizer(rasterizerBuilder.detach());
ajuma77b6ba32016-01-08 14:58:35 -0800533 paint.setImageFilter(make_image_filter());
reedd053ce92016-03-22 10:17:23 -0700534 sk_sp<SkData> data(make_3Dlut(nullptr, make_bool(), make_bool(), make_bool()));
ajuma77b6ba32016-01-08 14:58:35 -0800535 paint.setTextAlign(make_paint_align());
536 paint.setTextSize(make_scalar());
537 paint.setTextScaleX(make_scalar());
538 paint.setTextSkewX(make_scalar());
539 paint.setTextEncoding(make_paint_text_encoding());
540 return paint;
541}
542
robertphillips372177e2016-03-30 07:32:28 -0700543static sk_sp<SkImageFilter> make_image_filter(bool canBeNull) {
544 sk_sp<SkImageFilter> filter;
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +0000545
halcanary96fcdcc2015-08-27 07:41:13 -0700546 // Add a 1 in 3 chance to get a nullptr input
robertphillips372177e2016-03-30 07:32:28 -0700547 if (canBeNull && (R(3) == 1)) {
548 return filter;
549 }
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +0000550
sugoif11c5742014-10-27 08:03:56 -0700551 enum { ALPHA_THRESHOLD, MERGE, COLOR, LUT3D, BLUR, MAGNIFIER,
commit-bot@chromium.org067fe482014-05-27 13:52:51 +0000552 DOWN_SAMPLE, XFERMODE, OFFSET, MATRIX, MATRIX_CONVOLUTION, COMPOSE,
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +0000553 DISTANT_LIGHT, POINT_LIGHT, SPOT_LIGHT, NOISE, DROP_SHADOW,
ajuma77b6ba32016-01-08 14:58:35 -0800554 MORPHOLOGY, BITMAP, DISPLACE, TILE, PICTURE, PAINT, NUM_FILTERS };
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +0000555
556 switch (R(NUM_FILTERS)) {
commit-bot@chromium.org067fe482014-05-27 13:52:51 +0000557 case ALPHA_THRESHOLD:
robertphillips372177e2016-03-30 07:32:28 -0700558 filter = sk_sp<SkImageFilter>(SkAlphaThresholdFilter::Create(make_region(),
559 make_scalar(),
560 make_scalar()));
commit-bot@chromium.org067fe482014-05-27 13:52:51 +0000561 break;
robertphillips372177e2016-03-30 07:32:28 -0700562 case MERGE: {
563 sk_sp<SkImageFilter> subFilter1(make_image_filter());
564 sk_sp<SkImageFilter> subFilter2(make_image_filter());
565 filter = sk_sp<SkImageFilter>(SkMergeImageFilter::Create(subFilter1.get(),
566 subFilter2.get(),
567 make_xfermode()));
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +0000568 break;
robertphillipsa33cf072016-03-29 13:54:26 -0700569 }
robertphillips372177e2016-03-30 07:32:28 -0700570 case COLOR: {
571 sk_sp<SkColorFilter> cf(make_color_filter());
572 sk_sp<SkImageFilter> subFilter(make_image_filter());
573 filter = cf ? sk_sp<SkImageFilter>(SkColorFilterImageFilter::Create(cf.get(),
574 subFilter.get()))
575 : nullptr;
djsollen89057902016-03-29 19:07:07 -0700576 break;
robertphillips372177e2016-03-30 07:32:28 -0700577 }
578 case LUT3D: {
sugoif11c5742014-10-27 08:03:56 -0700579 int cubeDimension;
reedd053ce92016-03-22 10:17:23 -0700580 sk_sp<SkData> lut3D(make_3Dlut(&cubeDimension, (R(2) == 1), (R(2) == 1), (R(2) == 1)));
581 sk_sp<SkColorFilter> cf(SkColorCubeFilter::Make(lut3D, cubeDimension));
robertphillips372177e2016-03-30 07:32:28 -0700582 sk_sp<SkImageFilter> subFilter(make_image_filter());
583 filter = cf ? sk_sp<SkImageFilter>(SkColorFilterImageFilter::Create(cf.get(),
584 subFilter.get()))
585 : nullptr;
586 break;
sugoif11c5742014-10-27 08:03:56 -0700587 }
robertphillips372177e2016-03-30 07:32:28 -0700588 case BLUR: {
589 sk_sp<SkImageFilter> subFilter(make_image_filter());
590 filter = sk_sp<SkImageFilter>(SkBlurImageFilter::Create(make_scalar(true),
591 make_scalar(true),
592 subFilter.get()));
sugoif11c5742014-10-27 08:03:56 -0700593 break;
robertphillips372177e2016-03-30 07:32:28 -0700594 }
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +0000595 case MAGNIFIER:
robertphillips372177e2016-03-30 07:32:28 -0700596 filter = sk_sp<SkImageFilter>(SkMagnifierImageFilter::Create(make_rect(),
597 make_scalar(true)));
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +0000598 break;
commit-bot@chromium.org067fe482014-05-27 13:52:51 +0000599 case DOWN_SAMPLE:
robertphillips372177e2016-03-30 07:32:28 -0700600 filter = sk_sp<SkImageFilter>(SkDownSampleImageFilter::Create(make_scalar()));
commit-bot@chromium.org067fe482014-05-27 13:52:51 +0000601 break;
robertphillips372177e2016-03-30 07:32:28 -0700602 case XFERMODE: {
603 sk_sp<SkImageFilter> subFilter1(make_image_filter());
604 sk_sp<SkImageFilter> subFilter2(make_image_filter());
reedcfb6bdf2016-03-29 11:32:50 -0700605 filter = SkXfermodeImageFilter::Make(SkXfermode::Make(make_xfermode()),
robertphillips372177e2016-03-30 07:32:28 -0700606 subFilter1.get(),
607 subFilter2.get(),
608 nullptr);
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +0000609 break;
robertphillips372177e2016-03-30 07:32:28 -0700610 }
611 case OFFSET: {
612 sk_sp<SkImageFilter> subFilter(make_image_filter());
613 filter = sk_sp<SkImageFilter>(SkOffsetImageFilter::Create(make_scalar(), make_scalar(),
614 subFilter.get()));
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +0000615 break;
robertphillips372177e2016-03-30 07:32:28 -0700616 }
617 case MATRIX: {
618 sk_sp<SkImageFilter> subFilter(make_image_filter());
619 filter = sk_sp<SkImageFilter>(SkImageFilter::CreateMatrixFilter(make_matrix(),
620 (SkFilterQuality)R(4),
621 subFilter.get()));
commit-bot@chromium.org067fe482014-05-27 13:52:51 +0000622 break;
robertphillips372177e2016-03-30 07:32:28 -0700623 }
624 case MATRIX_CONVOLUTION: {
commit-bot@chromium.org067fe482014-05-27 13:52:51 +0000625 SkImageFilter::CropRect cropR(SkRect::MakeWH(SkIntToScalar(kBitmapSize),
626 SkIntToScalar(kBitmapSize)));
627 SkISize size = SkISize::Make(R(10)+1, R(10)+1);
628 int arraySize = size.width() * size.height();
629 SkTArray<SkScalar> kernel(arraySize);
630 for (int i = 0; i < arraySize; ++i) {
631 kernel.push_back() = make_scalar();
632 }
commit-bot@chromium.orgb859fe62014-05-27 17:03:25 +0000633 SkIPoint kernelOffset = SkIPoint::Make(R(SkIntToScalar(size.width())),
634 R(SkIntToScalar(size.height())));
robertphillips372177e2016-03-30 07:32:28 -0700635 sk_sp<SkImageFilter> subFilter(make_image_filter());
636
637 filter = sk_sp<SkImageFilter>(SkMatrixConvolutionImageFilter::Create(
638 size,
commit-bot@chromium.org067fe482014-05-27 13:52:51 +0000639 kernel.begin(),
640 make_scalar(),
641 make_scalar(),
642 kernelOffset,
643 (SkMatrixConvolutionImageFilter::TileMode)R(3),
644 R(2) == 1,
robertphillips372177e2016-03-30 07:32:28 -0700645 subFilter.get(),
646 &cropR));
647 break;
commit-bot@chromium.org067fe482014-05-27 13:52:51 +0000648 }
robertphillips491fb172016-03-30 12:32:58 -0700649 case COMPOSE:
650 filter = SkComposeImageFilter::Make(make_image_filter(), make_image_filter());
commit-bot@chromium.org067fe482014-05-27 13:52:51 +0000651 break;
robertphillips372177e2016-03-30 07:32:28 -0700652 case DISTANT_LIGHT: {
653 sk_sp<SkImageFilter> subFilter(make_image_filter());
654
655 filter = (R(2) == 1)
656 ? sk_sp<SkImageFilter>(SkLightingImageFilter::CreateDistantLitDiffuse(make_point(),
657 make_color(), make_scalar(), make_scalar(),
658 subFilter.get()))
659 : sk_sp<SkImageFilter>(SkLightingImageFilter::CreateDistantLitSpecular(make_point(),
660 make_color(), make_scalar(),
661 make_scalar(), SkIntToScalar(R(10)),
662 subFilter.get()));
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +0000663 break;
robertphillips372177e2016-03-30 07:32:28 -0700664 }
665 case POINT_LIGHT: {
666 sk_sp<SkImageFilter> subFilter(make_image_filter());
667
668 filter = (R(2) == 1)
669 ? sk_sp<SkImageFilter>(SkLightingImageFilter::CreatePointLitDiffuse(make_point(),
670 make_color(), make_scalar(), make_scalar(),
671 subFilter.get()))
672 : sk_sp<SkImageFilter>(SkLightingImageFilter::CreatePointLitSpecular(make_point(),
673 make_color(), make_scalar(), make_scalar(),
674 SkIntToScalar(R(10)),
675 subFilter.get()));
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +0000676 break;
robertphillips372177e2016-03-30 07:32:28 -0700677 }
678 case SPOT_LIGHT: {
679 sk_sp<SkImageFilter> subFilter(make_image_filter());
680
681 filter = (R(2) == 1)
682 ? sk_sp<SkImageFilter>(SkLightingImageFilter::CreateSpotLitDiffuse(SkPoint3::Make(0, 0, 0),
683 make_point(), make_scalar(), make_scalar(),
684 make_color(), make_scalar(), make_scalar(),
685 subFilter.get()))
686 : sk_sp<SkImageFilter>(SkLightingImageFilter::CreateSpotLitSpecular(SkPoint3::Make(0, 0, 0),
687 make_point(), make_scalar(), make_scalar(),
688 make_color(), make_scalar(), make_scalar(),
689 SkIntToScalar(R(10)), subFilter.get()));
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +0000690 break;
robertphillips372177e2016-03-30 07:32:28 -0700691 }
692 case NOISE: {
reedfe630452016-03-25 09:08:00 -0700693 sk_sp<SkShader> shader((R(2) == 1) ?
694 SkPerlinNoiseShader::MakeFractalNoise(
sugoi@google.combb8148b2013-09-19 19:51:27 +0000695 make_scalar(true), make_scalar(true), R(10.0f), make_scalar()) :
reedfe630452016-03-25 09:08:00 -0700696 SkPerlinNoiseShader::MakeTurbulence(
sugoi@google.combb8148b2013-09-19 19:51:27 +0000697 make_scalar(true), make_scalar(true), R(10.0f), make_scalar()));
ajuma77b6ba32016-01-08 14:58:35 -0800698 SkPaint paint;
699 paint.setShader(shader);
reed@google.com44699382013-10-31 17:28:30 +0000700 SkImageFilter::CropRect cropR(SkRect::MakeWH(SkIntToScalar(kBitmapSize),
701 SkIntToScalar(kBitmapSize)));
robertphillips372177e2016-03-30 07:32:28 -0700702 filter = SkPaintImageFilter::Make(paint, &cropR);
703 break;
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +0000704 }
robertphillips372177e2016-03-30 07:32:28 -0700705 case DROP_SHADOW: {
706 sk_sp<SkImageFilter> subFilter(make_image_filter());
707
708 filter = sk_sp<SkImageFilter>(SkDropShadowImageFilter::Create(make_scalar(),
709 make_scalar(),
710 make_scalar(true),
711 make_scalar(true),
712 make_color(),
713 make_shadow_mode(),
714 subFilter.get(),
715 nullptr));
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +0000716 break;
robertphillips372177e2016-03-30 07:32:28 -0700717 }
718 case MORPHOLOGY: {
719 sk_sp<SkImageFilter> subFilter(make_image_filter());
720
commit-bot@chromium.org43f4a552014-01-15 20:20:24 +0000721 if (R(2) == 1) {
robertphillips372177e2016-03-30 07:32:28 -0700722 filter = sk_sp<SkImageFilter>(SkDilateImageFilter::Create(R(static_cast<float>(kBitmapSize)),
723 R(static_cast<float>(kBitmapSize)),
724 subFilter.get()));
commit-bot@chromium.org43f4a552014-01-15 20:20:24 +0000725 } else {
robertphillips372177e2016-03-30 07:32:28 -0700726 filter = sk_sp<SkImageFilter>(SkErodeImageFilter::Create(R(static_cast<float>(kBitmapSize)),
727 R(static_cast<float>(kBitmapSize)),
728 subFilter.get()));
commit-bot@chromium.org43f4a552014-01-15 20:20:24 +0000729 }
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +0000730 break;
robertphillips372177e2016-03-30 07:32:28 -0700731 }
732 case BITMAP: {
reed9ce9d672016-03-17 10:51:11 -0700733 sk_sp<SkImage> image(SkImage::MakeFromBitmap(make_bitmap()));
commit-bot@chromium.org43f4a552014-01-15 20:20:24 +0000734 if (R(2) == 1) {
robertphillips372177e2016-03-30 07:32:28 -0700735 filter = sk_sp<SkImageFilter>(SkImageSource::Create(image.get(),
736 make_rect(),
737 make_rect(),
738 kHigh_SkFilterQuality));
commit-bot@chromium.org43f4a552014-01-15 20:20:24 +0000739 } else {
robertphillips372177e2016-03-30 07:32:28 -0700740 filter = sk_sp<SkImageFilter>(SkImageSource::Create(image.get()));
commit-bot@chromium.org43f4a552014-01-15 20:20:24 +0000741 }
robertphillips372177e2016-03-30 07:32:28 -0700742 break;
fmalita5598b632015-09-15 11:26:13 -0700743 }
robertphillips372177e2016-03-30 07:32:28 -0700744 case DISPLACE: {
745 sk_sp<SkImageFilter> subFilter1(make_image_filter(false));
746 sk_sp<SkImageFilter> subFilter2(make_image_filter());
747
748 filter = sk_sp<SkImageFilter>(SkDisplacementMapEffect::Create(make_channel_selector_type(),
749 make_channel_selector_type(),
750 make_scalar(),
751 subFilter1.get(),
752 subFilter2.get()));
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +0000753 break;
robertphillips372177e2016-03-30 07:32:28 -0700754 }
755 case TILE: {
756 sk_sp<SkImageFilter> subFilter(make_image_filter(false));
757
758 filter = sk_sp<SkImageFilter>(SkTileImageFilter::Create(make_rect(),
759 make_rect(),
760 subFilter.get()));
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +0000761 break;
robertphillips372177e2016-03-30 07:32:28 -0700762 }
763 case PICTURE: {
senorblanco@chromium.org97f5fc62014-05-30 20:50:56 +0000764 SkRTreeFactory factory;
765 SkPictureRecorder recorder;
halcanary9d524f22016-03-29 09:03:52 -0700766 SkCanvas* recordingCanvas = recorder.beginRecording(SkIntToScalar(kBitmapSize),
767 SkIntToScalar(kBitmapSize),
robertphillipsa8d7f0b2014-08-29 08:03:56 -0700768 &factory, 0);
senorblanco@chromium.org97f5fc62014-05-30 20:50:56 +0000769 drawSomething(recordingCanvas);
reedca2622b2016-03-18 07:25:55 -0700770 sk_sp<SkPicture> pict(recorder.finishRecordingAsPicture());
robertphillips372177e2016-03-30 07:32:28 -0700771 filter = SkPictureImageFilter::Make(pict, make_rect());
robertphillipsa33cf072016-03-29 13:54:26 -0700772 break;
robertphillips372177e2016-03-30 07:32:28 -0700773 }
774 case PAINT: {
djsollen89057902016-03-29 19:07:07 -0700775 SkImageFilter::CropRect cropR(make_rect());
robertphillips372177e2016-03-30 07:32:28 -0700776 filter = SkPaintImageFilter::Make(make_paint(), &cropR);
777 break;
ajuma77b6ba32016-01-08 14:58:35 -0800778 }
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +0000779 default:
780 break;
781 }
782 return (filter || canBeNull) ? filter : make_image_filter(canBeNull);
783}
784
commit-bot@chromium.org77e079a2013-10-28 15:52:02 +0000785static SkImageFilter* make_serialized_image_filter() {
robertphillips372177e2016-03-30 07:32:28 -0700786 sk_sp<SkImageFilter> filter(make_image_filter(false));
787 SkAutoTUnref<SkData> data(SkValidatingSerializeFlattenable(filter.get()));
commit-bot@chromium.org77e079a2013-10-28 15:52:02 +0000788 const unsigned char* ptr = static_cast<const unsigned char*>(data->data());
789 size_t len = data->size();
790#ifdef SK_ADD_RANDOM_BIT_FLIPS
791 unsigned char* p = const_cast<unsigned char*>(ptr);
792 for (size_t i = 0; i < len; ++i, ++p) {
commit-bot@chromium.orgcd3b15c2013-12-04 17:06:49 +0000793 if (R(250) == 1) { // 0.4% of the time, flip a bit or byte
794 if (R(10) == 1) { // Then 10% of the time, change a whole byte
795 switch(R(3)) {
796 case 0:
797 *p ^= 0xFF; // Flip entire byte
798 break;
799 case 1:
800 *p = 0xFF; // Set all bits to 1
801 break;
802 case 2:
803 *p = 0x00; // Set all bits to 0
804 break;
805 }
806 } else {
807 *p ^= (1 << R(8));
808 }
commit-bot@chromium.org77e079a2013-10-28 15:52:02 +0000809 }
810 }
811#endif // SK_ADD_RANDOM_BIT_FLIPS
812 SkFlattenable* flattenable = SkValidatingDeserializeFlattenable(ptr, len,
813 SkImageFilter::GetFlattenableType());
commit-bot@chromium.org77e079a2013-10-28 15:52:02 +0000814 return static_cast<SkImageFilter*>(flattenable);
815}
816
sugoi@google.combb8148b2013-09-19 19:51:27 +0000817static void drawClippedBitmap(SkCanvas* canvas, int x, int y, const SkPaint& paint) {
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +0000818 canvas->save();
819 canvas->clipRect(SkRect::MakeXYWH(SkIntToScalar(x), SkIntToScalar(y),
820 SkIntToScalar(kBitmapSize), SkIntToScalar(kBitmapSize)));
821 canvas->drawBitmap(make_bitmap(), SkIntToScalar(x), SkIntToScalar(y), &paint);
822 canvas->restore();
823}
824
825static void do_fuzz(SkCanvas* canvas) {
commit-bot@chromium.orgef74fa12013-12-17 20:49:46 +0000826 SkImageFilter* filter = make_serialized_image_filter();
827
commit-bot@chromium.orgcd3b15c2013-12-04 17:06:49 +0000828#ifdef SK_FUZZER_IS_VERBOSE
commit-bot@chromium.orgef74fa12013-12-17 20:49:46 +0000829 static uint32_t numFilters = 0;
830 static uint32_t numValidFilters = 0;
831 if (0 == numFilters) {
commit-bot@chromium.orgcd3b15c2013-12-04 17:06:49 +0000832 printf("Fuzzing with %u\n", kSeed);
833 }
commit-bot@chromium.orgef74fa12013-12-17 20:49:46 +0000834 numFilters++;
bsalomon49f085d2014-09-05 13:34:00 -0700835 if (filter) {
commit-bot@chromium.orgef74fa12013-12-17 20:49:46 +0000836 numValidFilters++;
837 }
838 printf("Filter no : %u. Valid filters so far : %u\r", numFilters, numValidFilters);
commit-bot@chromium.orgcd3b15c2013-12-04 17:06:49 +0000839 fflush(stdout);
commit-bot@chromium.orgcd3b15c2013-12-04 17:06:49 +0000840#endif
841
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +0000842 SkPaint paint;
commit-bot@chromium.orgef74fa12013-12-17 20:49:46 +0000843 SkSafeUnref(paint.setImageFilter(filter));
commit-bot@chromium.org22d69f92013-09-19 18:40:49 +0000844 drawClippedBitmap(canvas, 0, 0, paint);
845}
846
847//////////////////////////////////////////////////////////////////////////////
848
849class ImageFilterFuzzView : public SampleView {
850public:
851 ImageFilterFuzzView() {
852 this->setBGColor(0xFFDDDDDD);
853 }
854
855protected:
856 // overrides from SkEventSink
857 virtual bool onQuery(SkEvent* evt) {
858 if (SampleCode::TitleQ(*evt)) {
859 SampleCode::TitleR(evt, "ImageFilterFuzzer");
860 return true;
861 }
862 return this->INHERITED::onQuery(evt);
863 }
864
865 void drawBG(SkCanvas* canvas) {
866 canvas->drawColor(0xFFDDDDDD);
867 }
868
869 virtual void onDrawContent(SkCanvas* canvas) {
870 do_fuzz(canvas);
871 this->inval(0);
872 }
873
874private:
875 typedef SkView INHERITED;
876};
877
878//////////////////////////////////////////////////////////////////////////////
879
880static SkView* MyFactory() { return new ImageFilterFuzzView; }
881static SkViewRegister reg(MyFactory);