add interp path
Add path methods to determine if a pair of paths
can be interpolated, and to interpolate them.
R=reed@google.com, robertphillips@google.com
BUG=skia:4549
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1703943003
Review URL: https://codereview.chromium.org/1703943003
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index 719c033..4c2f897 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -193,6 +193,33 @@
}
}
+bool SkPath::isInterpolatable(const SkPath& compare) const {
+ int count = fPathRef->countVerbs();
+ if (count != compare.fPathRef->countVerbs()) {
+ return false;
+ }
+ if (!count) {
+ return true;
+ }
+ if (memcmp(fPathRef->verbsMemBegin(), compare.fPathRef->verbsMemBegin(),
+ count)) {
+ return false;
+ }
+ return !SkToBool(memcmp(fPathRef->conicWeights(), compare.fPathRef->conicWeights(),
+ fPathRef->countWeights() * sizeof(*fPathRef->conicWeights())));
+}
+
+bool SkPath::interpolate(const SkPath& ending, SkScalar weight, SkPath* out) const {
+ int verbCount = fPathRef->countVerbs();
+ if (verbCount != ending.fPathRef->countVerbs()) {
+ return false;
+ }
+ out->reset();
+ out->addPath(*this);
+ fPathRef->interpolate(*ending.fPathRef, weight, out->fPathRef);
+ return true;
+}
+
static inline bool check_edge_against_rect(const SkPoint& p0,
const SkPoint& p1,
const SkRect& rect,