add test for SkConvertQuadToCubic
git-svn-id: http://skia.googlecode.com/svn/trunk@1967 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkGeometry.cpp b/src/core/SkGeometry.cpp
index 3c9e9f9..57ce2fd 100644
--- a/src/core/SkGeometry.cpp
+++ b/src/core/SkGeometry.cpp
@@ -448,18 +448,20 @@
}
}
-void SkConvertQuadToCubic(const SkPoint src[3], SkPoint dst[4])
-{
- SkScalar two = SkIntToScalar(2);
- SkScalar one_third = SkScalarDiv(SK_Scalar1, SkIntToScalar(3));
- dst[0].set(src[0].fX, src[0].fY);
- dst[1].set(
- SkScalarMul(SkScalarMulAdd(src[1].fX, two, src[0].fX), one_third),
- SkScalarMul(SkScalarMulAdd(src[1].fY, two, src[0].fY), one_third));
- dst[2].set(
- SkScalarMul(SkScalarMulAdd(src[1].fX, two, src[2].fX), one_third),
- SkScalarMul(SkScalarMulAdd(src[1].fY, two, src[2].fY), one_third));
- dst[3].set(src[2].fX, src[2].fY);
+#ifdef SK_SCALAR_IS_FLOAT
+ #define SK_ScalarTwoThirds (0.666666666f)
+#else
+ #define SK_ScalarTwoThirds ((SkFixed)(43691))
+#endif
+
+void SkConvertQuadToCubic(const SkPoint src[3], SkPoint dst[4]) {
+ const SkScalar scale = SK_ScalarTwoThirds;
+ dst[0] = src[0];
+ dst[1].set(src[0].fX + SkScalarMul(src[1].fX - src[0].fX, scale),
+ src[0].fY + SkScalarMul(src[1].fY - src[0].fY, scale));
+ dst[2].set(src[2].fX + SkScalarMul(src[1].fX - src[2].fX, scale),
+ src[2].fY + SkScalarMul(src[1].fY - src[2].fY, scale));
+ dst[3] = src[2];
}
////////////////////////////////////////////////////////////////////////////////////////