blob: fa61d49bd98185861170028b4296f667cc3e7ffa [file] [log] [blame]
Kevin Lubick2541edf2018-01-11 10:27:14 -05001/*
2 * Copyright 2018 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "../Fuzz.h"
9#include "../FuzzCommon.h"
10#include "SkData.h"
11#include "SkPath.h"
12#include "SkRegion.h"
13
14
15void FuzzRegionSetPath(Fuzz* fuzz) {
16 SkPath p;
Mike Klein7ffa40c2018-09-25 12:16:53 -040017 FuzzNicePath(fuzz, &p, 1000);
Kevin Lubick2541edf2018-01-11 10:27:14 -050018 SkRegion r1;
19 bool initR1;
20 fuzz->next(&initR1);
21 if (initR1) {
22 fuzz->next(&r1);
23 }
24 SkRegion r2;
25 fuzz->next(&r2);
26
27 r1.setPath(p, r2);
28
29 // Do some follow on computations to make sure region is well-formed.
30 r1.computeRegionComplexity();
31 r1.isComplex();
32 if (r1 == r2) {
33 r1.contains(0,0);
34 } else {
35 r1.contains(1,1);
36 }
37}
38
39#if defined(IS_FUZZING_WITH_LIBFUZZER)
40extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
41 sk_sp<SkData> bytes(SkData::MakeWithoutCopy(data, size));
42 Fuzz fuzz(bytes);
43 FuzzRegionSetPath(&fuzz);
44 return 0;
45}
46#endif