Added a few more SKPath methods to the C API
authorMatthew Leibowitz <mattleibow@live.com>
Wed, 14 Sep 2016 05:16:17 +0000 (07:16 +0200)
committerMatthew Leibowitz <mattleibow@live.com>
Wed, 14 Sep 2016 05:16:17 +0000 (07:16 +0200)
include/c/sk_path.h
include/c/sk_types.h
src/c/sk_enums.cpp
src/c/sk_path.cpp

index 1385e83..f96415b 100644 (file)
@@ -215,6 +215,14 @@ SK_API int sk_path_get_points (const sk_path_t* cpath, sk_point_t* points, int m
 
 SK_API bool sk_path_contains (const sk_path_t* cpath, float x, float y);
 
+SK_API sk_path_convexity_t sk_path_get_convexity (const sk_path_t* cpath);
+
+SK_API void sk_path_set_convexity (sk_path_t* cpath, sk_path_convexity_t convexity);
+
+SK_API bool sk_path_parse_svg_string (sk_path_t* cpath, const char* str);
+
+SK_API void sk_path_to_svg_string (const sk_path_t* cpath, sk_string_t* str);
+
 SK_API bool sk_path_get_last_point (const sk_path_t* cpath, sk_point_t* point);
 
 SK_API bool sk_pathop_op(const sk_path_t* one, const sk_path_t* two, sk_pathop_t op, sk_path_t* result);
index 7c48bfa..cff0f25 100644 (file)
@@ -632,6 +632,12 @@ typedef enum {
 
 typedef struct sk_opbuilder_t sk_opbuilder_t;
 
+typedef enum {
+    UNKNOWN_SK_PATH_CONVEXITY,
+    CONVEX_SK_PATH_CONVEXITY,
+    CONCAVE_SK_PATH_CONVEXITY,
+} sk_path_convexity_t;
+
 SK_C_PLUS_PLUS_END_GUARD
 
 #endif
index 0b5426a..0450149 100644 (file)
@@ -298,4 +298,9 @@ static_assert ((int)SkPathOp::kUnion_SkPathOp               == (int)UNION_SK_PAT
 static_assert ((int)SkPathOp::kXOR_SkPathOp                 == (int)XOR_SK_PATHOP,                  ASSERT_MSG(SkPathOp, sk_pathop_t));
 static_assert ((int)SkPathOp::kReverseDifference_SkPathOp   == (int)REVERSE_DIFFERENCE_SK_PATHOP,   ASSERT_MSG(SkPathOp, sk_pathop_t));
 
+// sk_path_convexity_t
+static_assert ((int)SkPath::Convexity::kUnknown_Convexity   == (int)UNKNOWN_SK_PATH_CONVEXITY,   ASSERT_MSG(SkPath::Convexity, sk_path_convexity_t));
+static_assert ((int)SkPath::Convexity::kConvex_Convexity    == (int)CONVEX_SK_PATH_CONVEXITY,    ASSERT_MSG(SkPath::Convexity, sk_path_convexity_t));
+static_assert ((int)SkPath::Convexity::kConcave_Convexity   == (int)CONCAVE_SK_PATH_CONVEXITY,   ASSERT_MSG(SkPath::Convexity, sk_path_convexity_t));
+
 #endif
index c5128d3..0defb4e 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "SkPath.h"
 #include "SkPathOps.h"
+#include "SkParsePath.h"
 
 #include "sk_path.h"
 
@@ -247,6 +248,22 @@ bool sk_path_contains (const sk_path_t* cpath, float x, float y) {
     return AsPath(*cpath).contains(x, y);
 }
 
+sk_path_convexity_t sk_path_get_convexity (const sk_path_t* cpath) {
+    return (sk_path_convexity_t)AsPath(*cpath).getConvexity();
+}
+
+void sk_path_set_convexity (sk_path_t* cpath, sk_path_convexity_t convexity) {
+    AsPath(cpath)->setConvexity((SkPath::Convexity)convexity);
+}
+
+SK_API bool sk_path_parse_svg_string (sk_path_t* cpath, const char* str) {
+    return SkParsePath::FromSVGString(str, AsPath(cpath));
+}
+
+SK_API void sk_path_to_svg_string (const sk_path_t* cpath, sk_string_t* str) {
+    SkParsePath::ToSVGString(AsPath(*cpath), AsString(str));
+}
+
 bool sk_path_get_last_point (const sk_path_t* cpath, sk_point_t* point) {
     if (point) {
         return AsPath(*cpath).getLastPt(AsPoint(point));