blob: 8082668ae996786e2d0ab2e3a3c44557d3c46218 [file] [log] [blame]
Jim Van Verth061cc212018-07-11 14:09:09 -04001/*
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.h"
9#include "FuzzCommon.h"
10#include "SkPolyUtils.h"
11
12void inline ignoreResult(bool ) {}
13
14DEF_FUZZ(PolyUtils, fuzz) {
15 int count;
16 fuzz->nextRange(&count, 0, 512);
17 SkAutoSTMalloc<64, SkPoint> polygon(count);
18 for (int index = 0; index < count; ++index) {
19 fuzz->next(&polygon[index].fX, &polygon[index].fY);
20 }
21
22 ignoreResult(SkGetPolygonWinding(polygon, count));
23 ignoreResult(SkIsConvexPolygon(polygon, count));
24 ignoreResult(SkIsSimplePolygon(polygon, count));
25
26 SkScalar inset;
27 fuzz->next(&inset);
28 SkTDArray<SkPoint> output;
29 ignoreResult(SkInsetConvexPolygon(polygon, count, inset, &output));
Jim Van Verth061cc212018-07-11 14:09:09 -040030
31 SkScalar offset;
32 fuzz->next(&offset);
33 ignoreResult(SkOffsetSimplePolygon(polygon, count, offset, &output));
Jim Van Verth061cc212018-07-11 14:09:09 -040034
35 SkAutoSTMalloc<64, uint16_t> indexMap(count);
36 for (int index = 0; index < count; ++index) {
37 fuzz->next(&indexMap[index]);
38 }
39 SkTDArray<uint16_t> outputIndices;
40 ignoreResult(SkTriangulateSimplePolygon(polygon, indexMap, count, &outputIndices));
41}