Index: tests/PathTest.cpp |
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp |
index 36e93074ef4b59c66d2ceb45094ca0aa7272a3dc..df255dd6400bc0aea68aff2188aae90daedf9cb2 100644 |
--- a/tests/PathTest.cpp |
+++ b/tests/PathTest.cpp |
@@ -5,6 +5,7 @@ |
* found in the LICENSE file. |
*/ |
+#include <cmath> |
#include "SkCanvas.h" |
#include "SkGeometry.h" |
#include "SkPaint.h" |
@@ -3306,12 +3307,12 @@ static void test_arc(skiatest::Reporter* reporter) { |
p.reset(); |
SkPath cwOval; |
cwOval.addOval(oval); |
- p.addArc(oval, 1, 360); |
+ p.addArc(oval, 0, 360); |
REPORTER_ASSERT(reporter, p == cwOval); |
p.reset(); |
SkPath ccwOval; |
ccwOval.addOval(oval, SkPath::kCCW_Direction); |
- p.addArc(oval, 1, -360); |
+ p.addArc(oval, 0, -360); |
REPORTER_ASSERT(reporter, p == ccwOval); |
p.reset(); |
p.addArc(oval, 1, 180); |
@@ -3321,6 +3322,33 @@ static void test_arc(skiatest::Reporter* reporter) { |
REPORTER_ASSERT(reporter, p.isConvex()); |
} |
+static void test_arc_ovals(skiatest::Reporter* reporter) { |
+ SkRect oval = SkRect::MakeWH(10, 20); |
+ for (SkScalar sweep : {-360.f, 360.f}) { |
+ for (SkScalar start = -360.f; start <= 360.f; start += 1.f) { |
+ SkPath path; |
+ path.addArc(oval, start, sweep); |
+ SkRect r; |
+ SkPath::Direction d; |
+ unsigned s; |
+ bool isOval = path.isOval(&r, &d, &s); |
+ // SkPath's interfaces for inserting and extracting ovals only allow contours |
+ // to start at multiples of 90 degrees. |
+ if (std::fmod(start, 90.f) == 0) { |
+ REPORTER_ASSERT(reporter, isOval); |
+ SkPath recreatedPath; |
+ recreatedPath.addOval(r, d, s); |
+ REPORTER_ASSERT(reporter, path == recreatedPath); |
robertphillips
2016/05/27 12:12:30
Do we still need these next 3 lines? They look lik
bsalomon
2016/05/27 14:29:33
Done.
|
+ path.reset(); |
+ path.addArc(oval, start, sweep); |
+ path.isOval(&r, &d, &s); |
+ } else { |
+ REPORTER_ASSERT(reporter, !isOval); |
+ } |
+ } |
+ } |
+} |
+ |
static void check_move(skiatest::Reporter* reporter, SkPath::RawIter* iter, |
SkScalar x0, SkScalar y0) { |
SkPoint pts[4]; |
@@ -4121,6 +4149,7 @@ DEF_TEST(Paths, reporter) { |
test_path_to_region(reporter); |
test_rrect(reporter); |
test_arc(reporter); |
+ test_arc_ovals(reporter); |
test_arcTo(reporter); |
test_addPath(reporter); |
test_addPathMode(reporter, false, false); |