Coverage Report

Created: 2024-05-20 07:14

/src/skia/fuzz/FuzzPathMeasure.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/SkPathMeasure.h"
11
12
7.11k
void inline ignoreResult(bool ) {}
13
14
913
DEF_FUZZ(PathMeasure, fuzz) {
15
913
    uint8_t bits;
16
913
    fuzz->next(&bits);
17
913
    SkScalar distance[6];
18
6.39k
    for (auto index = 0; index < 6; ++index) {
19
5.47k
        fuzz->next(&distance[index]);
20
5.47k
    }
21
913
    SkPath path;
22
913
    FuzzEvilPath(fuzz, &path, SkPath::Verb::kDone_Verb);
23
913
    SkRect bounds = path.getBounds();
24
913
    SkScalar maxDim = std::max(bounds.width(), bounds.height());
25
913
    if (maxDim > 1000000) {
26
137
        return;
27
137
    }
28
776
    SkScalar resScale = maxDim / 1000;
29
776
    SkPathMeasure measure(path, bits & 1, resScale);
30
776
    SkPoint position;
31
776
    SkVector tangent;
32
776
    ignoreResult(measure.getPosTan(distance[0], &position, &tangent));
33
776
    SkPath dst;
34
776
    ignoreResult(measure.getSegment(distance[1], distance[2], &dst, (bits >> 1) & 1));
35
776
    ignoreResult(measure.nextContour());
36
776
    ignoreResult(measure.getPosTan(distance[3], &position, &tangent));
37
776
    ignoreResult(measure.getSegment(distance[4], distance[5], &dst, (bits >> 2) & 1));
38
776
}