static SkPathEffect* make_path_effect(bool canBeNull = true) { SkPathEffect* pathEffect = nullptr; if (canBeNull && (R(3) == 1)) { return pathEffect; } switch (R(9)) { case 0: pathEffect = SkArcToPathEffect::Create(make_scalar(true)); break; case 1: { SkAutoTUnref<SkPathEffect> outer(make_path_effect(false)); SkAutoTUnref<SkPathEffect> inner(make_path_effect(false)); pathEffect = SkComposePathEffect::Create(outer, inner); break; } case 2: pathEffect = SkCornerPathEffect::Create(make_scalar()); break; case 3: { int count = R(10); SkScalar intervals[10]; for (int i = 0; i < count; ++i) { intervals[i] = make_scalar(); } pathEffect = SkDashPathEffect::Create(intervals, count, make_scalar()); break; } case 4: pathEffect = SkDiscretePathEffect::Create(make_scalar(), make_scalar()); break; case 5: pathEffect = SkPath1DPathEffect::Create(make_path(), make_scalar(), make_scalar(), make_path_1d_path_effect_style()); break; case 6: pathEffect = SkLine2DPathEffect::Create(make_scalar(), make_matrix()); break; case 7: pathEffect = SkPath2DPathEffect::Create(make_matrix(), make_path()); break; case 8: default: pathEffect = SkSumPathEffect::Create(make_path_effect(false), make_path_effect(false)); break; } return pathEffect; }
static sk_sp<SkPathEffect> make_path_effect(bool canBeNull = true) { sk_sp<SkPathEffect> pathEffect; if (canBeNull && (R(3) == 1)) { return pathEffect; } switch (R(8)) { case 0: pathEffect = SkPath2DPathEffect::Make(make_matrix(), make_path()); break; case 1: pathEffect = SkPathEffect::MakeCompose(make_path_effect(false), make_path_effect(false)); break; case 2: pathEffect = SkCornerPathEffect::Make(make_scalar()); break; case 3: { int count = R(10); SkScalar intervals[10]; for (int i = 0; i < count; ++i) { intervals[i] = make_scalar(); } pathEffect = SkDashPathEffect::Make(intervals, count, make_scalar()); break; } case 4: pathEffect = SkDiscretePathEffect::Make(make_scalar(), make_scalar()); break; case 5: pathEffect = SkPath1DPathEffect::Make(make_path(), make_scalar(), make_scalar(), make_path_1d_path_effect_style()); break; case 6: pathEffect = SkLine2DPathEffect::Make(make_scalar(), make_matrix()); break; case 7: default: pathEffect = SkPathEffect::MakeSum(make_path_effect(false), make_path_effect(false)); break; } return pathEffect; }
static SkPaint make_paint() { SkPaint paint; if (fuzz->exhausted()) { return paint; } paint.setHinting(make_paint_hinting()); paint.setAntiAlias(make_bool()); paint.setDither(make_bool()); paint.setLinearText(make_bool()); paint.setSubpixelText(make_bool()); paint.setLCDRenderText(make_bool()); paint.setEmbeddedBitmapText(make_bool()); paint.setAutohinted(make_bool()); paint.setVerticalText(make_bool()); paint.setFakeBoldText(make_bool()); paint.setDevKernText(make_bool()); paint.setFilterQuality(make_filter_quality()); paint.setStyle(make_paint_style()); paint.setColor(make_color()); paint.setStrokeWidth(make_number(false)); paint.setStrokeMiter(make_number(false)); paint.setStrokeCap(make_paint_cap()); paint.setStrokeJoin(make_paint_join()); paint.setColorFilter(make_color_filter()); paint.setBlendMode(make_blendmode()); paint.setPathEffect(make_path_effect()); paint.setMaskFilter(make_mask_filter()); if (false) { // our validating buffer does not support typefaces yet, so skip this for now paint.setTypeface(SkTypeface::MakeFromName(make_font_name().c_str(),make_typeface_style())); } SkLayerRasterizer::Builder rasterizerBuilder; SkPaint paintForRasterizer; if (make_bool()) { paintForRasterizer = make_paint(); } rasterizerBuilder.addLayer(paintForRasterizer); paint.setRasterizer(rasterizerBuilder.detach()); paint.setImageFilter(make_image_filter()); bool a, b, c; fuzz->next(&a, &b, &c); sk_sp<SkData> data(make_3Dlut(nullptr, a, b, c)); paint.setTextAlign(make_paint_align()); SkScalar d, e, f; fuzz->next(&d, &e, &f); paint.setTextSize(d); paint.setTextScaleX(e); paint.setTextSkewX(f); paint.setTextEncoding(make_paint_text_encoding()); return paint; }
static SkPaint make_paint() { SkPaint paint; paint.setHinting(make_paint_hinting()); paint.setAntiAlias(make_bool()); paint.setDither(make_bool()); paint.setLinearText(make_bool()); paint.setSubpixelText(make_bool()); paint.setLCDRenderText(make_bool()); paint.setEmbeddedBitmapText(make_bool()); paint.setAutohinted(make_bool()); paint.setVerticalText(make_bool()); paint.setUnderlineText(make_bool()); paint.setStrikeThruText(make_bool()); paint.setFakeBoldText(make_bool()); paint.setDevKernText(make_bool()); paint.setFilterQuality(make_filter_quality()); paint.setStyle(make_paint_style()); paint.setColor(make_color()); paint.setStrokeWidth(make_scalar()); paint.setStrokeMiter(make_scalar()); paint.setStrokeCap(make_paint_cap()); paint.setStrokeJoin(make_paint_join()); paint.setColorFilter(make_color_filter()); paint.setXfermodeMode(make_xfermode()); paint.setPathEffect(make_path_effect()); paint.setMaskFilter(make_mask_filter()); if (false) { // our validating buffer does not support typefaces yet, so skip this for now SkAutoTUnref<SkTypeface> typeface( SkTypeface::CreateFromName(make_font_name().c_str(), make_typeface_style())); paint.setTypeface(typeface); } SkLayerRasterizer::Builder rasterizerBuilder; SkPaint paintForRasterizer; if (R(2) == 1) { paintForRasterizer = make_paint(); } rasterizerBuilder.addLayer(paintForRasterizer); paint.setRasterizer(rasterizerBuilder.detach()); paint.setImageFilter(make_image_filter()); sk_sp<SkData> data(make_3Dlut(nullptr, make_bool(), make_bool(), make_bool())); paint.setTextAlign(make_paint_align()); paint.setTextSize(make_scalar()); paint.setTextScaleX(make_scalar()); paint.setTextSkewX(make_scalar()); paint.setTextEncoding(make_paint_text_encoding()); return paint; }
static SkPaint make_paint() { SkPaint paint; paint.setHinting(make_paint_hinting()); paint.setAntiAlias(make_bool()); paint.setDither(make_bool()); paint.setLinearText(make_bool()); paint.setSubpixelText(make_bool()); paint.setLCDRenderText(make_bool()); paint.setEmbeddedBitmapText(make_bool()); paint.setAutohinted(make_bool()); paint.setVerticalText(make_bool()); paint.setFakeBoldText(make_bool()); paint.setDevKernText(make_bool()); paint.setFilterQuality(make_filter_quality()); paint.setStyle(make_paint_style()); paint.setColor(make_color()); paint.setStrokeWidth(make_scalar()); paint.setStrokeMiter(make_scalar()); paint.setStrokeCap(make_paint_cap()); paint.setStrokeJoin(make_paint_join()); paint.setColorFilter(make_color_filter()); paint.setBlendMode(make_xfermode()); paint.setPathEffect(make_path_effect()); paint.setMaskFilter(make_mask_filter()); if (false) { // our validating buffer does not support typefaces yet, so skip this for now paint.setTypeface(SkTypeface::MakeFromName(make_font_name().c_str(), make_typeface_style())); } paint.setImageFilter(make_image_filter()); sk_sp<SkData> data(make_3Dlut(nullptr, make_bool(), make_bool(), make_bool())); paint.setTextAlign(make_paint_align()); paint.setTextSize(make_scalar()); paint.setTextScaleX(make_scalar()); paint.setTextSkewX(make_scalar()); paint.setTextEncoding(make_paint_text_encoding()); return paint; }
static sk_sp<SkPathEffect> make_path_effect(bool canBeNull = true) { sk_sp<SkPathEffect> pathEffect; uint8_t s; fuzz->nextRange(&s, 0, 2); if (canBeNull && s == 0) { return pathEffect; } fuzz->nextRange(&s, 0, 8); switch (s) { case 0: { SkScalar a = make_number(true); pathEffect = SkArcToPathEffect::Make(a); break; } case 1: { sk_sp<SkPathEffect> a = make_path_effect(false); sk_sp<SkPathEffect> b = make_path_effect(false); pathEffect = SkPathEffect::MakeCompose(a, b); break; } case 2: { SkScalar a = make_number(false); pathEffect = SkCornerPathEffect::Make(a); break; } case 3: { uint8_t count; fuzz->nextRange(&count, 0, 9); SkScalar intervals[10]; fuzz->nextN(intervals, 10); SkScalar a = make_number(false); pathEffect = SkDashPathEffect::Make(intervals, count, a); break; } case 4: { SkScalar a, b; fuzz->next(&a, &b); pathEffect = SkDiscretePathEffect::Make(a, b); break; } case 5: { SkPath path = make_path(); SkScalar a, b; fuzz->next(&a, &b); SkPath1DPathEffect::Style style = make_path_1d_path_effect_style(); pathEffect = SkPath1DPathEffect::Make(path, a, b, style); break; } case 6: { SkScalar a = make_number(false); SkMatrix m; init_matrix(&m); pathEffect = SkLine2DPathEffect::Make(a, m); break; } case 7: { SkPath path = make_path(); SkMatrix m; init_matrix(&m); pathEffect = SkPath2DPathEffect::Make(m, path); break; } case 8: default: { sk_sp<SkPathEffect> a = make_path_effect(false); sk_sp<SkPathEffect> b = make_path_effect(false); pathEffect = SkPathEffect::MakeCompose(a, b); break; } } return pathEffect; }