From ebf95ba28db75212a1313edc947ed68decc30273 Mon Sep 17 00:00:00 2001 From: "caryclark@google.com" Date: Mon, 8 Apr 2013 11:53:42 +0000 Subject: keep old experimental code in sync git-svn-id: http://skia.googlecode.com/svn/trunk@8554 2bbb7eff-a529-9590-31e7-b0007b416f81 --- experimental/Intersection/CubicIntersection.cpp | 2 +- .../Intersection/CubicIntersection_Test.cpp | 14 ++- experimental/Intersection/DataTypes.h | 4 +- experimental/Intersection/Intersection_Tests.cpp | 6 +- experimental/Intersection/SimplifyNew_Test.cpp | 74 +++++++++++- experimental/Intersection/as.htm | 128 ++++++++++++++++++++- experimental/Intersection/op.htm | 7 ++ experimental/Intersection/qc.htm | 78 +++++++++++++ 8 files changed, 294 insertions(+), 19 deletions(-) (limited to 'experimental') diff --git a/experimental/Intersection/CubicIntersection.cpp b/experimental/Intersection/CubicIntersection.cpp index a773c4098e..175b7b7c46 100644 --- a/experimental/Intersection/CubicIntersection.cpp +++ b/experimental/Intersection/CubicIntersection.cpp @@ -20,7 +20,7 @@ #endif #if ONE_OFF_DEBUG -static const double tLimits1[2][2] = {{0.865205808, 0.865215212}, {0.865207696, 0.865208078}}; +static const double tLimits1[2][2] = {{0.36, 0.37}, {0.63, 0.64}}; static const double tLimits2[2][2] = {{-0.865211397, -0.865215212}, {-0.865207696, -0.865208078}}; #endif diff --git a/experimental/Intersection/CubicIntersection_Test.cpp b/experimental/Intersection/CubicIntersection_Test.cpp index 9662eb8379..ffaa933175 100644 --- a/experimental/Intersection/CubicIntersection_Test.cpp +++ b/experimental/Intersection/CubicIntersection_Test.cpp @@ -62,6 +62,12 @@ static void standardTestCases() { } static const Cubic testSet[] = { +{{67.426548091427676, 37.993772624988935}, {23.483695892376684, 90.476863174921306}, {35.597065061143162, 79.872482633158796}, {75.38634169631932, 18.244890038969412}}, +{{67.4265481, 37.9937726}, {23.4836959, 90.4768632}, {35.5970651, 79.8724826}, {75.3863417, 18.24489}}, + +{{0, 0}, {0, 1}, {1, 1}, {1, 0}}, +{{1, 0}, {0, 0}, {0, 1}, {1, 1}}, + {{0,1}, {4,5}, {1,0}, {5,3}}, {{0,1}, {3,5}, {1,0}, {5,4}}, @@ -90,9 +96,6 @@ static const Cubic testSet[] = { {{0,2}, {0,1}, {1,0}, {1,0}}, {{0,1}, {0,1}, {2,0}, {1,0}}, -{{0, 0}, {0, 1}, {1, 1}, {1, 0}}, -{{1, 0}, {0, 0}, {0, 1}, {1, 1}}, - {{0, 1}, {0, 2}, {1, 0}, {1, 0}}, {{0, 1}, {0, 1}, {1, 0}, {2, 0}}, @@ -375,7 +378,7 @@ static void oneOff(int outer, int inner) { } void CubicIntersection_OneOffTest() { - oneOff(12, 14); + oneOff(0, 1); } static void newOneOff(int outer, int inner) { @@ -732,7 +735,8 @@ void CubicIntersection_SelfTest() { {{12.81,7.27}, {7.22,6.98}, {12.49,8.97}, {11.42,6.18}}, }; size_t selfSetCount = sizeof(selfSet) / sizeof(selfSet[0]); - for (size_t index = 0; index < selfSetCount; ++index) { + size_t firstFail = 1; + for (size_t index = firstFail; index < selfSetCount; ++index) { const Cubic& cubic = selfSet[index]; #if ONE_OFF_DEBUG int idx2; diff --git a/experimental/Intersection/DataTypes.h b/experimental/Intersection/DataTypes.h index 7d749afc13..20dbef8751 100644 --- a/experimental/Intersection/DataTypes.h +++ b/experimental/Intersection/DataTypes.h @@ -12,8 +12,8 @@ #include "SkPoint.h" -#define FORCE_RELEASE 1 // set force release to 1 for multiple thread -- no debugging -#define ONE_OFF_DEBUG 0 +#define FORCE_RELEASE 0 // set force release to 1 for multiple thread -- no debugging +#define ONE_OFF_DEBUG 1 #define ONE_OFF_DEBUG_MATHEMATICA 0 // FIXME: move these into SkTypes.h diff --git a/experimental/Intersection/Intersection_Tests.cpp b/experimental/Intersection/Intersection_Tests.cpp index 2bff918d70..0754ecc27f 100644 --- a/experimental/Intersection/Intersection_Tests.cpp +++ b/experimental/Intersection/Intersection_Tests.cpp @@ -14,13 +14,13 @@ void parseSVG(); void Intersection_Tests() { int testsRun = 0; +#if 0 + CubicIntersection_OneOffTest(); + CubicIntersection_SelfTest(); QuadraticIntersection_IntersectionFinder(); QuadraticIntersection_OneOffTest(); CubicIntersection_IntersectionFinder(); - CubicIntersection_NewOneOffTest(); -#if 0 CubicUtilities_Test(); - CubicIntersection_SelfTest(); #endif SimplifyNew_Test(); CubicsToQuadratics_OneOffTest(); diff --git a/experimental/Intersection/SimplifyNew_Test.cpp b/experimental/Intersection/SimplifyNew_Test.cpp index de59cfd5e8..dc04cadc26 100644 --- a/experimental/Intersection/SimplifyNew_Test.cpp +++ b/experimental/Intersection/SimplifyNew_Test.cpp @@ -3536,7 +3536,6 @@ static void testCubic1() { testSimplifyx(path); } -#if 0 static void testQuadratic93() { SkPath path; path.moveTo(3, 0); @@ -3549,7 +3548,6 @@ static void testQuadratic93() { path.close(); testSimplifyx(path); } -#endif static void cubicOp1d() { SkPath path, pathB; @@ -4611,12 +4609,79 @@ static void cubicOp63d() { testShapeOp(path, pathB, kDifference_Op); } -static void (*firstTest)() = cubicOp63d; +static void testQuad1() { + SkPath path; + path.moveTo(0,0); + path.quadTo(0,0, 0,1); + path.lineTo(1,1); + path.close(); + path.moveTo(0,0); + path.quadTo(1,1, 0,2); + path.close(); + testSimplifyx(path); +} + +static void testQuad1z() { + SkPath path; + path.moveTo(0,0); + path.quadTo(0,0, 0,1); + path.lineTo(1,1); + path.close(); + path.moveTo(0,0); + path.lineTo(0.5f,1); + path.lineTo(0,2); + path.close(); + testSimplifyx(path); +} + +static void testQuad1c() { + SkPath path; + path.moveTo(0,0); + path.quadTo(0,0, 0,1); + path.lineTo(1,1); + path.close(); + path.moveTo(0,0); + path.cubicTo(0.5f,0.5f, 0.5f,1.5f, 0,2); + path.close(); + testSimplifyx(path); +} + +static void testRectOp1d() { + SkPath path, pathB; + path.moveTo(0,1); + path.cubicTo(0,1, 1,0, 3,0); + path.lineTo(0,1); + path.close(); + pathB.moveTo(0,1); + pathB.cubicTo(0,3, 1,0, 1,0); + pathB.lineTo(0,1); + pathB.close(); + testShapeOp(path, pathB, kDifference_Op); +} + +static void testCubicOp64d() { + SkPath path, pathB; + path.setFillType(SkPath::kWinding_FillType); + path.addRect(0, 0, 1, 1, SkPath::kCW_Direction); + path.addRect(2, 2, 3, 3, SkPath::kCW_Direction); + pathB.setFillType(SkPath::kEvenOdd_FillType); + pathB.addRect(0, 0, 4, 4, SkPath::kCW_Direction); + pathB.addRect(0, 0, 3, 3, SkPath::kCW_Direction); + testShapeOp(path, pathB, kDifference_Op); +} + +static void (*firstTest)() = testRectOp1d; static struct { void (*fun)(); const char* str; } tests[] = { + TEST(testRectOp1d), + TEST(testCubicOp64d), + TEST(testQuad1c), + TEST(testQuad1z), + TEST(testQuad1), + TEST(testQuadratic93), // FIXME: gets stuck in a loop because top is unsortable TEST(cubicOp63d), TEST(cubicOp62d), TEST(cubicOp61d), @@ -4704,7 +4769,6 @@ static struct { TEST(cubicOp3d), TEST(cubicOp2d), TEST(cubicOp1d), - // TEST(testQuadratic93), // FIXME: gets stuck in a loop because top is unsortable TEST(testCubic1), TEST(testQuadralateral1), TEST(testLine85), @@ -5063,7 +5127,7 @@ static void (*firstSubTest)() = 0; static bool skipAll = false; static bool runSubTestsFirst = false; -static bool runReverse = true; +static bool runReverse = false; static void (*stopTest)() = 0; void SimplifyNew_Test() { diff --git a/experimental/Intersection/as.htm b/experimental/Intersection/as.htm index f5f6250ec1..063b92113d 100644 --- a/experimental/Intersection/as.htm +++ b/experimental/Intersection/as.htm @@ -3612,11 +3612,92 @@ markDoneBinary id=1 (1,3 5,6 5,3 5,4) t=0.666666667 [2] (4.85185194,3.96296287) path.cubicTo(4.97231197,3.77658033, 4.93595362,3.85783577, 4.85185194,3.96296287); +
+ RunTestSet [testQuad1] +{{0,0}, {0,0}, {0,1}}, +{{0,1}, {1,1}}, +{{1,1}, {0,0}}, +{{0,0}, {1,1}, {0,2}}, +{{0,2}, {0,0}}, +debugShowLineIntersection wtTs[0]=0 {{0,0}, {0,1}} {{0,1}} wnTs[0]=1 {{0,1}, {1,1}} +debugShowLineIntersection wtTs[0]=1 {{0,0}, {0,1}} {{0,0}} wnTs[0]=0 {{1,1}, {0,0}} +debugShowLineIntersection wtTs[0]=-0 {{0,1}, {1,1}} {{1,1}} wnTs[0]=1 {{1,1}, {0,0}} +debugShowQuadLineIntersection wtTs[0]=0 {{0,0}, {1,1}, {0,2}} {{0,0}} wnTs[0]=0 {{0,0}, {0,1}} +debugShowLineIntersection wtTs[0]=1 {{0,0}, {0,1}} {{0,0}} wtTs[1]=0.5 {{0,1}} wnTs[0]=-0 {{0,2}, {0,0}} wnTs[1]=1 +debugShowQuadLineIntersection wtTs[0]=0.5 {{0,0}, {1,1}, {0,2}} {{0.5,1}} wnTs[0]=0.5 {{0,1}, {1,1}} +debugShowLineIntersection wtTs[0]=0.5 {{0,1}, {1,1}} {{0,1}} wnTs[0]=0 {{0,2}, {0,0}} +debugShowQuadLineIntersection wtTs[0]=0 {{0,0}, {1,1}, {0,2}} {{0,0}} wnTs[0]=1 {{1,1}, {0,0}} +debugShowLineIntersection wtTs[0]=1 {{1,1}, {0,0}} {{0,0}} wnTs[0]=1 {{0,2}, {0,0}} +debugShowQuadLineIntersection wtTs[0]=0 {{0,0}, {1,1}, {0,2}} {{0,0}} wtTs[1]=1 {{0,2}} wnTs[0]=1 {{0,2}, {0,0}} wnTs[1]=0 +debugShowTs id=1 [o=3,4 t=0 0,0 w=1 o=0] [o=2 t=1 0,1 w=1 o=0] +debugShowTs id=5 [o=4 t=0 0,2 w=1 o=0] [o=2 t=0.5 0,1 w=1 o=0] [o=3,4 t=1 0,0 w=1 o=0] +addTPair addTPair this=5 0.5 other=1 1 +debugShowTs id=1 [o=3,4 t=0 0,0 w=1 o=0] [o=2,5 t=1 0,1 w=1 o=0] +debugShowTs id=5 [o=4 t=0 0,2 w=1 o=0] [o=2,1 t=0.5 0,1 w=1 o=0] [o=3,4 t=1 0,0 w=1 o=0] +debugShowTs id=1 [o=3,4 t=0 0,0 w=0 o=0] [o=2,5 t=1 0,1 w=1 o=0] done +debugShowTs id=5 [o=4 t=0 0,2 w=1 o=0] [o=2,1 t=0.5 0,1 w=0 o=0] [o=3,4 t=1 0,0 w=1 o=0] +debugShowActiveSpans id=2 (0,1 1,1) t=0 (0,1) tEnd=0.5 other=1 otherT=1 otherIndex=2 windSum=? windValue=1 oppValue=0 +debugShowActiveSpans id=2 (0,1 1,1) t=0 (0,1) tEnd=0.5 other=5 otherT=0.5 otherIndex=1 windSum=? windValue=1 oppValue=0 +debugShowActiveSpans id=2 (0,1 1,1) t=0.5 (0.5,1) tEnd=1 other=4 otherT=0.5 otherIndex=3 windSum=? windValue=1 oppValue=0 +debugShowActiveSpans id=3 (1,1 0,0) t=-0 (1,1) tEnd=1 other=2 otherT=1 otherIndex=3 windSum=? windValue=1 oppValue=0 +debugShowActiveSpans id=4 (0,0 1,1 0,2) t=0 (0,0) tEnd=0.5 other=1 otherT=0 otherIndex=1 windSum=? windValue=1 oppValue=0 +debugShowActiveSpans id=4 (0,0 1,1 0,2) t=0 (0,0) tEnd=0.5 other=3 otherT=1 otherIndex=2 windSum=? windValue=1 oppValue=0 +debugShowActiveSpans id=4 (0,0 1,1 0,2) t=0 (0,0) tEnd=0.5 other=5 otherT=1 otherIndex=4 windSum=? windValue=1 oppValue=0 +debugShowActiveSpans id=4 (0,0 1,1 0,2) t=0.5 (0.5,1) tEnd=1 other=2 otherT=0.5 otherIndex=2 windSum=? windValue=1 oppValue=0 +debugShowActiveSpans id=5 (0,2 0,0) t=0 (0,2) tEnd=0.5 other=4 otherT=1 otherIndex=4 windSum=? windValue=1 oppValue=0 +findTop debugShowSort contourWinding=0 oppContourWinding=0 sign=-1 +debugShowSort [0] {{0,0}, {1,1}, {0,2}} tStart=0 tEnd=0.5 sign=-1 windValue=1 windSum=? 0->1 (max=1) done=0 tiny=0 opp=0 +debugShowSort [1] {{1,1}, {0,0}} tStart=1 tEnd=-0 sign=1 windValue=1 windSum=? 1->0 (max=1) done=0 tiny=0 opp=0 +findTop swap=1 serpentine=0 controls_contained_by_ends=0 +markWinding id=4 (0,0 1,1 0,2) t=0 [0] (0,0) tEnd=0 newWindSum=-1 newOppSum=0 oppSum=? windSum=? windValue=1 +markWinding id=4 (0,0 1,1 0,2) t=0 [1] (0,0) tEnd=0 newWindSum=-1 newOppSum=0 oppSum=? windSum=? windValue=1 +markWinding id=4 (0,0 1,1 0,2) t=0 [2] (0,0) tEnd=0.5 newWindSum=-1 newOppSum=0 oppSum=? windSum=? windValue=1 +markWinding id=4 (0,0 1,1 0,2) t=0 [0] (0,0) tEnd=0 newWindSum=-1 newOppSum=0 oppSum=0 windSum=-1 windValue=1 +markWinding id=4 (0,0 1,1 0,2) t=0 [1] (0,0) tEnd=0 newWindSum=-1 newOppSum=0 oppSum=0 windSum=-1 windValue=1 +markWinding id=4 (0,0 1,1 0,2) t=0 [2] (0,0) tEnd=0.5 newWindSum=-1 newOppSum=0 oppSum=0 windSum=-1 windValue=1 +findNextWinding debugShowSort contourWinding=0 oppContourWinding=0 sign=1 +debugShowSort [0] {{0,0}, {1,1}, {0,2}} tStart=0.5 tEnd=0 sign=1 windValue=1 windSum=-1 0->-1 (max=-1) done=0 tiny=0 opp=0 +debugShowSort [1] {{0,1}, {1,1}} tStart=0.5 tEnd=0 sign=1 windValue=1 windSum=? -1->-2 (max=-2) done=0 tiny=0 opp=0 +debugShowSort [2] {{0,0}, {1,1}, {0,2}} tStart=0.5 tEnd=1 sign=-1 windValue=1 windSum=? -2->-1 (max=-2) done=0 tiny=0 opp=0 +debugShowSort [3] {{0,1}, {1,1}} tStart=0.5 tEnd=1 sign=-1 windValue=1 windSum=? -1->0 (max=-1) done=0 tiny=0 opp=0 +findNextWinding firstIndex=[0] sign=1 +markDone id=2 (0,1 1,1) t=0 [0] (0,1) tEnd=0 newWindSum=-2 windSum=? windValue=1 +markDone id=2 (0,1 1,1) t=0 [1] (0,1) tEnd=0.5 newWindSum=-2 windSum=? windValue=1 +findNextWinding chase.append id=2 +markDone id=4 (0,0 1,1 0,2) t=0.5 [3] (0.5,1) tEnd=1 newWindSum=-2 windSum=? windValue=1 +markDone id=5 (0,2 0,0) t=0 [0] (0,2) tEnd=0.5 newWindSum=-2 windSum=? windValue=1 +findNextWinding chase.append id=5 +markWinding id=2 (0,1 1,1) t=0.5 [2] (0.5,1) tEnd=1 newWindSum=-1 windSum=? windValue=1 +markWinding id=3 (1,1 0,0) t=-0 [0] (1,1) tEnd=1 newWindSum=-1 windSum=? windValue=1 +findNextWinding chase.append id=3 +markDoneUnary id=4 (0,0 1,1 0,2) t=0 [0] (0,0) tEnd=0 newWindSum=-1 windSum=-1 windValue=1 +markDoneUnary id=4 (0,0 1,1 0,2) t=0 [1] (0,0) tEnd=0 newWindSum=-1 windSum=-1 windValue=1 +markDoneUnary id=4 (0,0 1,1 0,2) t=0 [2] (0,0) tEnd=0.5 newWindSum=-1 windSum=-1 windValue=1 +findNextWinding from:[4] to:[2] start=2 end=3 +bridgeWinding current id=4 from=(0,0) to=(0.5,1) +path.moveTo(0,0); +path.quadTo(0.5,0.5, 0.5,1); +findNextWinding simple +markDoneUnary id=2 (0,1 1,1) t=0.5 [2] (0.5,1) tEnd=1 newWindSum=-1 windSum=-1 windValue=1 +bridgeWinding current id=2 from=(0.5,1) to=(1,1) +findNextWinding debugShowSort contourWinding=0 oppContourWinding=? sign=1 +debugShowSort [1] {{1,1}, {0,0}} tStart=1 tEnd=-0 sign=1 windValue=1 windSum=-1 0->-1 (max=-1) done=0 tiny=0 opp=0 +debugShowSort [0] {{0,0}, {1,1}, {0,2}} tStart=0 tEnd=0.5 sign=-1 windValue=1 windSum=-1 -1->0 (max=-1) done=1 tiny=0 opp=0 +findNextWinding firstIndex=[1] sign=1 +markDoneUnary id=3 (1,1 0,0) t=-0 [0] (1,1) tEnd=1 newWindSum=-1 windSum=-1 windValue=1 +findNextWinding from:[3] to:[4] start=1 end=3 +bridgeWinding current id=3 from=(1,1) to=(0,0) +path.lineTo(1,1); +path.lineTo(0,0); +path.close(); +
+