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