From 087d5aafb18b88dfc6c6a5dbf59160c8be914e62 Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Wed, 29 Feb 2012 20:59:24 +0000 Subject: fix edgecase in chopcubic where we computed duplicate tvalues git-svn-id: http://skia.googlecode.com/svn/trunk@3285 2bbb7eff-a529-9590-31e7-b0007b416f81 --- tests/GeometryTest.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests/GeometryTest.cpp') 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 + + + */ + 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" -- cgit v1.2.3