bool lineClipCohStuth(Point winMin, Point winMax, Point &p1, Point &p2) { unsigned char code1, code2; int done = false, plotLine = false; float m; while (!done) { code1 = encode(p1, winMin, winMax); code2 = encode(p2, winMin, winMax); if (accept(code1, code2)) { done = true; plotLine = true; } else if (reject(code1, code2)) done = true; else { if (inside(code1)) { swapPts(&p1, &p2); swapCodes(&code1, &code2); } if (p2.x != p1.x) m = (p2.y - p1.y) / (p2.x - p1.x); if (code1 & winLeftBitCode) { p1.y += (winMin.x - p1.x) * m; p1.x = winMin.x; } else if (code1 & winRightBitCode) { p1.y += (winMax.x - p1.x) * m; p1.x = winMax.x; } else if (code1 & winBottomBitCode) { if(p2.x != p1.x) p1.x += (winMin.y - p1.y) * m; p1.y = winMin.y; } else if (code1 & winTopBitCode) { if (p2.x != p1.x) p1.x += (winMax.y - p1.y) * m; p1.y = winMax.y; } } } return plotLine; }
int SkIntersections::intersect(const SkDCubic& c) { // check to see if x or y end points are the extrema. Are other quick rejects possible? if (c.endsAreExtremaInXOrY()) { return false; } (void) intersect(c, c); if (used() > 0) { SkASSERT(used() == 1); if (fT[0][0] > fT[1][0]) { swapPts(); } } return used(); }