When solving the cubic line intersection directly fails, use binary search as a fallback.

The cubic line intersection math empirically works 99.99% of the time (fails 3100 out of 1B random tests) but when it fails, an intersection may be missed altogether.

The binary search is may not find a solution if the cubic line failed to find any solutions at all, but so far that case hasn't arisen.

BUG=skia:2504
TBR=reed@google.com

Author: caryclark@google.com

Review URL: https://codereview.chromium.org/266063003

git-svn-id: http://skia.googlecode.com/svn/trunk@14614 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/PathOpsOpTest.cpp b/tests/PathOpsOpTest.cpp
index 86baea4..75b6030 100644
--- a/tests/PathOpsOpTest.cpp
+++ b/tests/PathOpsOpTest.cpp
@@ -3329,10 +3329,30 @@
     testPathOp(reporter, path1, path2, kDifference_PathOp, filename);
 }
 
+static void issue2504(skiatest::Reporter* reporter, const char* filename) {
+    SkPath path1;
+    path1.moveTo(34.2421875, -5.976562976837158203125);
+    path1.lineTo(35.453121185302734375, 0);
+    path1.lineTo(31.9375, 0);
+    path1.close();
+
+    SkPath path2;
+    path2.moveTo(36.71843719482421875, 0.8886508941650390625);
+    path2.cubicTo(36.71843719482421875, 0.8886508941650390625,
+                  35.123386383056640625, 0.554015457630157470703125,
+                  34.511409759521484375, -0.1152553558349609375);
+    path2.cubicTo(33.899425506591796875, -0.7845261096954345703125,
+                  34.53484344482421875, -5.6777553558349609375,
+                  34.53484344482421875, -5.6777553558349609375);
+    path2.close();
+    testPathOp(reporter, path1, path2, kUnion_PathOp, filename);
+}
+
 static void (*firstTest)(skiatest::Reporter* , const char* filename) = 0;
 static void (*stopTest)(skiatest::Reporter* , const char* filename) = 0;
 
 static struct TestDesc tests[] = {
+    TEST(issue2504),
     TEST(kari1),
     TEST(quadOp10i),
 #if 0  // FIXME: serpentine curve is ordered the wrong way