From 7796f00dcfd09ca52140c4133ddc9bc197b832db Mon Sep 17 00:00:00 2001 From: Florin Malita Date: Fri, 8 Jun 2018 12:25:38 -0400 Subject: SkJson For now this is only wired to a bench and a couple of tests. Local numbers, for a ~500KB BM "compressed" json: micros bench 2456.54 json_rapidjson nonrendering 1192.38 json_skjson nonrendering Change-Id: I7b3514f84c7c525d1787722c43ad6095e3692563 Reviewed-on: https://skia-review.googlesource.com/127622 Reviewed-by: Mike Klein Commit-Queue: Florin Malita --- fuzz/fuzz.cpp | 64 ++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 20 deletions(-) (limited to 'fuzz/fuzz.cpp') diff --git a/fuzz/fuzz.cpp b/fuzz/fuzz.cpp index 0917747790..ce0119c1a9 100644 --- a/fuzz/fuzz.cpp +++ b/fuzz/fuzz.cpp @@ -28,10 +28,6 @@ #include "SkSLCompiler.h" #endif -#if defined(SK_ENABLE_SKOTTIE) -#include "Skottie.h" -#endif - #include #include #include @@ -47,22 +43,31 @@ DEFINE_string2(name, n, "", "If --type is 'api', fuzz the API with this name."); DEFINE_string2(dump, d, "", "If not empty, dump 'image*' or 'skp' types as a " "PNG with this name."); DEFINE_bool2(verbose, v, false, "Print more information while fuzzing."); -DEFINE_string2(type, t, "", "How to interpret --bytes, one of:\n" - "animated_image_decode\n" - "api\n" - "color_deserialize\n" - "filter_fuzz (equivalent to Chrome's filter_fuzz_stub)\n" - "image_decode\n" - "image_mode\n" - "image_scale\n" - "path_deserialize\n" - "pipe\n" - "region_deserialize\n" - "region_set_path\n" - "skp\n" - "sksl2glsl\n" - "skottie_json\n" - "textblob"); + +// This cannot be inlined in DEFINE_string2 due to interleaved ifdefs +static constexpr char g_type_message[] = "How to interpret --bytes, one of:\n" + "animated_image_decode\n" + "api\n" + "color_deserialize\n" + "filter_fuzz (equivalent to Chrome's filter_fuzz_stub)\n" + "image_decode\n" + "image_mode\n" + "image_scale\n" + "path_deserialize\n" + "pipe\n" + "region_deserialize\n" + "region_set_path\n" +#if defined(SK_ENABLE_SKJSON) + "skjson\n" +#endif + "skp\n" + "sksl2glsl\n" +#if defined(SK_ENABLE_SKOTTIE) + "skottie_json\n" +#endif + "textblob"; + +DEFINE_string2(type, t, "", g_type_message); static int fuzz_file(SkString path, SkString type); static uint8_t calculate_option(SkData*); @@ -87,6 +92,10 @@ static void print_api_names(); static void fuzz_sksl2glsl(sk_sp); #endif +#if defined(SK_ENABLE_SKJSON) +static void fuzz_skjson(sk_sp); +#endif + #if defined(SK_ENABLE_SKOTTIE) static void fuzz_skottie_json(sk_sp); #endif @@ -181,6 +190,12 @@ static int fuzz_file(SkString path, SkString type) { fuzz_skpipe(bytes); return 0; } +#if defined(SK_ENABLE_SKJSON) + if (type.equals("skjson")) { + fuzz_skjson(bytes); + return 0; + } +#endif #if defined(SK_ENABLE_SKOTTIE) if (type.equals("skottie_json")) { fuzz_skottie_json(bytes); @@ -266,6 +281,15 @@ static SkString try_auto_detect(SkString path, SkString* name) { return SkString(""); } +#if defined(SK_ENABLE_SKJSON) +void FuzzSkJSON(sk_sp bytes); + +static void fuzz_skjson(sk_sp bytes){ + FuzzSkJSON(bytes); + SkDebugf("[terminated] Done parsing!\n"); +} +#endif + #if defined(SK_ENABLE_SKOTTIE) void FuzzSkottieJSON(sk_sp bytes); -- cgit v1.2.3