diff options
author | caryclark <caryclark@google.com> | 2015-03-26 07:52:43 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-26 07:52:43 -0700 |
commit | 54359294a7c9dc54802d512a5d891a35c1663392 (patch) | |
tree | 7339bbad708bb43a4a96f7b76075c84ff7732189 /tests/PathOpsDRectTest.cpp | |
parent | c08330f1601aeca7f10aeb2194118decbfbf83e1 (diff) |
cumulative pathops patch
Replace the implicit curve intersection with a geometric curve intersection. The implicit intersection proved mathematically unstable and took a long time to zero in on an answer.
Use pointers instead of indices to refer to parts of curves. Indices required awkward renumbering.
Unify t and point values so that small intervals can be eliminated in one pass.
Break cubics up front to eliminate loops and cusps.
Make the Simplify and Op code more regular and eliminate arbitrary differences.
Add a builder that takes an array of paths and operators.
Delete unused code.
BUG=skia:3588
R=reed@google.com
Review URL: https://codereview.chromium.org/1037573004
Diffstat (limited to 'tests/PathOpsDRectTest.cpp')
-rw-r--r-- | tests/PathOpsDRectTest.cpp | 64 |
1 files changed, 17 insertions, 47 deletions
diff --git a/tests/PathOpsDRectTest.cpp b/tests/PathOpsDRectTest.cpp index 874e82b69a..70d39d15c0 100644 --- a/tests/PathOpsDRectTest.cpp +++ b/tests/PathOpsDRectTest.cpp @@ -11,15 +11,6 @@ #include "SkPathOpsRect.h" #include "Test.h" -static const SkDLine lineTests[] = { - {{{2, 1}, {2, 1}}}, - {{{2, 1}, {1, 1}}}, - {{{2, 1}, {2, 2}}}, - {{{1, 1}, {2, 2}}}, - {{{3, 0}, {2, 1}}}, - {{{3, 2}, {1, 1}}}, -}; - static const SkDQuad quadTests[] = { {{{1, 1}, {2, 1}, {0, 2}}}, {{{0, 0}, {1, 1}, {3, 1}}}, @@ -34,44 +25,31 @@ static const SkDCubic cubicTests[] = { {{{3, 0}, {2, 1}, {3, 2}, {1, 1}}}, }; -static const size_t lineTests_count = SK_ARRAY_COUNT(lineTests); static const size_t quadTests_count = SK_ARRAY_COUNT(quadTests); static const size_t cubicTests_count = SK_ARRAY_COUNT(cubicTests); +static void setRawBounds(const SkDQuad& quad, SkDRect* rect) { + rect->set(quad[0]); + rect->add(quad[1]); + rect->add(quad[2]); +} + +static void setRawBounds(const SkDCubic& cubic, SkDRect* rect) { + rect->set(cubic[0]); + rect->add(cubic[1]); + rect->add(cubic[2]); + rect->add(cubic[3]); +} + DEF_TEST(PathOpsDRect, reporter) { size_t index; SkDRect rect, rect2; - for (index = 0; index < lineTests_count; ++index) { - const SkDLine& line = lineTests[index]; - SkASSERT(ValidLine(line)); - rect.setBounds(line); - REPORTER_ASSERT(reporter, rect.fLeft == SkTMin(line[0].fX, line[1].fX)); - REPORTER_ASSERT(reporter, rect.fTop == SkTMin(line[0].fY, line[1].fY)); - REPORTER_ASSERT(reporter, rect.fRight == SkTMax(line[0].fX, line[1].fX)); - REPORTER_ASSERT(reporter, rect.fBottom == SkTMax(line[0].fY, line[1].fY)); - rect2.set(line[0]); - rect2.add(line[1]); - REPORTER_ASSERT(reporter, rect2.fLeft == SkTMin(line[0].fX, line[1].fX)); - REPORTER_ASSERT(reporter, rect2.fTop == SkTMin(line[0].fY, line[1].fY)); - REPORTER_ASSERT(reporter, rect2.fRight == SkTMax(line[0].fX, line[1].fX)); - REPORTER_ASSERT(reporter, rect2.fBottom == SkTMax(line[0].fY, line[1].fY)); - REPORTER_ASSERT(reporter, rect.contains(line[0])); - REPORTER_ASSERT(reporter, rect.intersects(&rect2)); - } for (index = 0; index < quadTests_count; ++index) { const SkDQuad& quad = quadTests[index]; SkASSERT(ValidQuad(quad)); - rect.setRawBounds(quad); - REPORTER_ASSERT(reporter, rect.fLeft == SkTMin(quad[0].fX, - SkTMin(quad[1].fX, quad[2].fX))); - REPORTER_ASSERT(reporter, rect.fTop == SkTMin(quad[0].fY, - SkTMin(quad[1].fY, quad[2].fY))); - REPORTER_ASSERT(reporter, rect.fRight == SkTMax(quad[0].fX, - SkTMax(quad[1].fX, quad[2].fX))); - REPORTER_ASSERT(reporter, rect.fBottom == SkTMax(quad[0].fY, - SkTMax(quad[1].fY, quad[2].fY))); + setRawBounds(quad, &rect); rect2.setBounds(quad); - REPORTER_ASSERT(reporter, rect.intersects(&rect2)); + REPORTER_ASSERT(reporter, rect.intersects(rect2)); // FIXME: add a recursive box subdivision method to verify that tight bounds is correct SkDPoint leftTop = {rect2.fLeft, rect2.fTop}; REPORTER_ASSERT(reporter, rect.contains(leftTop)); @@ -81,17 +59,9 @@ DEF_TEST(PathOpsDRect, reporter) { for (index = 0; index < cubicTests_count; ++index) { const SkDCubic& cubic = cubicTests[index]; SkASSERT(ValidCubic(cubic)); - rect.setRawBounds(cubic); - REPORTER_ASSERT(reporter, rect.fLeft == SkTMin(cubic[0].fX, - SkTMin(cubic[1].fX, SkTMin(cubic[2].fX, cubic[3].fX)))); - REPORTER_ASSERT(reporter, rect.fTop == SkTMin(cubic[0].fY, - SkTMin(cubic[1].fY, SkTMin(cubic[2].fY, cubic[3].fY)))); - REPORTER_ASSERT(reporter, rect.fRight == SkTMax(cubic[0].fX, - SkTMax(cubic[1].fX, SkTMax(cubic[2].fX, cubic[3].fX)))); - REPORTER_ASSERT(reporter, rect.fBottom == SkTMax(cubic[0].fY, - SkTMax(cubic[1].fY, SkTMax(cubic[2].fY, cubic[3].fY)))); + setRawBounds(cubic, &rect); rect2.setBounds(cubic); - REPORTER_ASSERT(reporter, rect.intersects(&rect2)); + REPORTER_ASSERT(reporter, rect.intersects(rect2)); // FIXME: add a recursive box subdivision method to verify that tight bounds is correct SkDPoint leftTop = {rect2.fLeft, rect2.fTop}; REPORTER_ASSERT(reporter, rect.contains(leftTop)); |