Fix handling of nan when clamping number of pts in quads/cubics

Review URL: http://codereview.appspot.com/4646044/



git-svn-id: http://skia.googlecode.com/svn/trunk@1642 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
bsalomon@google.com 2011-06-17 20:06:49 +00:00
Родитель 026427654f
Коммит 61f3bde1ba
1 изменённых файлов: 16 добавлений и 2 удалений

Просмотреть файл

@ -32,7 +32,14 @@ uint32_t GrPathUtils::quadraticPointCount(const GrPoint points[],
// points.
// 2^(log4(x)) = sqrt(x);
int temp = SkScalarCeil(SkScalarSqrt(SkScalarDiv(d, tol)));
return GrMin(GrNextPow2(temp), MAX_POINTS_PER_CURVE);
int pow2 = GrNextPow2(temp);
// Because of NaNs & INFs we can wind up with a degenerate temp
// such that pow2 comes out negative. Also, our point generator
// will always output at least one pt.
if (pow2 < 1) {
pow2 = 1;
}
return GrMin(pow2, MAX_POINTS_PER_CURVE);
}
}
@ -70,7 +77,14 @@ uint32_t GrPathUtils::cubicPointCount(const GrPoint points[],
return 1;
} else {
int temp = SkScalarCeil(SkScalarSqrt(SkScalarDiv(d, tol)));
return GrMin(GrNextPow2(temp), MAX_POINTS_PER_CURVE);
int pow2 = GrNextPow2(temp);
// Because of NaNs & INFs we can wind up with a degenerate temp
// such that pow2 comes out negative. Also, our point generator
// will always output at least one pt.
if (pow2 < 1) {
pow2 = 1;
}
return GrMin(pow2, MAX_POINTS_PER_CURVE);
}
}