Coverage Report

Created: 2024-09-14 07:19

/src/skia/fuzz/oss_fuzz/FuzzRegionSetPath.cpp
Line
Count
Source
1
/*
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/Fuzz.h"
9
#include "fuzz/FuzzCommon.h"
10
#include "include/core/SkPath.h"
11
#include "include/core/SkRegion.h"
12
13
14
6.76k
void FuzzRegionSetPath(Fuzz* fuzz) {
15
6.76k
    SkPath p;
16
6.76k
    FuzzNicePath(fuzz, &p, 1000);
17
6.76k
    SkRegion r1;
18
6.76k
    bool initR1;
19
6.76k
    fuzz->next(&initR1);
20
6.76k
    if (initR1) {
21
521
        fuzz->next(&r1);
22
521
    }
23
6.76k
    SkRegion r2;
24
6.76k
    fuzz->next(&r2);
25
26
6.76k
    r1.setPath(p, r2);
27
28
    // Do some follow on computations to make sure region is well-formed.
29
6.76k
    r1.computeRegionComplexity();
30
6.76k
    r1.isComplex();
31
6.76k
    if (r1 == r2) {
32
5.19k
        r1.contains(0,0);
33
5.19k
    } else {
34
1.57k
        r1.contains(1,1);
35
1.57k
    }
36
6.76k
}
37
38
#if defined(SK_BUILD_FOR_LIBFUZZER)
39
162k
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
40
162k
    if (size > 512) {
41
207
        return 0;
42
207
    }
43
162k
    Fuzz fuzz(data, size);
44
162k
    FuzzRegionSetPath(&fuzz);
45
162k
    return 0;
46
162k
}
47
#endif