C = ( (a ) - g'*(d ) - h' )
*/
-
class LineQuadraticIntersections {
public:
enum PinTPoint {
, fLine(l)
, fIntersections(i)
, fAllowNear(true) {
- i->setMax(2);
+ i->setMax(3); // allow short partial coincidence plus discrete intersection
}
void allowNear(bool allow) {
}
bool pinTs(double* quadT, double* lineT, SkDPoint* pt, PinTPoint ptSet) {
- if (!approximately_one_or_less(*lineT)) {
+ if (!approximately_one_or_less_double(*lineT)) {
return false;
}
- if (!approximately_zero_or_more(*lineT)) {
+ if (!approximately_zero_or_more_double(*lineT)) {
return false;
}
double qT = *quadT = SkPinT(*quadT);
}
SkPoint gridPt = pt->asSkPoint();
if (gridPt == fLine[0].asSkPoint()) {
+ *pt = fLine[0];
*lineT = 0;
} else if (gridPt == fLine[1].asSkPoint()) {
+ *pt = fLine[1];
*lineT = 1;
}
+ if (fIntersections->used() > 0 && approximately_equal((*fIntersections)[1][0], *lineT)) {
+ return false;
+ }
if (gridPt == fQuad[0].asSkPoint()) {
+ *pt = fQuad[0];
*quadT = 0;
} else if (gridPt == fQuad[2].asSkPoint()) {
+ *pt = fQuad[2];
*quadT = 1;
}
return true;
bool fAllowNear;
};
-// utility for pairs of coincident quads
-static double horizontalIntersect(const SkDQuad& quad, const SkDPoint& pt) {
- LineQuadraticIntersections q(quad, *(static_cast<SkDLine*>(0)),
- static_cast<SkIntersections*>(0));
- double rootVals[2];
- int roots = q.horizontalIntersect(pt.fY, rootVals);
- for (int index = 0; index < roots; ++index) {
- double t = rootVals[index];
- SkDPoint qPt = quad.ptAtT(t);
- if (AlmostEqualUlps(qPt.fX, pt.fX)) {
- return t;
- }
- }
- return -1;
-}
-
-static double verticalIntersect(const SkDQuad& quad, const SkDPoint& pt) {
- LineQuadraticIntersections q(quad, *(static_cast<SkDLine*>(0)),
- static_cast<SkIntersections*>(0));
- double rootVals[2];
- int roots = q.verticalIntersect(pt.fX, rootVals);
- for (int index = 0; index < roots; ++index) {
- double t = rootVals[index];
- SkDPoint qPt = quad.ptAtT(t);
- if (AlmostEqualUlps(qPt.fY, pt.fY)) {
- return t;
- }
- }
- return -1;
-}
-
-double SkIntersections::Axial(const SkDQuad& q1, const SkDPoint& p, bool vertical) {
- if (vertical) {
- return verticalIntersect(q1, p);
- }
- return horizontalIntersect(q1, p);
-}
-
int SkIntersections::horizontal(const SkDQuad& quad, double left, double right, double y,
bool flipped) {
SkDLine line = {{{ left, y }, { right, y }}};