Some assert fixes for running the Fuzzer sample in GPU mode.

quadraticPointCount, cubicPointCount: passing NaN to GrNextPow2 causes
it to assert, so detect that and return the max points per curve
instead.

Passing a zero scale to GrStyle::applyToPath() makes it assert, so
draw nothing (likely what drawing with a zero scale is going to do
anyway).

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2257423002

Review-Url: https://codereview.chromium.org/2257423002
This commit is contained in:
senorblanco 2016-08-19 08:07:22 -07:00 committed by Commit bot
parent e9fd0f8eaf
commit b6a40b83f3
2 changed files with 8 additions and 4 deletions

View File

@ -156,8 +156,8 @@ static void draw_path_with_mask_filter(GrContext* context,
// We just fully apply the style here.
if (style.applies()) {
if (!style.applyToPath(tmpPath.init(), &fillOrHairline, *path,
GrStyle::MatrixToScaleFactor(viewMatrix))) {
SkScalar scale = GrStyle::MatrixToScaleFactor(viewMatrix);
if (0 == scale || !style.applyToPath(tmpPath.init(), &fillOrHairline, *path, scale)) {
return;
}
pathIsMutable = true;

View File

@ -44,7 +44,9 @@ uint32_t GrPathUtils::quadraticPointCount(const SkPoint points[],
SkASSERT(tol > 0);
SkScalar d = points[1].distanceToLineSegmentBetween(points[0], points[2]);
if (d <= tol) {
if (!SkScalarIsFinite(d)) {
return MAX_POINTS_PER_CURVE;
} else if (d <= tol) {
return 1;
} else {
// Each time we subdivide, d should be cut in 4. So we need to
@ -104,7 +106,9 @@ uint32_t GrPathUtils::cubicPointCount(const SkPoint points[],
points[1].distanceToLineSegmentBetweenSqd(points[0], points[3]),
points[2].distanceToLineSegmentBetweenSqd(points[0], points[3]));
d = SkScalarSqrt(d);
if (d <= tol) {
if (!SkScalarIsFinite(d)) {
return MAX_POINTS_PER_CURVE;
} else if (d <= tol) {
return 1;
} else {
SkScalar divSqrt = SkScalarSqrt(d / tol);