[C API] Add support for SkPath.RawIter, in addition to SkPath.Iter
authorMiguel de Icaza <miguel@gnome.org>
Wed, 6 Jul 2016 02:21:47 +0000 (22:21 -0400)
committerMiguel de Icaza <miguel@gnome.org>
Wed, 6 Jul 2016 02:21:47 +0000 (22:21 -0400)
include/c/xamarin/sk_x_path.h
include/c/xamarin/sk_x_types.h
src/c/xamarin/sk_x_path.cpp
src/c/xamarin/sk_x_types_priv.h

index 7469ef4ce92208f36aa21d79268077e82cdc76a4..f675da634a9b811d36440294bef6e686b8147e19 100644 (file)
@@ -76,6 +76,7 @@ SK_API void sk_path_transform(sk_path_t* cpath, const sk_matrix_t* cmatrix);
 */
 SK_API sk_path_t* sk_path_clone(const sk_path_t* cpath);
 
+/* Iterators */
 SK_API sk_path_iterator_t* sk_path_create_iter (sk_path_t *cpath, int forceClose);
 
 SK_API sk_path_verb_t sk_path_iter_next (sk_path_iterator_t *iterator, sk_point_t points [4], int doConsumeDegenerates, int exact);
@@ -86,11 +87,32 @@ SK_API int sk_path_iter_is_close_line (sk_path_iterator_t *iterator);
 
 SK_API int sk_path_iter_is_closed_contour (sk_path_iterator_t *iterator);
 
+SK_API void sk_path_iter_destroy (sk_path_iterator_t *iterator);
+
+/* Raw iterators */
+SK_API sk_path_rawiterator_t* sk_path_create_rawiter (sk_path_t *cpath);
+
+SK_API sk_path_verb_t sk_path_rawiter_peek (sk_path_rawiterator_t *iterator);
+
+SK_API sk_path_verb_t sk_path_rawiter_next (sk_path_rawiterator_t *iterator);
+
+SK_API float sk_path_rawiter_conic_weight (sk_path_rawiterator_t *iterator);
+
+SK_API void sk_path_rawiter_destroy (sk_path_rawiterator_t *iterator);
 
 /* Paths */
 
+/**
+   Adds the @other path to the @cpath by appending a @dx, @dy offset to each node, using the specified adding mode in @add_mode
+ */ 
 SK_API void sk_path_add_path_offset  (sk_path_t* cpath, sk_path_t* other, float dx, float dy, sk_path_add_mode_t add_mode);
+/**
+   Adds the @other path to the @cpath by applying the @matrix transformation on the @other, using the specified adding mode in @add_mode
+ */ 
 SK_API void sk_path_add_path_matrix  (sk_path_t* cpath, sk_path_t* other, sk_matrix_t *matrix, sk_path_add_mode_t add_mode);
+/**
+   Adds the @other path to the @cpath using the specified adding mode in @add_mode
+ */ 
 SK_API void sk_path_add_path         (sk_path_t* cpath, sk_path_t* other, sk_path_add_mode_t add_mode);
 SK_API void sk_path_add_path_reverse (sk_path_t* cpath, sk_path_t* other);
 
index aeaff9acab84211ecb91988cebdd028f482fd0e3..73a154d0702f914a7b2c5dee0c764e3add7b66b3 100644 (file)
@@ -234,6 +234,7 @@ typedef enum {
 } sk_path_verb_t;
 
 typedef struct sk_path_iterator_t sk_path_iterator_t;
+typedef struct sk_path_rawiterator_t sk_path_rawiterator_t;
 
 typedef enum {
        APPEND_ADD_MODE,
index e753c6e0773cf296a87c7f23d3e73b0e8ff90d89..681abcd2a1f29f32b3d84c8261f97442de3a1f4c 100644 (file)
@@ -123,6 +123,40 @@ int sk_path_iter_is_closed_contour (sk_path_iterator_t *iterator)
     return AsPathIter(iterator)->isClosedContour ();
 }
 
+void sk_path_iter_destroy (sk_path_iterator_t *iterator)
+{
+    delete AsPathIter (iterator);
+}
+
+sk_path_rawiterator_t* sk_path_create_rawiter (sk_path_t *cpath)
+{
+    SkPath::RawIter* iter = new SkPath::RawIter(AsPath(*cpath));
+    return ToPathRawIter(iter);
+}
+
+sk_path_verb_t sk_path_rawiter_next (sk_path_rawiterator_t *iterator, sk_point_t points [4])
+{
+    SkPath::RawIter *iter = AsPathRawIter(iterator);
+    SkPoint *pts = AsPoint(points);
+    SkPath::Verb verb = iter->next(pts);
+    return (sk_path_verb_t)verb;
+}
+
+sk_path_verb_t sk_path_rawiter_peek (sk_path_rawiterator_t *iterator)
+{
+    return (sk_path_verb_t) AsPathRawIter(iterator)->peek ();
+}
+
+float sk_path_rawiter_conic_weight (sk_path_rawiterator_t *iterator)
+{
+    return AsPathRawIter(iterator)->conicWeight ();
+}
+
+void sk_path_rawiter_destroy (sk_path_rawiterator_t *iterator)
+{
+    delete AsPathRawIter (iterator);
+}
+
 #if __cplusplus >= 199711L
 static_assert (SkPath::kAppend_AddPathMode == APPEND_ADD_MODE, "ABI changed, you must write a enumeration mapper for SkPath::AddPathMode to sk_path_add_mode_t");
 static_assert (SkPath::kExtend_AddPathMode == EXTEND_ADD_MODE, "ABI changed, you must write a enumeration mapper for SkPath::AddPathMode to sk_path_add_mode_t");
index f0ef81183d5a49331933879e0e1b744ec6d29a1c..d47bb4c2fa74b7b73836d82f2d06858d598b411c 100644 (file)
@@ -729,4 +729,12 @@ static inline SkPath::Iter* AsPathIter(sk_path_iterator_t* iter) {
 static inline sk_path_iterator_t* ToPathIter(SkPath::Iter* iter) {
     return reinterpret_cast<sk_path_iterator_t*>(iter);
 }
+
+static inline SkPath::RawIter* AsPathRawIter(sk_path_rawiterator_t* iter) {
+    return reinterpret_cast<SkPath::RawIter*>(iter);
+}
+
+static inline sk_path_rawiterator_t* ToPathRawIter(SkPath::RawIter* iter) {
+    return reinterpret_cast<sk_path_rawiterator_t*>(iter);
+}
 #endif