/src/skia/fuzz/FuzzPolyUtils.cpp
Line | Count | Source |
1 | | /* |
2 | | * Copyright 2018 Google LLC |
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 | | |
10 | | #include "include/private/SkTemplates.h" |
11 | | #include "src/utils/SkPolyUtils.h" |
12 | | |
13 | 9.04k | void inline ignoreResult(bool ) {} |
14 | | |
15 | 975 | DEF_FUZZ(PolyUtils, fuzz) { |
16 | 975 | int count; |
17 | 975 | fuzz->nextRange(&count, 0, 512); |
18 | 975 | SkAutoSTMalloc<64, SkPoint> polygon(count); |
19 | 142k | for (int index = 0; index < count; ++index) { |
20 | 141k | fuzz->next(&polygon[index].fX, &polygon[index].fY); |
21 | 141k | } |
22 | 975 | SkRect bounds; |
23 | 975 | bounds.setBoundsCheck(polygon, count); |
24 | | |
25 | 975 | ignoreResult(SkGetPolygonWinding(polygon, count)); |
26 | 975 | ignoreResult(SkIsConvexPolygon(polygon, count)); |
27 | 975 | ignoreResult(SkIsSimplePolygon(polygon, count)); |
28 | | |
29 | 975 | SkScalar inset; |
30 | 975 | fuzz->next(&inset); |
31 | 975 | SkTDArray<SkPoint> output; |
32 | 975 | ignoreResult(SkInsetConvexPolygon(polygon, count, inset, &output)); |
33 | | |
34 | 975 | SkScalar offset; |
35 | 975 | fuzz->next(&offset); |
36 | 975 | ignoreResult(SkOffsetSimplePolygon(polygon, count, bounds, offset, &output)); |
37 | | |
38 | 975 | SkAutoSTMalloc<64, uint16_t> indexMap(count); |
39 | 142k | for (int index = 0; index < count; ++index) { |
40 | 141k | fuzz->next(&indexMap[index]); |
41 | 141k | } |
42 | 975 | SkTDArray<uint16_t> outputIndices; |
43 | 975 | ignoreResult(SkTriangulateSimplePolygon(polygon, indexMap, count, &outputIndices)); |
44 | 975 | } |