this addresses a few FIXME issues
- speed up implicit quad computation
- use ulps instead of epsilon
- assert on bad line results more often
git-svn-id: http://skia.googlecode.com/svn/trunk@8823
2bbb7eff-a529-9590-31e7-
b0007b416f81
axLen * (ay - ax * ayLen / axLen) == axLen * (by - bx * ayLen / axLen)
axLen * ay - ax * ayLen == axLen * by - bx * ayLen
*/
- // FIXME: need to use AlmostEqualUlps variant instead
- if (!approximately_equal_squared(axLen * a[0].fY - ayLen * a[0].fX,
+ if (!AlmostEqualUlps(axLen * a[0].fY - ayLen * a[0].fX,
axLen * b[0].fY - ayLen * b[0].fX)) {
return fUsed = 0;
}
int SkIntersections::horizontal(const SkDLine& line, double left, double right, double y) {
int result = horizontal(line, y);
if (result != 1) {
- SkASSERT(result == 0); // FIXME: this is incorrect if result == 2
+ SkASSERT(0);
return result;
}
double xIntercept = line[0].fX + fT[0][0] * (line[1].fX - line[0].fX);
bool second = fabs(fT[0][0] - fT[0][1]) > FLT_EPSILON;
SkASSERT((fabs(fT[1][0] - fT[1][1]) <= FLT_EPSILON) ^ second);
return computePoints(line, 1 + second);
- break;
}
if (flipped) {
// OPTIMIZATION: instead of swapping, pass original line, use [1].fY - [0].fY
*
*/
-// OPTIMIZATION: test, verify tricky arithmetic
-static bool straight_forward = true;
+// use the tricky arithmetic path, but leave the original to compare just in case
+static bool straight_forward = false;
SkDQuadImplicit::SkDQuadImplicit(const SkDQuad& q) {
double a, b, c;
/* Given a pair of quadratics, determine their parametric coefficients.
* If the scaled coefficients are nearly equal, then the part of the quadratics
* may be coincident.
- * FIXME: optimization -- since comparison short-circuits on no match,
+ * OPTIMIZATION -- since comparison short-circuits on no match,
* lazily compute the coefficients, comparing the easiest to compute first.
* xx and yy first; then xy; and so on.
*/
kEvenOdd_PathOpsMask = 1
};
+// Use Almost Equal when comparing coordinates. Use epsilon to compare T values.
extern bool AlmostEqualUlps(float A, float B);
inline bool AlmostEqualUlps(double A, double B) {
return AlmostEqualUlps(SkDoubleToScalar(A), SkDoubleToScalar(B));