Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Unified Diff: src/core/SkGeometry.cpp

Issue 1036753002: SkChopCubicAt2 using Sk2s-- 2x faster (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkGeometry.h ('k') | tests/GeometryTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkGeometry.cpp
diff --git a/src/core/SkGeometry.cpp b/src/core/SkGeometry.cpp
index 0d64fb5137c474d5b294c4be54a1ecb814e85684..62c5903123eea2affb218dc0445517c4309c754d 100644
--- a/src/core/SkGeometry.cpp
+++ b/src/core/SkGeometry.cpp
@@ -479,6 +479,31 @@ void SkChopCubicAt(const SkPoint src[4], SkPoint dst[7], SkScalar t) {
interp_cubic_coords(&src[0].fY, &dst[0].fY, t);
}
+void SkChopCubicAt2(const SkPoint src[4], SkPoint dst[7], SkScalar t) {
+ SkASSERT(t > 0 && t < SK_Scalar1);
+
+ Sk2s p0 = from_point(src[0]);
+ Sk2s p1 = from_point(src[1]);
+ Sk2s p2 = from_point(src[2]);
+ Sk2s p3 = from_point(src[3]);
+ Sk2s tt(t);
+
+ Sk2s ab = interp(p0, p1, tt);
+ Sk2s bc = interp(p1, p2, tt);
+ Sk2s cd = interp(p2, p3, tt);
+ Sk2s abc = interp(ab, bc, tt);
+ Sk2s bcd = interp(bc, cd, tt);
+ Sk2s abcd = interp(abc, bcd, tt);
+
+ dst[0] = src[0];
+ dst[1] = to_point(ab);
+ dst[2] = to_point(abc);
+ dst[3] = to_point(abcd);
+ dst[4] = to_point(bcd);
+ dst[5] = to_point(cd);
+ dst[6] = src[3];
+}
+
/* http://code.google.com/p/skia/issues/detail?id=32
This test code would fail when we didn't check the return result of
« no previous file with comments | « src/core/SkGeometry.h ('k') | tests/GeometryTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698