From 246039fd056bcec1abc12c8aa7e42d0686ad0fc2 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Sun, 3 Jul 2016 00:27:23 -0400 Subject: [PATCH] [C API] Add SkPath APIs to add sub-paths --- include/c/xamarin/sk_x_path.h | 10 +++++++++- include/c/xamarin/sk_x_types.h | 5 +++++ src/c/xamarin/sk_x_path.cpp | 29 +++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/include/c/xamarin/sk_x_path.h b/include/c/xamarin/sk_x_path.h index d8363ade3b..7469ef4ce9 100644 --- a/include/c/xamarin/sk_x_path.h +++ b/include/c/xamarin/sk_x_path.h @@ -85,7 +85,15 @@ SK_API float sk_path_iter_conic_weight (sk_path_iterator_t *iterator); 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); - + + +/* Paths */ + +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); +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); +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); + SK_C_PLUS_PLUS_END_GUARD #endif diff --git a/include/c/xamarin/sk_x_types.h b/include/c/xamarin/sk_x_types.h index e3a9c69ff5..aeaff9acab 100644 --- a/include/c/xamarin/sk_x_types.h +++ b/include/c/xamarin/sk_x_types.h @@ -235,6 +235,11 @@ typedef enum { typedef struct sk_path_iterator_t sk_path_iterator_t; +typedef enum { + APPEND_ADD_MODE, + EXTEND_ADD_MODE, +} sk_path_add_mode_t; + SK_C_PLUS_PLUS_END_GUARD #endif diff --git a/src/c/xamarin/sk_x_path.cpp b/src/c/xamarin/sk_x_path.cpp index c36d2d1531..e753c6e077 100644 --- a/src/c/xamarin/sk_x_path.cpp +++ b/src/c/xamarin/sk_x_path.cpp @@ -122,3 +122,32 @@ int sk_path_iter_is_closed_contour (sk_path_iterator_t *iterator) { return AsPathIter(iterator)->isClosedContour (); } + +#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"); +#endif + +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) +{ + as_path (cpath)->addPath (AsPath (*other), dx, dy, (SkPath::AddPathMode) add_mode); +} + +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) +{ + SkMatrix skmatrix; + from_c(matrix, &skmatrix); + as_path (cpath)->addPath (AsPath (*other), skmatrix, (SkPath::AddPathMode) add_mode); +} + +void sk_path_add_path (sk_path_t* cpath, sk_path_t* other, sk_path_add_mode_t add_mode) +{ + as_path (cpath)->addPath (AsPath (*other), (SkPath::AddPathMode) add_mode); +} + +void sk_path_add_path_reverse (sk_path_t* cpath, sk_path_t* other) +{ + as_path (cpath)->reverseAddPath (AsPath (*other)); +} + + -- 2.34.1