aboutsummaryrefslogtreecommitdiffhomepage
path: root/fuzz
diff options
context:
space:
mode:
authorGravatar Kevin Lubick <kjlubick@google.com>2017-02-20 17:47:18 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-02-20 23:18:58 +0000
commitedee1ae9e3b87983ed0ff0ea55b3c49892901260 (patch)
tree8eb808eecc90c8b432fa4673861e391aaab9df7c /fuzz
parent8e1c4e672553ecae2745168514240705f3516773 (diff)
Write SkRegion fuzzer
BUG=688987 Change-Id: I2ad1c53ea01185a77b662d2d86b0c6d36fcb63c7 Reviewed-on: https://skia-review.googlesource.com/8499 Commit-Queue: Kevin Lubick <kjlubick@google.com> Reviewed-by: Hal Canary <halcanary@google.com>
Diffstat (limited to 'fuzz')
-rw-r--r--fuzz/fuzz.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/fuzz/fuzz.cpp b/fuzz/fuzz.cpp
index 67207543e7..cc26b2daca 100644
--- a/fuzz/fuzz.cpp
+++ b/fuzz/fuzz.cpp
@@ -14,6 +14,8 @@
#include "SkImageEncoder.h"
#include "SkMallocPixelRef.h"
#include "SkPath.h"
+#include "SkRegion.h"
+#include "SkSurface.h"
#include "SkOSFile.h"
#include "SkOSPath.h"
#include "SkPicture.h"
@@ -44,6 +46,7 @@ static void fuzz_color_deserialize(sk_sp<SkData>);
static void fuzz_icc(sk_sp<SkData>);
static void fuzz_img(sk_sp<SkData>, uint8_t, uint8_t);
static void fuzz_path_deserialize(sk_sp<SkData>);
+static void fuzz_region_deserialize(sk_sp<SkData>);
static void fuzz_skp(sk_sp<SkData>);
#if SK_SUPPORT_GPU
static void fuzz_sksl2glsl(sk_sp<SkData>);
@@ -104,6 +107,10 @@ static int fuzz_file(const char* path) {
fuzz_path_deserialize(bytes);
return 0;
}
+ if (0 == strcmp("region_deserialize", FLAGS_type[0])) {
+ fuzz_region_deserialize(bytes);
+ return 0;
+ }
if (0 == strcmp("skp", FLAGS_type[0])) {
fuzz_skp(bytes);
return 0;
@@ -476,6 +483,26 @@ static void fuzz_path_deserialize(sk_sp<SkData> bytes) {
SkDebugf("[terminated] Success! Initialized SkPath.\n");
}
+static void fuzz_region_deserialize(sk_sp<SkData> bytes) {
+ SkRegion region;
+ if (!region.readFromMemory(bytes->data(), bytes->size())) {
+ SkDebugf("[terminated] Couldn't initialize SkRegion.\n");
+ return;
+ }
+ region.computeRegionComplexity();
+ region.isComplex();
+ SkRegion r2;
+ if (region == r2) {
+ region.contains(0,0);
+ } else {
+ region.contains(1,1);
+ }
+ auto s = SkSurface::MakeRasterN32Premul(1024, 1024);
+ s->getCanvas()->drawRegion(region, SkPaint());
+ SkDEBUGCODE(region.validate());
+ SkDebugf("[terminated] Success! Initialized SkRegion.\n");
+}
+
#if SK_SUPPORT_GPU
static void fuzz_sksl2glsl(sk_sp<SkData> bytes) {
SkSL::Compiler compiler;