aboutsummaryrefslogtreecommitdiffhomepage
path: root/fuzz/oss_fuzz/FuzzRegionSetPath.cpp
blob: ee6e74759f00dd26dcd1d636f832c2a8d1ab8684 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
 * Copyright 2018 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "../Fuzz.h"
#include "../FuzzCommon.h"
#include "SkData.h"
#include "SkPath.h"
#include "SkRegion.h"


void FuzzRegionSetPath(Fuzz* fuzz) {
    SkPath p;
    FuzzPath(fuzz, &p, 1000);
    SkRegion r1;
    bool initR1;
    fuzz->next(&initR1);
    if (initR1) {
        fuzz->next(&r1);
    }
    SkRegion r2;
    fuzz->next(&r2);

    r1.setPath(p, r2);

    // Do some follow on computations to make sure region is well-formed.
    r1.computeRegionComplexity();
    r1.isComplex();
    if (r1 == r2) {
        r1.contains(0,0);
    } else {
        r1.contains(1,1);
    }
}

#if defined(IS_FUZZING_WITH_LIBFUZZER)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
    sk_sp<SkData> bytes(SkData::MakeWithoutCopy(data, size));
    Fuzz fuzz(bytes);
    FuzzRegionSetPath(&fuzz);
    return 0;
}
#endif