aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PathTest.cpp
diff options
context:
space:
mode:
authorGravatar caryclark <caryclark@google.com>2015-12-18 04:35:24 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-12-18 04:35:24 -0800
commit9cb5d755e7ea8647bcf8bb1ee151ca4c86051107 (patch)
tree7036c005ab9109676b4348aa50bbee212c932e97 /tests/PathTest.cpp
parentc8b4336444e7b90382e04e33665fb3b8490b825b (diff)
fix bugs in path contains
Pull out the logic to check to see if the point is on the edge so all curve types can share. Reorder cubic to be like conic and quad so that mixed types consider the curves consistently. Don't count on curve points twice if they are on the end and compute a zero cross product. Remove logic that checks, when there are no roots, if the point is closer to the top or the bottom (it's always the top). Initialize the iterator correctly when it is accessing the list of on point curves. Use 'multiply' instead of 'subtract' to see if the vectors are pointing in opposite directions. Add more test cases. R=reed@google.com,fs@opera.com BUG=skia:4265 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1532003004 Review URL: https://codereview.chromium.org/1532003004
Diffstat (limited to 'tests/PathTest.cpp')
-rw-r--r--tests/PathTest.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index aa2ffdb32f..faa091c997 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -3591,6 +3591,10 @@ static void test_contains(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, p.contains(5, 5));
REPORTER_ASSERT(reporter, p.contains(5, 8));
REPORTER_ASSERT(reporter, p.contains(4, 5));
+ // test quad endpoints
+ REPORTER_ASSERT(reporter, p.contains(4, 4));
+ REPORTER_ASSERT(reporter, p.contains(8, 8));
+ REPORTER_ASSERT(reporter, p.contains(4, 8));
p.reset();
const SkPoint qPts[] = {{6, 6}, {8, 8}, {6, 8}, {4, 8}, {4, 6}, {4, 4}, {6, 6}};
@@ -3622,6 +3626,10 @@ static void test_contains(skiatest::Reporter* reporter) {
halfway = conic.evalAt(0.5f);
REPORTER_ASSERT(reporter, p.contains(halfway.fX, halfway.fY));
}
+ // test conic end points
+ REPORTER_ASSERT(reporter, p.contains(4, 4));
+ REPORTER_ASSERT(reporter, p.contains(8, 8));
+ REPORTER_ASSERT(reporter, p.contains(4, 8));
// test cubics
SkPoint pts[] = {{5, 4}, {6, 5}, {7, 6}, {6, 6}, {4, 6}, {5, 7}, {5, 5}, {5, 4}, {6, 5}, {7, 6}};
@@ -3639,6 +3647,10 @@ static void test_contains(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, p.contains(halfway.fX, halfway.fY));
SkEvalCubicAt(&pts[i + 3], 0.5f, &halfway, nullptr, nullptr);
REPORTER_ASSERT(reporter, p.contains(halfway.fX, halfway.fY));
+ // test cubic end points
+ REPORTER_ASSERT(reporter, p.contains(pts[i].fX, pts[i].fY));
+ REPORTER_ASSERT(reporter, p.contains(pts[i + 3].fX, pts[i + 3].fY));
+ REPORTER_ASSERT(reporter, p.contains(pts[i + 6].fX, pts[i + 6].fY));
}
}