From 55888e44171ffd48b591d19256884a969fe4da17 Mon Sep 17 00:00:00 2001 From: caryclark Date: Mon, 18 Jul 2016 10:01:36 -0700 Subject: pathops coincidence and security rewrite Most changes stem from working on an examples bracketed by #if DEBUG_UNDER_DEVELOPMENT // tiger These exposed many problems with coincident curves, as well as errors throughout the code. Fixing these errors also fixed a number of fuzzer-inspired bug reports. * Line/Curve Intersections Check to see if the end of the line nearly intersects the curve. This was a FIXME in the old code. * Performance Use a central chunk allocator. Plumb the allocator into the global variable state so that it can be shared. (Note that 'SkGlobalState' is allocated on the stack and is visible to children functions but not other threads.) * Refactor Let SkOpAngle grow up from a structure to a class. Let SkCoincidentSpans grow up from a structure to a class. Rename enum Alias to AliasMatch. * Coincidence Rewrite Add more debugging to coincidence detection. Parallel debugging routines have read-only logic to report the current coincidence state so that steps through the logic can expose whether things got better or worse. More functions can error-out and cause the pathops engine to non-destructively exit. * Accuracy Remove code that adjusted point locations. Instead, offset the curve part so that sorted curves all use the same origin. Reduce the size (and influence) of magic numbers. * Testing The debug suite with verify and the full release suite ./out/Debug/pathops_unittest -v -V ./out/Release/pathops_unittest -v -V -x expose one error. That error is captured as cubics_d3. This error exists in the checked in code as well. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2128633003 BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2128633003 Review-Url: https://codereview.chromium.org/2128633003 --- tests/PathOpsAngleIdeas.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'tests/PathOpsAngleIdeas.cpp') diff --git a/tests/PathOpsAngleIdeas.cpp b/tests/PathOpsAngleIdeas.cpp index 2e3c7b9066..9d1b5994b2 100755 --- a/tests/PathOpsAngleIdeas.cpp +++ b/tests/PathOpsAngleIdeas.cpp @@ -406,12 +406,11 @@ static bool bruteForceCheck(skiatest::Reporter* reporter, const SkDQuad& quad1, return ccw == upperRange.ccw; } -static void makeSegment(SkOpContour* contour, const SkDQuad& quad, SkPoint shortQuad[3], - SkChunkAlloc* allocator) { +static void makeSegment(SkOpContour* contour, const SkDQuad& quad, SkPoint shortQuad[3]) { shortQuad[0] = quad[0].asSkPoint(); shortQuad[1] = quad[1].asSkPoint(); shortQuad[2] = quad[2].asSkPoint(); - contour->addQuad(shortQuad, allocator); + contour->addQuad(shortQuad); } static void testQuadAngles(skiatest::Reporter* reporter, const SkDQuad& quad1, const SkDQuad& quad2, @@ -419,14 +418,14 @@ static void testQuadAngles(skiatest::Reporter* reporter, const SkDQuad& quad1, c SkPoint shortQuads[2][3]; SkOpContourHead contour; - SkOpGlobalState state(nullptr, &contour SkDEBUGPARAMS(false) SkDEBUGPARAMS(nullptr)); + SkOpGlobalState state(&contour, allocator SkDEBUGPARAMS(false) SkDEBUGPARAMS(nullptr)); contour.init(&state, false, false); - makeSegment(&contour, quad1, shortQuads[0], allocator); - makeSegment(&contour, quad1, shortQuads[1], allocator); + makeSegment(&contour, quad1, shortQuads[0]); + makeSegment(&contour, quad1, shortQuads[1]); SkOpSegment* seg1 = contour.first(); - seg1->debugAddAngle(0, 1, allocator); + seg1->debugAddAngle(0, 1); SkOpSegment* seg2 = seg1->next(); - seg2->debugAddAngle(0, 1, allocator); + seg2->debugAddAngle(0, 1); int realOverlap = PathOpsAngleTester::ConvexHullOverlaps(*seg1->debugLastAngle(), *seg2->debugLastAngle()); const SkDPoint& origin = quad1[0]; -- cgit v1.2.3