aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/GeometryTest.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-02-29 20:59:24 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-02-29 20:59:24 +0000
commit087d5aafb18b88dfc6c6a5dbf59160c8be914e62 (patch)
treee9ad39f9b9ead185c64ac9c2cefb8f05dd2e8cf7 /tests/GeometryTest.cpp
parent8822266651a8ee54a3b958f02728d8b63bdf3094 (diff)
fix edgecase in chopcubic where we computed duplicate tvalues
git-svn-id: http://skia.googlecode.com/svn/trunk@3285 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/GeometryTest.cpp')
-rw-r--r--tests/GeometryTest.cpp22
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"