diff options
Diffstat (limited to 'tests/GeometryTest.cpp')
-rw-r--r-- | tests/GeometryTest.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/GeometryTest.cpp b/tests/GeometryTest.cpp index 6158a20d60..7cee730d47 100644 --- a/tests/GeometryTest.cpp +++ b/tests/GeometryTest.cpp @@ -12,6 +12,26 @@ static bool nearly_equal(const SkPoint& a, const SkPoint& b) { return SkScalarNearlyEqual(a.fX, b.fX) && SkScalarNearlyEqual(a.fY, b.fY); } +static void testChopCubic(skiatest::Reporter* reporter) { + /* + Inspired by this test, which used to assert that the tValues had dups + + <path stroke="#202020" d="M0,0 C0,0 1,1 2190,5130 C2190,5070 2220,5010 2205,4980" /> + */ + const SkPoint src[] = { + { SkIntToScalar(2190), SkIntToScalar(5130) }, + { SkIntToScalar(2190), SkIntToScalar(5070) }, + { SkIntToScalar(2220), SkIntToScalar(5010) }, + { SkIntToScalar(2205), SkIntToScalar(4980) }, + }; + SkPoint dst[13]; + SkScalar tValues[3]; + int count = SkChopCubicAtMaxCurvature(src, dst, tValues); + // if we successfully collaps duplicate t-values, we should only get 2 segments + REPORTER_ASSERT(reporter, 2 == count); +} + + static void TestGeometry(skiatest::Reporter* reporter) { SkPoint pts[3], dst[5]; @@ -35,6 +55,8 @@ static void TestGeometry(skiatest::Reporter* reporter) { for (int i = 0; i < 4; ++i) { REPORTER_ASSERT(reporter, nearly_equal(cubic[i], dst[i])); } + + testChopCubic(reporter); } #include "TestClassDef.h" |