Coverage Report

Created: 2024-09-14 07:19

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