aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar fmalita <fmalita@chromium.org>2015-12-01 09:13:23 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-12-01 09:13:23 -0800
commitaa0df4e98d39cf0691fbaf0766c9f5f7ec72177f (patch)
treedbd8137882246dcb1eda16fd972e034bd717064a
parent0cbe7ee765cf72f15e6ca10b308676aa077fb3e2 (diff)
Add an SkPath conic conversion utility.
Expose SkConic::chopIntoQuadsPOW2() as SkPath::ConvertConicToQuads(). BUG=chromium:315277 R=reed@google.com Review URL: https://codereview.chromium.org/1484373002
-rw-r--r--include/core/SkPath.h7
-rw-r--r--src/core/SkPath.cpp6
2 files changed, 13 insertions, 0 deletions
diff --git a/include/core/SkPath.h b/include/core/SkPath.h
index 3c68ff7d84..33db8ac249 100644
--- a/include/core/SkPath.h
+++ b/include/core/SkPath.h
@@ -540,6 +540,13 @@ public:
}
/**
+ * Chop a conic into N quads, stored continguously in pts[], where
+ * N = 1 << pow2. The amount of storage needed is (1 + 2 * N)
+ */
+ static int ConvertConicToQuads(const SkPoint& p0, const SkPoint& p1, const SkPoint& p2,
+ SkScalar w, SkPoint pts[], int pow2);
+
+ /**
* Returns true if the path specifies a rectangle.
*
* If this returns false, then all output parameters are ignored, and left
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index 2d4976a82a..351629d125 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -2837,3 +2837,9 @@ bool SkPath::contains(SkScalar x, SkScalar y) const {
}
return SkToBool(w);
}
+
+int SkPath::ConvertConicToQuads(const SkPoint& p0, const SkPoint& p1, const SkPoint& p2,
+ SkScalar w, SkPoint pts[], int pow2) {
+ const SkConic conic(p0, p1, p2, w);
+ return conic.chopIntoQuadsPOW2(pts, pow2);
+}