• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.h"
9 #include "SkPolyUtils.h"
10 
ignoreResult(bool)11 void inline ignoreResult(bool ) {}
12 
DEF_FUZZ(PolyUtils,fuzz)13 DEF_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));
29 
30     SkScalar offset;
31     fuzz->next(&offset);
32     ignoreResult(SkOffsetSimplePolygon(polygon, count, offset, &output));
33 
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 }
41