Check sanitized data when fuzzing PolyUtils.
PolyUtils is only ever used when generating shadows, and the data there is pre-clamped to 1/16th values, so we should be fuzzing on that. Bug: oss-fuzz:39746 Change-Id: I609059ab14cd83f0dab2d40cb17e3cb7979cff8a Reviewed-on: https://skia-review.googlesource.com/c/skia/+/493039 Reviewed-by: Michael Ludwig <michaelludwig@google.com> Commit-Queue: Jim Van Verth <jvanverth@google.com>
This commit is contained in:
parent
8b2513a986
commit
2e6181cac4
@ -12,12 +12,21 @@
|
||||
|
||||
void inline ignoreResult(bool ) {}
|
||||
|
||||
// clamps the point to the nearest 16th of a pixel
|
||||
static SkPoint sanitize_point(const SkPoint& in) {
|
||||
SkPoint out;
|
||||
out.fX = SkScalarRoundToScalar(16.f*in.fX)*0.0625f;
|
||||
out.fY = SkScalarRoundToScalar(16.f*in.fY)*0.0625f;
|
||||
return out;
|
||||
}
|
||||
|
||||
DEF_FUZZ(PolyUtils, fuzz) {
|
||||
int count;
|
||||
fuzz->nextRange(&count, 0, 512);
|
||||
SkAutoSTMalloc<64, SkPoint> polygon(count);
|
||||
for (int index = 0; index < count; ++index) {
|
||||
fuzz->next(&polygon[index].fX, &polygon[index].fY);
|
||||
polygon[index] = sanitize_point(polygon[index]);
|
||||
}
|
||||
SkRect bounds;
|
||||
bounds.setBoundsCheck(polygon, count);
|
||||
|
@ -17,6 +17,7 @@ struct SkRect;
|
||||
|
||||
/**
|
||||
* Generates a polygon that is inset a constant from the boundary of a given convex polygon.
|
||||
* The input polygon is expected to have values clamped to the nearest 1/16th.
|
||||
*
|
||||
* @param inputPolygonVerts Array of points representing the vertices of the original polygon.
|
||||
* It should be convex and have no coincident points.
|
||||
@ -31,7 +32,8 @@ bool SkInsetConvexPolygon(const SkPoint* inputPolygonVerts, int inputPolygonSize
|
||||
/**
|
||||
* Generates a simple polygon (if possible) that is offset a constant distance from the boundary
|
||||
* of a given simple polygon.
|
||||
* The input polygon must be simple and have no coincident vertices or collinear edges.
|
||||
* The input polygon must be simple, have no coincident vertices or collinear edges, and have
|
||||
* values clamped to the nearest 1/16th.
|
||||
*
|
||||
* @param inputPolygonVerts Array of points representing the vertices of the original polygon.
|
||||
* @param inputPolygonSize Number of vertices in the original polygon.
|
||||
@ -85,6 +87,7 @@ bool SkIsConvexPolygon(const SkPoint* polygonVerts, int polygonSize);
|
||||
/**
|
||||
* Determine whether a polygon is simple (i.e., not self-intersecting) or not.
|
||||
* The input polygon must have no coincident vertices or the test will fail.
|
||||
* The polygon is also expected to have values clamped to the nearest 1/16th.
|
||||
*
|
||||
* @param polygonVerts Array of points representing the vertices of the polygon.
|
||||
* @param polygonSize Number of vertices in the polygon.
|
||||
|
Loading…
Reference in New Issue
Block a user