fix pathops quad line intersection

git-svn-id: http://skia.googlecode.com/svn/trunk@12374 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
caryclark@google.com 2013-11-25 13:39:12 +00:00
parent 27346f52cb
commit 28d219c568
2 changed files with 17 additions and 8 deletions

View File

@ -304,15 +304,10 @@ protected:
SkDPoint xy = fQuad.ptAtT(t);
double dx = fLine[1].fX - fLine[0].fX;
double dy = fLine[1].fY - fLine[0].fY;
double dxT = (xy.fX - fLine[0].fX) / dx;
double dyT = (xy.fY - fLine[0].fY) / dy;
if (!between(FLT_EPSILON, dxT, 1 - FLT_EPSILON) && between(0, dyT, 1)) {
return dyT;
if (fabs(dx) > fabs(dy)) {
return (xy.fX - fLine[0].fX) / dx;
}
if (!between(FLT_EPSILON, dyT, 1 - FLT_EPSILON) && between(0, dxT, 1)) {
return dxT;
}
return fabs(dx) > fabs(dy) ? dxT : dyT;
return (xy.fY - fLine[0].fY) / dy;
}
bool pinTs(double* quadT, double* lineT, SkDPoint* pt, PinTPoint ptSet) {

View File

@ -3946,9 +3946,23 @@ static void testQuad10(skiatest::Reporter* reporter) {
testSimplify(reporter, path);
}
static void testQuad11(skiatest::Reporter* reporter) {
SkPath path;
path.moveTo(2, 0);
path.quadTo(0, 1, 1, 2);
path.lineTo(1, 2);
path.close();
path.moveTo(0, 0);
path.lineTo(1, 1);
path.quadTo(1, 3, 3, 3);
path.close();
testSimplify(reporter, path);
}
static void (*firstTest)(skiatest::Reporter* ) = 0;
static TestDesc tests[] = {
TEST(testQuad11),
TEST(testQuad10),
TEST(testQuad9),
TEST(testTriangles4x),