aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar mike@reedtribe.org <mike@reedtribe.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-04-14 02:40:50 +0000
committerGravatar mike@reedtribe.org <mike@reedtribe.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-04-14 02:40:50 +0000
commit8d551011966a1bc14a654dbde704f343c0e222b6 (patch)
tree6b673139aae31e58f9e3b3df80c543809f1163e9 /src
parent4af6280aa366a02540f34c48f89ea73ce3d27974 (diff)
add special-case for chopping at exactly half for rational-quads (2-3x faster)
git-svn-id: http://skia.googlecode.com/svn/trunk@8672 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/core/SkGeometry.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/core/SkGeometry.cpp b/src/core/SkGeometry.cpp
index 511c34e1aa..a440d039de 100644
--- a/src/core/SkGeometry.cpp
+++ b/src/core/SkGeometry.cpp
@@ -1464,3 +1464,24 @@ void SkRationalQuad::chopAt(SkScalar t, SkRationalQuad dst[2]) const {
dst[0].fW = tmp2[0].fZ / root;
dst[1].fW = tmp2[2].fZ / root;
}
+
+void SkRationalQuad::chop(SkRationalQuad dst[2]) const {
+ SkScalar scale = SkScalarInvert(SK_Scalar1 + fW);
+ SkScalar p1x = fW * fPts[1].fX;
+ SkScalar p1y = fW * fPts[1].fY;
+ SkScalar mx = (fPts[0].fX + 2 * p1x + fPts[2].fX) * scale * SK_ScalarHalf;
+ SkScalar my = (fPts[0].fY + 2 * p1y + fPts[2].fY) * scale * SK_ScalarHalf;
+
+ dst[0].fPts[0] = fPts[0];
+ dst[0].fPts[1].set((fPts[0].fX + p1x) * scale,
+ (fPts[0].fY + p1y) * scale);
+ dst[0].fPts[2].set(mx, my);
+
+ dst[1].fPts[0].set(mx, my);
+ dst[1].fPts[1].set((p1x + fPts[2].fX) * scale,
+ (p1y + fPts[2].fY) * scale);
+ dst[1].fPts[2] = fPts[2];
+
+ dst[0].fW = dst[1].fW = SkScalarSqrt((1 + fW) * SK_ScalarHalf);
+}
+