Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
FuzzPolyUtils.cpp File Reference
#include "fuzz/Fuzz.h"
#include "include/core/SkPoint.h"
#include "include/private/base/SkTDArray.h"
#include "include/private/base/SkTemplates.h"
#include "src/utils/SkPolyUtils.h"

Go to the source code of this file.

Functions

void ignoreResult (bool)
 
static SkPoint sanitize_point (const SkPoint &in)
 
 DEF_FUZZ (PolyUtils, fuzz)
 

Function Documentation

◆ DEF_FUZZ()

DEF_FUZZ ( PolyUtils  ,
fuzz   
)

Definition at line 28 of file FuzzPolyUtils.cpp.

28 {
29 int count;
30 fuzz->nextRange(&count, 0, 512);
32 for (int index = 0; index < count; ++index) {
33 fuzz->next(&polygon[index].fX, &polygon[index].fY);
34 polygon[index] = sanitize_point(polygon[index]);
35 }
37 bounds.setBoundsCheck(polygon, count);
38
40 bool isConvex = SkIsConvexPolygon(polygon, count);
41 bool isSimple = SkIsSimplePolygon(polygon, count);
42
44 if (isConvex) {
46 fuzz->next(&inset);
47 ignoreResult(SkInsetConvexPolygon(polygon, count, inset, &output));
48 }
49
50 if (isSimple) {
52 // Limit this to prevent timeouts.
53 // This should be fine, as this is roughly the range we expect from the shadow algorithm.
54 fuzz->nextRange(&offset, -1000, 1000);
55 ignoreResult(SkOffsetSimplePolygon(polygon, count, bounds, offset, &output));
56
58 for (int index = 0; index < count; ++index) {
59 fuzz->next(&indexMap[index]);
60 }
61 SkTDArray<uint16_t> outputIndices;
62 ignoreResult(SkTriangulateSimplePolygon(polygon, indexMap, count, &outputIndices));
63 }
64}
int count
static SkPoint sanitize_point(const SkPoint &in)
void ignoreResult(bool)
bool SkIsConvexPolygon(const SkPoint *polygonVerts, int polygonSize)
bool SkTriangulateSimplePolygon(const SkPoint *polygonVerts, uint16_t *indexMap, int polygonSize, SkTDArray< uint16_t > *triangleIndices)
bool SkOffsetSimplePolygon(const SkPoint *inputPolygonVerts, int inputPolygonSize, const SkRect &bounds, SkScalar offset, SkTDArray< SkPoint > *offsetPolygon, SkTDArray< int > *polygonIndices)
bool SkIsSimplePolygon(const SkPoint *polygon, int polygonSize)
int SkGetPolygonWinding(const SkPoint *polygonVerts, int polygonSize)
bool SkInsetConvexPolygon(const SkPoint *inputPolygonVerts, int inputPolygonSize, SkScalar inset, SkTDArray< SkPoint > *insetPolygon)
float SkScalar
Definition extension.cpp:12
Optional< SkRect > bounds
Definition SkRecords.h:189
static SkRect inset(const SkRect &r)
Point offset

◆ ignoreResult()

void ignoreResult ( bool  )
inline

Definition at line 18 of file FuzzPolyUtils.cpp.

18{}

◆ sanitize_point()

static SkPoint sanitize_point ( const SkPoint in)
static

Definition at line 21 of file FuzzPolyUtils.cpp.

21 {
23 out.fX = SkScalarRoundToScalar(16.f*in.fX)*0.0625f;
24 out.fY = SkScalarRoundToScalar(16.f*in.fY)*0.0625f;
25 return out;
26}
#define SkScalarRoundToScalar(x)
Definition SkScalar.h:32
float fX
x-axis value
float fY
y-axis value