From edef8ec4b24f9d2ce76e4c53304e25853888bee4 Mon Sep 17 00:00:00 2001 From: Kevin Lubick Date: Tue, 9 Jan 2018 15:32:58 -0500 Subject: Refactor SerializedImageFilter to avoid duplicate code After this CL, we have 3.5 options for fuzzing ImageFilter 1. Create it from API calls and then draw it fuzz -t api -n ImageFilter -b [input] 2. Deserialize a fuzzed stream into an ImageFilter (this is what Chromium's filter_fuzz_stub does) fuzz -t filter_fuzz -b [input] 3. Create an ImageFilter from API calls, serialize it, apply some mutations to the stream, deserialize it, then draw it. fuzz -t api -n SerializedImageFilter -b [input] 3.5 Create ImageFilters as part of our more general canvas fuzzers. fuzz -t api -n RasterN32Canvas -b [input] (and others) Previously, the SerializedImageFilter had its own, slightly stale and prone to stack-overflow way of making an image filter. This CL re-uses what we already do for Canvas fuzzing and removes that dead code. Additionally, there is a way to easily generate a corpus for the filter_fuzz type, via SerializedImageFilter. Bug: skia: Change-Id: I31bb4ffce2abf1c1a6d0a7000e5aceb8d7b38b65 Reviewed-on: https://skia-review.googlesource.com/92142 Reviewed-by: Hal Canary Commit-Queue: Kevin Lubick --- fuzz/fuzz.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'fuzz/fuzz.cpp') diff --git a/fuzz/fuzz.cpp b/fuzz/fuzz.cpp index 0d19027d6e..45298ca871 100644 --- a/fuzz/fuzz.cpp +++ b/fuzz/fuzz.cpp @@ -555,15 +555,13 @@ static void fuzz_textblob_deserialize(sk_sp bytes) { } static void fuzz_filter_fuzz(sk_sp bytes) { - const int BitmapSize = 24; SkBitmap bitmap; bitmap.allocN32Pixels(BitmapSize, BitmapSize); SkCanvas canvas(bitmap); canvas.clear(0x00000000); - sk_sp flattenable = SkValidatingDeserializeImageFilter( - bytes->data(), bytes->size()); + auto flattenable = SkImageFilter::Deserialize(bytes->data(), bytes->size()); // Adding some info, but the test passed if we got here without any trouble if (flattenable != nullptr) { -- cgit v1.2.3