Lines Matching full:fuzz
8 #include "fuzz/Fuzz.h"
9 #include "fuzz/FuzzCommon.h"
80 inline T make_fuzz_t(Fuzz* fuzz) { in make_fuzz_t() argument
82 fuzz->next(&t); in make_fuzz_t()
86 static sk_sp<SkImage> make_fuzz_image(Fuzz*);
88 static sk_sp<SkPicture> make_fuzz_picture(Fuzz*, int depth);
90 static sk_sp<SkColorFilter> make_fuzz_colorfilter(Fuzz* fuzz, int depth) { in make_fuzz_colorfilter() argument
95 fuzz->nextRange(&colorFilterType, 0, 8); in make_fuzz_colorfilter()
102 fuzz->next(&color); in make_fuzz_colorfilter()
103 fuzz->nextEnum(&mode, SkBlendMode::kLastMode); in make_fuzz_colorfilter()
107 sk_sp<SkColorFilter> outer = make_fuzz_colorfilter(fuzz, depth - 1); in make_fuzz_colorfilter()
111 sk_sp<SkColorFilter> inner = make_fuzz_colorfilter(fuzz, depth - 1); in make_fuzz_colorfilter()
117 fuzz->nextN(array, std::size(array)); in make_fuzz_colorfilter()
122 fuzz->next(&mul, &add); in make_fuzz_colorfilter()
129 fuzz->next(&grayscale); in make_fuzz_colorfilter()
130 fuzz->nextRange(&invertStyle, 0, 2); in make_fuzz_colorfilter()
131 fuzz->nextRange(&contrast, -1.0f, 1.0f); in make_fuzz_colorfilter()
139 fuzz->nextN(table, std::size(table)); in make_fuzz_colorfilter()
147 fuzz->nextN(tableA, std::size(tableA)); in make_fuzz_colorfilter()
148 fuzz->nextN(tableR, std::size(tableR)); in make_fuzz_colorfilter()
149 fuzz->nextN(tableG, std::size(tableG)); in make_fuzz_colorfilter()
150 fuzz->nextN(tableB, std::size(tableB)); in make_fuzz_colorfilter()
160 static void fuzz_gradient_stops(Fuzz* fuzz, SkScalar* pos, int colorCount) { in fuzz_gradient_stops() argument
163 fuzz->nextRange(&pos[i], 1.0f, 1024.0f); in fuzz_gradient_stops()
174 static sk_sp<SkShader> make_fuzz_shader(Fuzz* fuzz, int depth) { in make_fuzz_shader() argument
188 fuzz->nextRange(&shaderType, 0, 14); in make_fuzz_shader()
195 fuzz->next(&color); in make_fuzz_shader()
198 img = make_fuzz_image(fuzz); in make_fuzz_shader()
199 fuzz->nextEnum(&tmX, SkTileMode::kLastTileMode); in make_fuzz_shader()
200 fuzz->nextEnum(&tmY, SkTileMode::kLastTileMode); in make_fuzz_shader()
201 fuzz->next(&useMatrix); in make_fuzz_shader()
203 FuzzNiceMatrix(fuzz, &matrix); in make_fuzz_shader()
207 shader1 = make_fuzz_shader(fuzz, depth - 1); // limit recursion. in make_fuzz_shader()
208 FuzzNiceMatrix(fuzz, &matrix); in make_fuzz_shader()
211 shader1 = make_fuzz_shader(fuzz, depth - 1); // limit recursion. in make_fuzz_shader()
212 colorFilter = make_fuzz_colorfilter(fuzz, depth - 1); in make_fuzz_shader()
215 shader1 = make_fuzz_shader(fuzz, depth - 1); // limit recursion. in make_fuzz_shader()
216 shader2 = make_fuzz_shader(fuzz, depth - 1); in make_fuzz_shader()
217 fuzz->nextEnum(&blendMode, SkBlendMode::kLastMode); in make_fuzz_shader()
220 auto pic = make_fuzz_picture(fuzz, depth - 1); in make_fuzz_shader()
223 fuzz->nextEnum(&tmX, SkTileMode::kLastTileMode); in make_fuzz_shader()
224 fuzz->nextEnum(&tmY, SkTileMode::kLastTileMode); in make_fuzz_shader()
225 fuzz->next(&useMatrix, &useTile); in make_fuzz_shader()
227 FuzzNiceMatrix(fuzz, &matrix); in make_fuzz_shader()
230 fuzz->next(&tile); in make_fuzz_shader()
246 fuzz->nextN(pts, 2); in make_fuzz_shader()
247 fuzz->nextRange(&colorCount, 2, kMaxColors); in make_fuzz_shader()
248 fuzz->nextN(colors, colorCount); in make_fuzz_shader()
249 fuzz->nextEnum(&tmX, SkTileMode::kLastTileMode); in make_fuzz_shader()
250 fuzz->next(&useMatrix, &usePos); in make_fuzz_shader()
252 FuzzNiceMatrix(fuzz, &matrix); in make_fuzz_shader()
255 fuzz_gradient_stops(fuzz, pos, colorCount); in make_fuzz_shader()
268 fuzz->nextEnum(&tmX, SkTileMode::kLastTileMode); in make_fuzz_shader()
269 fuzz->next(&useMatrix, &usePos, ¢er, &radius); in make_fuzz_shader()
270 fuzz->nextRange(&colorCount, 2, kMaxColors); in make_fuzz_shader()
271 fuzz->nextN(colors, colorCount); in make_fuzz_shader()
273 FuzzNiceMatrix(fuzz, &matrix); in make_fuzz_shader()
276 fuzz_gradient_stops(fuzz, pos, colorCount); in make_fuzz_shader()
289 fuzz->nextEnum(&tmX, SkTileMode::kLastTileMode); in make_fuzz_shader()
290 fuzz->next(&useMatrix, &usePos, &startRadius, &endRadius, &start, &end); in make_fuzz_shader()
291 fuzz->nextRange(&colorCount, 2, kMaxColors); in make_fuzz_shader()
292 fuzz->nextN(colors, colorCount); in make_fuzz_shader()
294 FuzzNiceMatrix(fuzz, &matrix); in make_fuzz_shader()
297 fuzz_gradient_stops(fuzz, pos, colorCount); in make_fuzz_shader()
310 fuzz->next(&cx, &cy, &useMatrix, &usePos); in make_fuzz_shader()
311 fuzz->nextRange(&colorCount, 2, kMaxColors); in make_fuzz_shader()
312 fuzz->nextN(colors, colorCount); in make_fuzz_shader()
314 FuzzNiceMatrix(fuzz, &matrix); in make_fuzz_shader()
317 fuzz_gradient_stops(fuzz, pos, colorCount); in make_fuzz_shader()
327 fuzz->next(&baseFrequencyX, &baseFrequencyY, &seed, &useTileSize, &turbulence); in make_fuzz_shader()
329 fuzz->next(&tileSize); in make_fuzz_shader()
331 fuzz->nextRange(&numOctaves, 2, 7); in make_fuzz_shader()
353 static sk_sp<SkPathEffect> make_fuzz_patheffect(Fuzz* fuzz, int depth) { in make_fuzz_patheffect() argument
358 fuzz->nextRange(&pathEffectType, 0, 8); in make_fuzz_patheffect()
364 sk_sp<SkPathEffect> first = make_fuzz_patheffect(fuzz, depth - 1); in make_fuzz_patheffect()
365 sk_sp<SkPathEffect> second = make_fuzz_patheffect(fuzz, depth - 1); in make_fuzz_patheffect()
369 sk_sp<SkPathEffect> first = make_fuzz_patheffect(fuzz, depth - 1); in make_fuzz_patheffect()
370 sk_sp<SkPathEffect> second = make_fuzz_patheffect(fuzz, depth - 1); in make_fuzz_patheffect()
375 FuzzNicePath(fuzz, &path, 20); in make_fuzz_patheffect()
377 fuzz->next(&advance, &phase); in make_fuzz_patheffect()
379 fuzz->nextEnum(&style, SkPath1DPathEffect::kLastEnum_Style); in make_fuzz_patheffect()
385 fuzz->next(&width); in make_fuzz_patheffect()
386 FuzzNiceMatrix(fuzz, &matrix); in make_fuzz_patheffect()
391 FuzzNicePath(fuzz, &path, 20); in make_fuzz_patheffect()
393 FuzzNiceMatrix(fuzz, &matrix); in make_fuzz_patheffect()
398 fuzz->next(&radius); in make_fuzz_patheffect()
403 fuzz->next(&phase); in make_fuzz_patheffect()
406 fuzz->nextRange(&count, 0, (int)std::size(intervals)); in make_fuzz_patheffect()
407 fuzz->nextN(intervals, count); in make_fuzz_patheffect()
413 fuzz->next(&segLength, &dev, &seed); in make_fuzz_patheffect()
422 static sk_sp<SkMaskFilter> make_fuzz_maskfilter(Fuzz* fuzz) { in make_fuzz_maskfilter() argument
424 fuzz->nextRange(&maskfilterType, 0, 1); in make_fuzz_maskfilter()
430 fuzz->nextEnum(&blurStyle, kLastEnum_SkBlurStyle); in make_fuzz_maskfilter()
432 fuzz->next(&sigma); in make_fuzz_maskfilter()
434 fuzz->next(&respectCTM); in make_fuzz_maskfilter()
443 static sk_sp<SkTypeface> make_fuzz_typeface(Fuzz* fuzz) { in make_fuzz_typeface() argument
444 if (make_fuzz_t<bool>(fuzz)) { in make_fuzz_typeface()
450 fuzz->nextRange(&i, 0, familyCount - 1); in make_fuzz_typeface()
453 fuzz->nextRange(&j, 0, styleCount - 1); in make_fuzz_typeface()
457 static sk_sp<SkImageFilter> make_fuzz_imageFilter(Fuzz* fuzz, int depth);
459 static sk_sp<SkImageFilter> make_fuzz_lighting_imagefilter(Fuzz* fuzz, int depth) { in make_fuzz_lighting_imagefilter() argument
464 fuzz->nextRange(&imageFilterType, 1, 6); in make_fuzz_lighting_imagefilter()
471 fuzz->next(&useCropRect); in make_fuzz_lighting_imagefilter()
473 fuzz->next(&cropRect); in make_fuzz_lighting_imagefilter()
477 fuzz->next(&p, &lightColor, &surfaceScale, &k); in make_fuzz_lighting_imagefilter()
478 input = make_fuzz_imageFilter(fuzz, depth - 1); in make_fuzz_lighting_imagefilter()
483 fuzz->next(&p, &lightColor, &surfaceScale, &k); in make_fuzz_lighting_imagefilter()
484 input = make_fuzz_imageFilter(fuzz, depth - 1); in make_fuzz_lighting_imagefilter()
489 fuzz->next(&p, &q, &specularExponent, &cutoffAngle, &lightColor, &surfaceScale, &k); in make_fuzz_lighting_imagefilter()
490 input = make_fuzz_imageFilter(fuzz, depth - 1); in make_fuzz_lighting_imagefilter()
495 fuzz->next(&p, &lightColor, &surfaceScale, &k, &shininess); in make_fuzz_lighting_imagefilter()
496 input = make_fuzz_imageFilter(fuzz, depth - 1); in make_fuzz_lighting_imagefilter()
501 fuzz->next(&p, &lightColor, &surfaceScale, &k, &shininess); in make_fuzz_lighting_imagefilter()
502 input = make_fuzz_imageFilter(fuzz, depth - 1); in make_fuzz_lighting_imagefilter()
507 fuzz->next(&p, &q, &specularExponent, &cutoffAngle, &lightColor, &surfaceScale, &k, in make_fuzz_lighting_imagefilter()
509 input = make_fuzz_imageFilter(fuzz, depth - 1); in make_fuzz_lighting_imagefilter()
519 static void fuzz_paint(Fuzz* fuzz, SkPaint* paint, int depth);
521 static SkSamplingOptions next_sampling(Fuzz* fuzz) { in next_sampling() argument
522 if (fuzz->nextBool()) { in next_sampling()
524 fuzz->next(&B, &C); in next_sampling()
529 fuzz->nextEnum(&fm, SkFilterMode::kLast); in next_sampling()
530 fuzz->nextEnum(&mm, SkMipmapMode::kLast); in next_sampling()
535 static sk_sp<SkImageFilter> make_fuzz_imageFilter(Fuzz* fuzz, int depth) { in make_fuzz_imageFilter() argument
540 fuzz->nextRange(&imageFilterType, 0, 22); in make_fuzz_imageFilter()
546 sk_sp<SkImageFilter> input = make_fuzz_imageFilter(fuzz, depth - 1); in make_fuzz_imageFilter()
548 fuzz->next(&sigmaX, &sigmaY, &useCropRect); in make_fuzz_imageFilter()
551 fuzz->next(&cropRect); in make_fuzz_imageFilter()
558 FuzzNiceMatrix(fuzz, &matrix); in make_fuzz_imageFilter()
559 const auto sampling = next_sampling(fuzz); in make_fuzz_imageFilter()
560 sk_sp<SkImageFilter> input = make_fuzz_imageFilter(fuzz, depth - 1); in make_fuzz_imageFilter()
567 fuzz->next(&k1, &k2, &k3, &k4, &enforcePMColor, &useCropRect); in make_fuzz_imageFilter()
568 sk_sp<SkImageFilter> background = make_fuzz_imageFilter(fuzz, depth - 1); in make_fuzz_imageFilter()
569 sk_sp<SkImageFilter> foreground = make_fuzz_imageFilter(fuzz, depth - 1); in make_fuzz_imageFilter()
572 fuzz->next(&cropRect); in make_fuzz_imageFilter()
579 sk_sp<SkColorFilter> cf = make_fuzz_colorfilter(fuzz, depth - 1); in make_fuzz_imageFilter()
580 sk_sp<SkImageFilter> input = make_fuzz_imageFilter(fuzz, depth - 1); in make_fuzz_imageFilter()
583 fuzz->next(&useCropRect); in make_fuzz_imageFilter()
585 fuzz->next(&cropRect); in make_fuzz_imageFilter()
591 sk_sp<SkImageFilter> ifo = make_fuzz_imageFilter(fuzz, depth - 1); in make_fuzz_imageFilter()
592 sk_sp<SkImageFilter> ifi = make_fuzz_imageFilter(fuzz, depth - 1); in make_fuzz_imageFilter()
597 fuzz->nextEnum(&xChannelSelector, SkColorChannel::kLastEnum); in make_fuzz_imageFilter()
598 fuzz->nextEnum(&yChannelSelector, SkColorChannel::kLastEnum); in make_fuzz_imageFilter()
601 fuzz->next(&scale, &useCropRect); in make_fuzz_imageFilter()
604 fuzz->next(&cropRect); in make_fuzz_imageFilter()
606 sk_sp<SkImageFilter> displacement = make_fuzz_imageFilter(fuzz, depth - 1); in make_fuzz_imageFilter()
607 sk_sp<SkImageFilter> color = make_fuzz_imageFilter(fuzz, depth - 1); in make_fuzz_imageFilter()
616 fuzz->next(&dx, &dy, &sigmaX, &sigmaY, &color, &shadowOnly, &useCropRect); in make_fuzz_imageFilter()
619 fuzz->next(&cropRect); in make_fuzz_imageFilter()
621 sk_sp<SkImageFilter> input = make_fuzz_imageFilter(fuzz, depth - 1); in make_fuzz_imageFilter()
632 return SkImageFilters::Image(make_fuzz_image(fuzz), SkCubicResampler::Mitchell()); in make_fuzz_imageFilter()
634 sk_sp<SkImage> image = make_fuzz_image(fuzz); in make_fuzz_imageFilter()
636 fuzz->next(&srcRect, &dstRect); in make_fuzz_imageFilter()
637 return SkImageFilters::Image(std::move(image), srcRect, dstRect, next_sampling(fuzz)); in make_fuzz_imageFilter()
640 return make_fuzz_lighting_imagefilter(fuzz, depth - 1); in make_fuzz_imageFilter()
647 fuzz->next(&lensBounds, &zoomAmount, &inset, &useCropRect); in make_fuzz_imageFilter()
649 fuzz->next(&cropRect); in make_fuzz_imageFilter()
651 sk_sp<SkImageFilter> input = make_fuzz_imageFilter(fuzz, depth - 1); in make_fuzz_imageFilter()
652 const auto sampling = next_sampling(fuzz); in make_fuzz_imageFilter()
659 fuzz->nextRange(&n, 1, kMaxKernelSize); in make_fuzz_imageFilter()
660 fuzz->nextRange(&m, 1, kMaxKernelSize); in make_fuzz_imageFilter()
662 fuzz->nextN(kernel, n * m); in make_fuzz_imageFilter()
664 fuzz->nextRange(&offsetX, 0, n - 1); in make_fuzz_imageFilter()
665 fuzz->nextRange(&offsetY, 0, m - 1); in make_fuzz_imageFilter()
668 fuzz->next(&gain, &bias, &convolveAlpha, &useCropRect); in make_fuzz_imageFilter()
670 fuzz->nextEnum(&tileMode, SkTileMode::kLastTileMode); in make_fuzz_imageFilter()
673 fuzz->next(&cropRect); in make_fuzz_imageFilter()
675 sk_sp<SkImageFilter> input = make_fuzz_imageFilter(fuzz, depth - 1); in make_fuzz_imageFilter()
681 sk_sp<SkImageFilter> first = make_fuzz_imageFilter(fuzz, depth - 1); in make_fuzz_imageFilter()
682 sk_sp<SkImageFilter> second = make_fuzz_imageFilter(fuzz, depth - 1); in make_fuzz_imageFilter()
684 fuzz->next(&useCropRect); in make_fuzz_imageFilter()
687 fuzz->next(&cropRect); in make_fuzz_imageFilter()
696 fuzz->nextRange(&count, 1, kMaxCount); in make_fuzz_imageFilter()
698 ifs[i] = make_fuzz_imageFilter(fuzz, depth - 1); in make_fuzz_imageFilter()
701 fuzz->next(&useCropRect); in make_fuzz_imageFilter()
704 fuzz->next(&cropRect); in make_fuzz_imageFilter()
710 fuzz->next(&rx, &ry); in make_fuzz_imageFilter()
712 fuzz->next(&useCropRect); in make_fuzz_imageFilter()
715 fuzz->next(&cropRect); in make_fuzz_imageFilter()
717 sk_sp<SkImageFilter> input = make_fuzz_imageFilter(fuzz, depth - 1); in make_fuzz_imageFilter()
723 fuzz->next(&rx, &ry); in make_fuzz_imageFilter()
725 fuzz->next(&useCropRect); in make_fuzz_imageFilter()
728 fuzz->next(&cropRect); in make_fuzz_imageFilter()
730 sk_sp<SkImageFilter> input = make_fuzz_imageFilter(fuzz, depth - 1); in make_fuzz_imageFilter()
736 fuzz->next(&dx, &dy); in make_fuzz_imageFilter()
738 fuzz->next(&useCropRect); in make_fuzz_imageFilter()
741 fuzz->next(&cropRect); in make_fuzz_imageFilter()
743 sk_sp<SkImageFilter> input = make_fuzz_imageFilter(fuzz, depth - 1); in make_fuzz_imageFilter()
748 sk_sp<SkPicture> picture = make_fuzz_picture(fuzz, depth - 1); in make_fuzz_imageFilter()
753 fuzz->next(&cropRect); in make_fuzz_imageFilter()
754 sk_sp<SkPicture> picture = make_fuzz_picture(fuzz, depth - 1); in make_fuzz_imageFilter()
759 fuzz->next(&src, &dst); in make_fuzz_imageFilter()
760 sk_sp<SkImageFilter> input = make_fuzz_imageFilter(fuzz, depth - 1); in make_fuzz_imageFilter()
766 fuzz->next(&useCropRect); in make_fuzz_imageFilter()
767 fuzz->nextEnum(&blendMode, SkBlendMode::kLastMode); in make_fuzz_imageFilter()
770 fuzz->next(&cropRect); in make_fuzz_imageFilter()
772 sk_sp<SkImageFilter> bg = make_fuzz_imageFilter(fuzz, depth - 1); in make_fuzz_imageFilter()
773 sk_sp<SkImageFilter> fg = make_fuzz_imageFilter(fuzz, depth - 1); in make_fuzz_imageFilter()
778 sk_sp<SkShader> shader = make_fuzz_shader(fuzz, depth - 1); in make_fuzz_imageFilter()
780 fuzz->next(&useCropRect); in make_fuzz_imageFilter()
783 fuzz->next(&cropRect); in make_fuzz_imageFilter()
793 static sk_sp<SkImage> make_fuzz_image(Fuzz* fuzz) { in make_fuzz_image() argument
795 fuzz->nextRange(&w, 1, 1024); in make_fuzz_image()
796 fuzz->nextRange(&h, 1, 1024); in make_fuzz_image()
802 fuzz->next(&c); in make_fuzz_image()
811 static T make_fuzz_enum_range(Fuzz* fuzz, T maxv) { in make_fuzz_enum_range() argument
813 fuzz->nextEnum(&value, maxv); in make_fuzz_enum_range()
817 static void fuzz_paint(Fuzz* fuzz, SkPaint* paint, int depth) { in fuzz_paint() argument
818 if (!fuzz || !paint || depth <= 0) { in fuzz_paint()
822 paint->setAntiAlias( make_fuzz_t<bool>(fuzz)); in fuzz_paint()
823 paint->setDither( make_fuzz_t<bool>(fuzz)); in fuzz_paint()
824 paint->setColor( make_fuzz_t<SkColor>(fuzz)); in fuzz_paint()
825 paint->setBlendMode( make_fuzz_enum_range<SkBlendMode>(fuzz, SkBlendMode::kLastMode)); in fuzz_paint()
826 paint->setStyle( make_fuzz_enum_range<SkPaint::Style>(fuzz, in fuzz_paint()
828 paint->setShader( make_fuzz_shader(fuzz, depth - 1)); in fuzz_paint()
829 paint->setPathEffect( make_fuzz_patheffect(fuzz, depth - 1)); in fuzz_paint()
830 paint->setMaskFilter( make_fuzz_maskfilter(fuzz)); in fuzz_paint()
831 paint->setImageFilter( make_fuzz_imageFilter(fuzz, depth - 1)); in fuzz_paint()
832 paint->setColorFilter( make_fuzz_colorfilter(fuzz, depth - 1)); in fuzz_paint()
835 paint->setStrokeWidth(make_fuzz_t<SkScalar>(fuzz)); in fuzz_paint()
836 paint->setStrokeMiter(make_fuzz_t<SkScalar>(fuzz)); in fuzz_paint()
837 paint->setStrokeCap( make_fuzz_enum_range<SkPaint::Cap>(fuzz, SkPaint::kLast_Cap)); in fuzz_paint()
838 paint->setStrokeJoin( make_fuzz_enum_range<SkPaint::Join>(fuzz, SkPaint::kLast_Join)); in fuzz_paint()
842 static SkFont fuzz_font(Fuzz* fuzz) { in fuzz_font() argument
844 font.setTypeface( make_fuzz_typeface(fuzz)); in fuzz_font()
845 font.setSize( make_fuzz_t<SkScalar>(fuzz)); in fuzz_font()
846 font.setScaleX( make_fuzz_t<SkScalar>(fuzz)); in fuzz_font()
847 font.setSkewX( make_fuzz_t<SkScalar>(fuzz)); in fuzz_font()
848 font.setLinearMetrics( make_fuzz_t<bool>(fuzz)); in fuzz_font()
849 font.setSubpixel( make_fuzz_t<bool>(fuzz)); in fuzz_font()
850 font.setEmbeddedBitmaps( make_fuzz_t<bool>(fuzz)); in fuzz_font()
851 font.setForceAutoHinting( make_fuzz_t<bool>(fuzz)); in fuzz_font()
852 font.setEmbolden( make_fuzz_t<bool>(fuzz)); in fuzz_font()
853 font.setHinting( make_fuzz_enum_range<SkFontHinting>(fuzz, SkFontHinting::kFull)); in fuzz_font()
854 font.setEdging( make_fuzz_enum_range<SkFont::Edging>(fuzz, in fuzz_font()
859 static SkTextEncoding fuzz_paint_text_encoding(Fuzz* fuzz) { in fuzz_paint_text_encoding() argument
860 return make_fuzz_enum_range<SkTextEncoding>(fuzz, SkTextEncoding::kUTF32); in fuzz_paint_text_encoding()
865 static SkTDArray<uint8_t> make_fuzz_text(Fuzz* fuzz, const SkFont& font, SkTextEncoding encoding) { in make_fuzz_text() argument
875 fuzz->nextRange(&glyphCount, 1, kMaxGlyphCount); in make_fuzz_text()
878 fuzz->nextRange(&glyphs[i], 0, glyphRange - 1); in make_fuzz_text()
894 fuzz->nextRange(&length, 1, kMaxLength); in make_fuzz_text()
897 fuzz->nextRange(&value, 0, count - 1); in make_fuzz_text()
938 static std::string make_fuzz_string(Fuzz* fuzz) { in make_fuzz_string() argument
940 fuzz->nextRange(&len, 0, kMaxGlyphCount); in make_fuzz_string()
943 fuzz->next(&str[i]); in make_fuzz_string()
948 static sk_sp<SkTextBlob> make_fuzz_textblob(Fuzz* fuzz) { in make_fuzz_textblob() argument
951 fuzz->nextRange(&runCount, (int8_t)1, (int8_t)8); in make_fuzz_textblob()
954 SkTextEncoding encoding = fuzz_paint_text_encoding(fuzz); in make_fuzz_textblob()
955 … font.setEdging(make_fuzz_t<bool>(fuzz) ? SkFont::Edging::kAlias : SkFont::Edging::kAntiAlias); in make_fuzz_textblob()
956 SkTDArray<uint8_t> text = make_fuzz_text(fuzz, font, encoding); in make_fuzz_textblob()
962 fuzz->nextRange(&runType, (uint8_t)0, (uint8_t)2); in make_fuzz_textblob()
967 fuzz->next(&x, &y); in make_fuzz_textblob()
973 fuzz->next(&y); in make_fuzz_textblob()
977 fuzz->nextN(buffer->pos, glyphCount); in make_fuzz_textblob()
983 fuzz->nextN(buffer->pos, glyphCount * 2); in make_fuzz_textblob()
993 static void fuzz_canvas(Fuzz* fuzz, SkCanvas* canvas, int depth = 9) { in fuzz_canvas() argument
994 if (!fuzz || !canvas || depth <= 0) { in fuzz_canvas()
999 fuzz->nextRange(&N, 0, 2000); in fuzz_canvas()
1001 if (fuzz->exhausted()) { in fuzz_canvas()
1007 fuzz->nextRange(&drawCommand, 0, 62); in fuzz_canvas()
1021 fuzz->next(&bounds); in fuzz_canvas()
1022 fuzz_paint(fuzz, &paint, depth - 1); in fuzz_canvas()
1028 fuzz->next(&bounds); in fuzz_canvas()
1033 fuzz_paint(fuzz, &paint, depth - 1); in fuzz_canvas()
1041 fuzz->next(&alpha); in fuzz_canvas()
1048 fuzz->next(&bounds, &alpha); in fuzz_canvas()
1055 if (make_fuzz_t<bool>(fuzz)) { in fuzz_canvas()
1056 fuzz->next(&bounds); in fuzz_canvas()
1059 if (make_fuzz_t<bool>(fuzz)) { in fuzz_canvas()
1060 fuzz_paint(fuzz, &paint, depth - 1); in fuzz_canvas()
1064 if (make_fuzz_t<bool>(fuzz)) { in fuzz_canvas()
1065 imageFilter = make_fuzz_imageFilter(fuzz, depth - 1); in fuzz_canvas()
1069 // if (make_fuzz_t<bool>(fuzz)) { in fuzz_canvas()
1081 fuzz->next(&saveCount); in fuzz_canvas()
1087 fuzz->next(&x, &y); in fuzz_canvas()
1093 fuzz->next(&x, &y); in fuzz_canvas()
1099 fuzz->next(&v); in fuzz_canvas()
1105 fuzz->next(&x, &y, &v); in fuzz_canvas()
1111 fuzz->next(&x, &y); in fuzz_canvas()
1117 FuzzNiceMatrix(fuzz, &mat); in fuzz_canvas()
1123 FuzzNiceMatrix(fuzz, &mat); in fuzz_canvas()
1134 fuzz->next(&r, &doAntiAlias); in fuzz_canvas()
1135 fuzz->nextRange(&op, 0, 1); in fuzz_canvas()
1144 FuzzNiceRRect(fuzz, &rr); in fuzz_canvas()
1145 fuzz->next(&doAntiAlias); in fuzz_canvas()
1146 fuzz->nextRange(&op, 0, 1); in fuzz_canvas()
1152 FuzzNicePath(fuzz, &path, 30); in fuzz_canvas()
1155 fuzz->next(&doAntiAlias); in fuzz_canvas()
1156 fuzz->nextRange(&op, 0, 1); in fuzz_canvas()
1163 fuzz->next(®ion); in fuzz_canvas()
1164 fuzz->nextRange(&op, 0, 1); in fuzz_canvas()
1169 fuzz_paint(fuzz, &paint, depth - 1); in fuzz_canvas()
1173 fuzz_paint(fuzz, &paint, depth - 1); in fuzz_canvas()
1175 fuzz->nextRange(&pointMode, in fuzz_canvas()
1179 fuzz->nextRange(&count, 0, kMaxCount); in fuzz_canvas()
1181 fuzz->nextN(pts, count); in fuzz_canvas()
1186 fuzz_paint(fuzz, &paint, depth - 1); in fuzz_canvas()
1188 fuzz->next(&r); in fuzz_canvas()
1196 fuzz_paint(fuzz, &paint, depth - 1); in fuzz_canvas()
1198 fuzz->next(®ion); in fuzz_canvas()
1203 fuzz_paint(fuzz, &paint, depth - 1); in fuzz_canvas()
1205 fuzz->next(&r); in fuzz_canvas()
1214 fuzz_paint(fuzz, &paint, depth - 1); in fuzz_canvas()
1216 FuzzNiceRRect(fuzz, &rr); in fuzz_canvas()
1221 fuzz_paint(fuzz, &paint, depth - 1); in fuzz_canvas()
1223 FuzzNiceRRect(fuzz, &orr); in fuzz_canvas()
1224 FuzzNiceRRect(fuzz, &irr); in fuzz_canvas()
1231 fuzz_paint(fuzz, &paint, depth - 1); in fuzz_canvas()
1235 fuzz->next(&r, &start, &sweep, &useCenter); in fuzz_canvas()
1240 fuzz_paint(fuzz, &paint, depth - 1); in fuzz_canvas()
1242 FuzzNicePath(fuzz, &path, 60); in fuzz_canvas()
1247 sk_sp<SkImage> img = make_fuzz_image(fuzz); in fuzz_canvas()
1250 fuzz->next(&left, &top, &usePaint); in fuzz_canvas()
1252 fuzz_paint(fuzz, &paint, depth - 1); in fuzz_canvas()
1259 auto img = make_fuzz_image(fuzz); in fuzz_canvas()
1263 fuzz->next(&src, &dst, &usePaint); in fuzz_canvas()
1265 fuzz_paint(fuzz, &paint, depth - 1); in fuzz_canvas()
1268 make_fuzz_t<bool>(fuzz) ? SkCanvas::kStrict_SrcRectConstraint in fuzz_canvas()
1275 auto img = make_fuzz_image(fuzz); in fuzz_canvas()
1279 fuzz->next(&usePaint); in fuzz_canvas()
1281 fuzz_paint(fuzz, &paint, depth - 1); in fuzz_canvas()
1283 if (make_fuzz_t<bool>(fuzz)) { in fuzz_canvas()
1284 fuzz->next(¢er); in fuzz_canvas()
1286 fuzz->nextRange(¢er.fLeft, 0, img->width() - 1); in fuzz_canvas()
1287 fuzz->nextRange(¢er.fTop, 0, img->height() - 1); in fuzz_canvas()
1288 fuzz->nextRange(¢er.fRight, center.fLeft + 1, img->width()); in fuzz_canvas()
1289 fuzz->nextRange(¢er.fBottom, center.fTop + 1, img->height()); in fuzz_canvas()
1291 fuzz->next(&dst); in fuzz_canvas()
1297 auto img = make_fuzz_image(fuzz); in fuzz_canvas()
1300 fuzz->next(&usePaint, &dst); in fuzz_canvas()
1302 fuzz_paint(fuzz, &paint, depth - 1); in fuzz_canvas()
1307 fuzz->nextRange(&lattice.fXCount, 2, kMax); in fuzz_canvas()
1308 fuzz->nextRange(&lattice.fYCount, 2, kMax); in fuzz_canvas()
1309 fuzz->nextN(xDivs, lattice.fXCount); in fuzz_canvas()
1310 fuzz->nextN(yDivs, lattice.fYCount); in fuzz_canvas()
1316 fuzz_paint(fuzz, &paint, depth - 1); in fuzz_canvas()
1317 font = fuzz_font(fuzz); in fuzz_canvas()
1318 SkTextEncoding encoding = fuzz_paint_text_encoding(fuzz); in fuzz_canvas()
1320 fuzz->next(&x, &y); in fuzz_canvas()
1321 SkTDArray<uint8_t> text = make_fuzz_text(fuzz, font, encoding); in fuzz_canvas()
1347 sk_sp<SkTextBlob> blob = make_fuzz_textblob(fuzz); in fuzz_canvas()
1348 fuzz_paint(fuzz, &paint, depth - 1); in fuzz_canvas()
1350 fuzz->next(&x, &y); in fuzz_canvas()
1357 fuzz->next(&usePaint, &useMatrix); in fuzz_canvas()
1359 fuzz_paint(fuzz, &paint, depth - 1); in fuzz_canvas()
1362 FuzzNiceMatrix(fuzz, &matrix); in fuzz_canvas()
1364 auto pic = make_fuzz_picture(fuzz, depth - 1); in fuzz_canvas()
1370 fuzz_paint(fuzz, &paint, depth - 1); in fuzz_canvas()
1373 fuzz->nextRange(&vertexMode, 0, SkVertices::kTriangleFan_VertexMode); in fuzz_canvas()
1374 fuzz->nextRange(&blendMode, 0, SkBlendMode::kLastMode); in fuzz_canvas()
1380 fuzz->nextRange(&vertexCount, 3, kMaxCount); in fuzz_canvas()
1381 fuzz->nextN(vertices, vertexCount); in fuzz_canvas()
1383 fuzz->next(&useTexs, &useColors); in fuzz_canvas()
1385 fuzz->nextN(texs, vertexCount); in fuzz_canvas()
1388 fuzz->nextN(colors, vertexCount); in fuzz_canvas()
1392 if (make_fuzz_t<bool>(fuzz)) { in fuzz_canvas()
1393 fuzz->nextRange(&indexCount, vertexCount, vertexCount + kMaxCount); in fuzz_canvas()
1395 fuzz->nextRange(&indices[index], 0, vertexCount - 1); in fuzz_canvas()
1408 fuzz->nextRange(&blendMode, 0, SkBlendMode::kSrcOver); in fuzz_canvas()
1409 fuzz->next(&color); in fuzz_canvas()
1417 fuzz->nextRange(&blendMode, 0, SkBlendMode::kSrcOver); in fuzz_canvas()
1418 fuzz->nextRange(&R, -1, 2); in fuzz_canvas()
1419 fuzz->nextRange(&G, -1, 2); in fuzz_canvas()
1420 fuzz->nextRange(&B, -1, 2); in fuzz_canvas()
1421 fuzz->nextRange(&Alpha, 0, 1); in fuzz_canvas()
1427 fuzz_paint(fuzz, &paint, depth - 1); in fuzz_canvas()
1429 fuzz->next(&p0, &p1); in fuzz_canvas()
1434 fuzz_paint(fuzz, &paint, depth - 1); in fuzz_canvas()
1436 fuzz->next(&r); in fuzz_canvas()
1441 fuzz_paint(fuzz, &paint, depth - 1); in fuzz_canvas()
1444 fuzz->next(&radius, ¢er); in fuzz_canvas()
1449 fuzz_paint(fuzz, &paint, depth - 1); in fuzz_canvas()
1453 fuzz->next(&oval, &startAngle, &sweepAngle, &useCenter); in fuzz_canvas()
1458 fuzz_paint(fuzz, &paint, depth - 1); in fuzz_canvas()
1461 fuzz->next(&rect, &rx, &ry); in fuzz_canvas()
1466 fuzz_paint(fuzz, &paint, depth - 1); in fuzz_canvas()
1467 font = fuzz_font(fuzz); in fuzz_canvas()
1468 std::string str = make_fuzz_string(fuzz); in fuzz_canvas()
1470 fuzz->next(&x, &y); in fuzz_canvas()
1475 fuzz_paint(fuzz, &paint, depth - 1); in fuzz_canvas()
1480 fuzz->nextN(cubics, 12); in fuzz_canvas()
1481 fuzz->nextN(colors, 4); in fuzz_canvas()
1482 fuzz->next(&useTexCoords); in fuzz_canvas()
1484 fuzz->nextN(texCoords, 4); in fuzz_canvas()
1487 fuzz->nextEnum(&mode, SkBlendMode::kLastMode); in fuzz_canvas()
1499 static sk_sp<SkPicture> make_fuzz_picture(Fuzz* fuzz, int depth) { in make_fuzz_picture() argument
1501 fuzz->next(&w, &h); in make_fuzz_picture()
1503 fuzz_canvas(fuzz, pictureRecorder.beginRecording(w, h), depth - 1); in make_fuzz_picture()
1507 DEF_FUZZ(NullCanvas, fuzz) { in DEF_FUZZ() argument
1508 fuzz_canvas(fuzz, SkMakeNullCanvas().get()); in DEF_FUZZ()
1513 DEF_FUZZ(RasterN32Canvas, fuzz) { in DEF_FUZZ() argument
1516 if (!surface || !surface->getCanvas()) { fuzz->signalBug(); } in DEF_FUZZ()
1517 fuzz_canvas(fuzz, surface->getCanvas()); in DEF_FUZZ()
1524 DEF_FUZZ(RasterN32CanvasViaSerialization, fuzz) { in DEF_FUZZ() argument
1526 fuzz_canvas(fuzz, recorder.beginRecording(SkIntToScalar(kCanvasSize.width()), in DEF_FUZZ()
1529 if (!pic) { fuzz->signalBug(); } in DEF_FUZZ()
1535 if (!data) { fuzz->signalBug(); } in DEF_FUZZ()
1539 if (!deserialized) { fuzz->signalBug(); } in DEF_FUZZ()
1548 DEF_FUZZ(ImageFilter, fuzz) { in DEF_FUZZ() argument
1555 auto fil = make_fuzz_imageFilter(fuzz, 20); in DEF_FUZZ()
1567 DEF_FUZZ(SerializedImageFilter, fuzz) { in DEF_FUZZ() argument
1574 auto filter = make_fuzz_imageFilter(fuzz, 20); in DEF_FUZZ()
1585 fuzz->nextRange(&j, 1, 250); in DEF_FUZZ()
1588 fuzz->nextRange(&k, 1, 10); in DEF_FUZZ()
1591 fuzz->nextRange(&s, 0, 2); in DEF_FUZZ()
1605 fuzz->nextRange(&s, 0, 7); in DEF_FUZZ()
1630 static void fuzz_ganesh(Fuzz* fuzz, GrDirectContext* context) { in fuzz_ganesh() argument
1637 fuzz_canvas(fuzz, surface->getCanvas()); in fuzz_ganesh()
1640 DEF_FUZZ(MockGPUCanvas, fuzz) { in DEF_FUZZ() argument
1642 fuzz_ganesh(fuzz, f.get(skgpu::ContextType::kMock)); in DEF_FUZZ()
1661 DEF_FUZZ(NativeGLCanvas, fuzz) { in DEF_FUZZ() argument
1670 fuzz_ganesh(fuzz, context); in DEF_FUZZ()
1674 DEF_FUZZ(PDFCanvas, fuzz) { in DEF_FUZZ() argument
1677 fuzz_canvas(fuzz, doc->beginPage(SkIntToScalar(kCanvasSize.width()), in DEF_FUZZ()
1681 // not a "real" thing to fuzz, used to debug errors found while fuzzing.
1682 DEF_FUZZ(_DumpCanvas, fuzz) { in DEF_FUZZ() argument
1684 fuzz_canvas(fuzz, &debugCanvas); in DEF_FUZZ()
1697 DEF_FUZZ(SVGCanvas, fuzz) { in DEF_FUZZ() argument
1701 fuzz_canvas(fuzz, canvas.get()); in DEF_FUZZ()