SK_API int sk_path_convert_conic_to_quads(const sk_point_t* p0, const sk_point_t* p1, const sk_point_t* p2, float w, sk_point_t* pts, int pow2);
+SK_API sk_pathmeasure_t* sk_pathmeasure_new();
+
+SK_API sk_pathmeasure_t* sk_pathmeasure_new_with_path(const sk_path_t* path, bool forceClosed, float resScale);
+
+SK_API void sk_pathmeasure_destroy(sk_pathmeasure_t* pathMeasure);
+
+SK_API void sk_pathmeasure_set_path(sk_pathmeasure_t* pathMeasure, const sk_path_t* path, bool forceClosed);
+
+SK_API float sk_pathmeasure_get_length(sk_pathmeasure_t* pathMeasure);
+
+SK_API bool sk_pathmeasure_get_pos_tan(sk_pathmeasure_t* pathMeasure, float distance, sk_point_t* position, sk_vector_t* tangent);
+
+SK_API bool sk_pathmeasure_get_matrix(sk_pathmeasure_t* pathMeasure, float distance, sk_matrix_t* matrix, sk_pathmeasure_matrixflags_t flags);
+
+SK_API bool sk_pathmeasure_get_segment(sk_pathmeasure_t* pathMeasure, float start, float stop, sk_path_t* dst, bool startWithMoveTo);
+
+SK_API bool sk_pathmeasure_is_closed(sk_pathmeasure_t* pathMeasure);
+
+SK_API bool sk_pathmeasure_next_contour(sk_pathmeasure_t* pathMeasure);
+
SK_C_PLUS_PLUS_END_GUARD
#endif
float y;
} sk_point_t;
+typedef sk_point_t sk_vector_t;
+
typedef struct {
int32_t left;
int32_t top;
const sk_irect_t* fBounds;
} sk_lattice_t;
+typedef struct sk_pathmeasure_t sk_pathmeasure_t;
+
+typedef enum {
+ GET_POSITION_SK_PATHMEASURE_MATRIXFLAGS = 0x01,
+ GET_TANGENT_SK_PATHMEASURE_MATRIXFLAGS = 0x02,
+ GET_POS_AND_TAN_SK_PATHMEASURE_MATRIXFLAGS = GET_POSITION_SK_PATHMEASURE_MATRIXFLAGS | GET_TANGENT_SK_PATHMEASURE_MATRIXFLAGS,
+} sk_pathmeasure_matrixflags_t;
+
SK_C_PLUS_PLUS_END_GUARD
#endif
static_assert ((int)0 == (int)DEFAULT_SK_LATTICE_FLAGS, ASSERT_MSG(SkCanvas::Lattice::Flags, sk_lattice_flags_t));
static_assert ((int)SkCanvas::Lattice::Flags::kTransparent_Flags == (int)TRANSPARENT_SK_LATTICE_FLAGS, ASSERT_MSG(SkCanvas::Lattice::Flags, sk_lattice_flags_t));
+// sk_pathmeasure_matrixflags_t
+static_assert ((int)SkPathMeasure::MatrixFlags::kGetPosition_MatrixFlag == (int)GET_POSITION_SK_PATHMEASURE_MATRIXFLAGS, ASSERT_MSG(SkPathMeasure::MatrixFlags, sk_pathmeasure_matrixflags_t));
+static_assert ((int)SkPathMeasure::MatrixFlags::kGetTangent_MatrixFlag == (int)GET_TANGENT_SK_PATHMEASURE_MATRIXFLAGS, ASSERT_MSG(SkPathMeasure::MatrixFlags, sk_pathmeasure_matrixflags_t));
+static_assert ((int)SkPathMeasure::MatrixFlags::kGetPosAndTan_MatrixFlag == (int)GET_POS_AND_TAN_SK_PATHMEASURE_MATRIXFLAGS, ASSERT_MSG(SkPathMeasure::MatrixFlags, sk_pathmeasure_matrixflags_t));
+
#endif
*/
#include "SkPath.h"
+#include "SkPathMeasure.h"
#include "SkPathOps.h"
#include "SkParsePath.h"
AsPath(cpath)->setConvexity((SkPath::Convexity)convexity);
}
-SK_API bool sk_path_parse_svg_string (sk_path_t* cpath, const char* str) {
+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) {
+void sk_path_to_svg_string (const sk_path_t* cpath, sk_string_t* str) {
SkParsePath::ToSVGString(AsPath(*cpath), AsString(str));
}
int sk_path_convert_conic_to_quads(const sk_point_t* p0, const sk_point_t* p1, const sk_point_t* p2, float w, sk_point_t* pts, int pow2) {
return SkPath::ConvertConicToQuads(AsPoint(*p0), AsPoint(*p1), AsPoint(*p2), w, AsPoint(pts), pow2);
}
+
+sk_pathmeasure_t* sk_pathmeasure_new() {
+ return ToPathMeasure(new SkPathMeasure());
+}
+
+sk_pathmeasure_t* sk_pathmeasure_new_with_path(const sk_path_t* path, bool forceClosed, float resScale) {
+ return ToPathMeasure(new SkPathMeasure(AsPath(*path), forceClosed, resScale));
+}
+
+void sk_pathmeasure_destroy(sk_pathmeasure_t* pathMeasure) {
+ delete AsPathMeasure(pathMeasure);
+}
+
+void sk_pathmeasure_set_path(sk_pathmeasure_t* pathMeasure, const sk_path_t* path, bool forceClosed) {
+ AsPathMeasure(pathMeasure)->setPath(AsPath(path), forceClosed);
+}
+
+float sk_pathmeasure_get_length(sk_pathmeasure_t* pathMeasure) {
+ return AsPathMeasure(pathMeasure)->getLength();
+}
+
+bool sk_pathmeasure_get_pos_tan(sk_pathmeasure_t* pathMeasure, float distance, sk_point_t* position, sk_vector_t* tangent) {
+ return AsPathMeasure(pathMeasure)->getPosTan(distance, AsPoint(position), AsPoint(tangent));
+}
+
+bool sk_pathmeasure_get_matrix(sk_pathmeasure_t* pathMeasure, float distance, sk_matrix_t* matrix, sk_pathmeasure_matrixflags_t flags) {
+ SkMatrix skmatrix;
+ bool result = AsPathMeasure(pathMeasure)->getMatrix(distance, &skmatrix, (SkPathMeasure::MatrixFlags)flags);
+ from_sk(&skmatrix, matrix);
+ return result;
+}
+
+bool sk_pathmeasure_get_segment(sk_pathmeasure_t* pathMeasure, float start, float stop, sk_path_t* dst, bool startWithMoveTo) {
+ return AsPathMeasure(pathMeasure)->getSegment(start, stop, AsPath(dst), startWithMoveTo);
+}
+
+bool sk_pathmeasure_is_closed(sk_pathmeasure_t* pathMeasure) {
+ return AsPathMeasure(pathMeasure)->isClosed();
+}
+
+bool sk_pathmeasure_next_contour(sk_pathmeasure_t* pathMeasure) {
+ return AsPathMeasure(pathMeasure)->nextContour();
+}
#include "SkDocument.h"
#include "SkPaint.h"
#include "SkPath.h"
+#include "SkPathMeasure.h"
#include "SkCodec.h"
#include "SkPicture.h"
#include "SkPictureRecorder.h"
return reinterpret_cast<SkPath*>(cpath);
}
+static inline const SkPath* AsPath(const sk_path_t* cpath) {
+ return reinterpret_cast<const SkPath*>(cpath);
+}
+
static inline const SkImage* AsImage(const sk_image_t* cimage) {
return reinterpret_cast<const SkImage*>(cimage);
}
return reinterpret_cast<const SkCanvas::Lattice&>(p);
}
+static inline sk_pathmeasure_t* ToPathMeasure(SkPathMeasure* p) {
+ return reinterpret_cast<sk_pathmeasure_t*>(p);
+}
+
+static inline SkPathMeasure* AsPathMeasure(sk_pathmeasure_t* p) {
+ return reinterpret_cast<SkPathMeasure*>(p);
+}
+
static inline void from_c(const sk_matrix_t* cmatrix, SkMatrix* matrix) {
matrix->setAll(
cmatrix->mat[0], cmatrix->mat[1], cmatrix->mat[2],