blob: 62e7b7434c3ccab5c06872a94ff1834e61fbf282 [file] [log] [blame]
Cary Clark91390c82018-03-09 14:02:46 -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 "SkPathMeasure.h"
11
12void inline ignoreResult(bool ) {}
13
14DEF_FUZZ(PathMeasure, fuzz) {
15 uint8_t bits;
16 fuzz->next(&bits);
17 SkScalar distance[6];
18 for (auto index = 0; index < 6; ++index) {
19 fuzz->next(&distance[index]);
20 }
21 SkPath path;
Mike Klein7ffa40c2018-09-25 12:16:53 -040022 FuzzEvilPath(fuzz, &path, SkPath::Verb::kDone_Verb);
Cary Clark91390c82018-03-09 14:02:46 -050023 SkRect bounds = path.getBounds();
24 SkScalar maxDim = SkTMax(bounds.width(), bounds.height());
25 SkScalar resScale = maxDim / 1000;
26 SkPathMeasure measure(path, bits & 1, resScale);
27 SkPoint position;
28 SkVector tangent;
29 ignoreResult(measure.getPosTan(distance[0], &position, &tangent));
30 SkPath dst;
31 ignoreResult(measure.getSegment(distance[1], distance[2], &dst, (bits >> 1) & 1));
32 ignoreResult(measure.nextContour());
33 ignoreResult(measure.getPosTan(distance[3], &position, &tangent));
34 ignoreResult(measure.getSegment(distance[4], distance[5], &dst, (bits >> 2) & 1));
35}