Remove SK_TREAT_COLINEAR_DIAGONAL_POINTS_AS_CONCAVE This was rebaselined and removed from Chrome long ago. Planning to fix more bugs in the Convexicator, but want to get this out of the way first. Change-Id: I4f299d56a81be509a861d1e9c9f0e48a47170096 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209322 Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/gm/convex_all_line_paths.cpp b/gm/convex_all_line_paths.cpp index 1b607ff..38ee7b3 100644 --- a/gm/convex_all_line_paths.cpp +++ b/gm/convex_all_line_paths.cpp
@@ -55,13 +55,9 @@ const SkPoint gPoints4[] = { { -6.0f, -50.0f }, { 4.0f, -50.0f }, -#if SK_TREAT_COLINEAR_DIAGONAL_POINTS_AS_CONCAVE == 0 { 5.0f, -25.0f }, // remove if collinear diagonal points are not concave -#endif { 6.0f, 0.0f }, -#if SK_TREAT_COLINEAR_DIAGONAL_POINTS_AS_CONCAVE == 0 { 5.0f, 25.0f }, // remove if collinear diagonal points are not concave -#endif { 4.0f, 50.0f }, { -4.0f, 50.0f } };
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp index 6655ff1..29693a0 100644 --- a/src/core/SkPath.cpp +++ b/src/core/SkPath.cpp
@@ -2698,16 +2698,7 @@ largest = SkTMax(largest, -smallest); if (almost_equal(largest, largest + cross)) { -#if SK_TREAT_COLINEAR_DIAGONAL_POINTS_AS_CONCAVE - // colinear diagonals are not allowed; they aren't numerically stable - #define COLINEAR_POINT_DIR_CHANGE kConcave_DirChange -#else - // colinear diagonals are allowed; we can survive dealing with 'close enough' - #define COLINEAR_POINT_DIR_CHANGE kStraight_DirChange -#endif - - SkScalar dot = lastVec.dot(curVec); - return dot < 0 ? kBackwards_DirChange : COLINEAR_POINT_DIR_CHANGE; + return lastVec.dot(curVec) < 0 ? kBackwards_DirChange : kStraight_DirChange; } return 1 == SkScalarSignAsInt(cross) ? kRight_DirChange : kLeft_DirChange; }
diff --git a/src/core/SkPathPriv.h b/src/core/SkPathPriv.h index ff2fdc1..855efae 100644 --- a/src/core/SkPathPriv.h +++ b/src/core/SkPathPriv.h
@@ -10,14 +10,6 @@ #include "SkPath.h" -#define SK_TREAT_COLINEAR_DIAGONAL_POINTS_AS_CONCAVE 0 - -#if SK_TREAT_COLINEAR_DIAGONAL_POINTS_AS_CONCAVE - #define COLINEAR_DIAGONAL_CONVEXITY kConcave_Convexity -#else - #define COLINEAR_DIAGONAL_CONVEXITY kConvex_Convexity -#endif - class SkPathPriv { public: #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp index 7ce1ee3..e55cb44 100644 --- a/tests/PathTest.cpp +++ b/tests/PathTest.cpp
@@ -1348,16 +1348,10 @@ tinyConvexPolygon.lineTo(600.134891f, 800.137724f); tinyConvexPolygon.close(); tinyConvexPolygon.getConvexity(); - check_convexity(reporter, tinyConvexPolygon, SkPath::COLINEAR_DIAGONAL_CONVEXITY); -#if SK_TREAT_COLINEAR_DIAGONAL_POINTS_AS_CONCAVE - // colinear diagonal points cause convexicator to give up, so CheapComputeFirstDirection - // makes its best guess - check_direction(reporter, tinyConvexPolygon, SkPathPriv::kCW_FirstDirection); -#else + check_convexity(reporter, tinyConvexPolygon, SkPath::kConvex_Convexity); // lines are close enough to straight that polygon collapses to line that does not // enclose area, so has unknown first direction check_direction(reporter, tinyConvexPolygon, SkPathPriv::kUnknown_FirstDirection); -#endif SkPath platTriangle; platTriangle.moveTo(0, 0); @@ -1485,7 +1479,7 @@ SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle); stroke.setStrokeStyle(2 * SK_Scalar1); stroke.applyToPath(&strokedSin, strokedSin); - check_convexity(reporter, strokedSin, SkPath::COLINEAR_DIAGONAL_CONVEXITY); + check_convexity(reporter, strokedSin, SkPath::kConvex_Convexity); // !!! check_direction(reporter, strokedSin, kDontCheckDir); // http://crbug.com/412640 @@ -1519,7 +1513,7 @@ doubleback.lineTo(1, 1); check_convexity(reporter, doubleback, SkPath::kConvex_Convexity); doubleback.lineTo(2, 2); - check_convexity(reporter, doubleback, SkPath::COLINEAR_DIAGONAL_CONVEXITY); + check_convexity(reporter, doubleback, SkPath::kConvex_Convexity); doubleback.reset(); doubleback.lineTo(1, 0); check_convexity(reporter, doubleback, SkPath::kConvex_Convexity); @@ -1529,7 +1523,7 @@ check_convexity(reporter, doubleback, SkPath::kConvex_Convexity); doubleback.reset(); doubleback.quadTo(1, 1, 2, 2); - check_convexity(reporter, doubleback, SkPath::COLINEAR_DIAGONAL_CONVEXITY); + check_convexity(reporter, doubleback, SkPath::kConvex_Convexity); doubleback.reset(); doubleback.quadTo(1, 0, 2, 0); check_convexity(reporter, doubleback, SkPath::kConvex_Convexity); @@ -1592,7 +1586,7 @@ path.reset(); path.quadTo(100, 100, 50, 50); // This from GM:convexpaths - check_convexity(reporter, path, SkPath::COLINEAR_DIAGONAL_CONVEXITY); + check_convexity(reporter, path, SkPath::kConvex_Convexity); static const struct { const char* fPathStr; @@ -3727,10 +3721,10 @@ // diagonal colinear points make arc convex // TODO: one way to keep it concave would be to introduce interpolated on curve points // between control points and computing the on curve point at scan conversion time - REPORTER_ASSERT(reporter, p.getConvexity() == SkPath::COLINEAR_DIAGONAL_CONVEXITY); + REPORTER_ASSERT(reporter, p.getConvexity() == SkPath::kConvex_Convexity); REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(p, SkPathPriv::kCW_FirstDirection)); p.setConvexity(SkPath::kUnknown_Convexity); - REPORTER_ASSERT(reporter, p.getConvexity() == SkPath::COLINEAR_DIAGONAL_CONVEXITY); + REPORTER_ASSERT(reporter, p.getConvexity() == SkPath::kConvex_Convexity); } static inline SkScalar oval_start_index_to_angle(unsigned start) {