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