Add new C API for settign/getting fill type.
authorPeter Golde <peter@golde.org>
Mon, 14 Mar 2016 20:35:52 +0000 (13:35 -0700)
committerPeter Golde <peter@golde.org>
Mon, 14 Mar 2016 20:35:52 +0000 (13:35 -0700)
include/c/sk_path.h
include/c/sk_types.h
src/c/sk_surface.cpp
src/c/sk_types_priv.h

index 2a73b88..e9e7299 100644 (file)
@@ -68,6 +68,16 @@ SK_API void sk_path_add_rect(sk_path_t*, const sk_rect_t*, sk_path_direction_t);
 SK_API void sk_path_add_oval(sk_path_t*, const sk_rect_t*, sk_path_direction_t);
 
 /**
+    Get the fill type of the path.
+*/
+SK_API sk_path_filltype_t sk_path_get_filltype(sk_path_t*);
+
+/**
+    Set the fill type of the path.
+*/
+SK_API void sk_path_set_filltype(sk_path_t*, sk_path_filltype_t);
+
+/**
  *  If the path is empty, return false and set the rect parameter to [0, 0, 0, 0].
  *  else return true and set the rect parameter to the bounds of the control-points
  *  of the path.
index 9a65183..6c6b754 100644 (file)
@@ -324,6 +324,13 @@ typedef enum {
 } sk_path_direction_t;
 
 typedef enum {
+    WINDING_SK_PATH_FILLTYPE,
+    EVENODD_SK_PATH_FILLTYPE,
+    INVERSE_WINDING_SK_PATH_FILLTYPE,
+    INVERSE_EVENODD_SK_PATH_FILLTYPE,
+} sk_path_filltype_t;
+
+typedef enum {
     CLAMP_SK_SHADER_TILEMODE,
     REPEAT_SK_SHADER_TILEMODE,
     MIRROR_SK_SHADER_TILEMODE,
index 4c1a8a8..fe1a6b1 100644 (file)
@@ -128,6 +128,22 @@ void sk_path_add_oval(sk_path_t* cpath, const sk_rect_t* crect, sk_path_directio
     as_path(cpath)->addOval(AsRect(*crect), dir);
 }
 
+void sk_path_set_filltype(sk_path_t* cpath, sk_path_filltype_t cfilltype) {
+    SkPath::FillType filltype;
+    if (!find_sk(cfilltype, &filltype)) {
+        return;
+    }
+    as_path(cpath)->setFillType(filltype);
+}
+
+sk_path_filltype_t sk_path_get_filltype(sk_path_t *cpath) {
+    sk_path_filltype_t cfilltype; 
+    if (!find_c(as_path(cpath)->getFillType(), &cfilltype)) {
+        cfilltype = WINDING_SK_PATH_FILLTYPE;
+    }
+    return cfilltype;
+}
+
 bool sk_path_get_bounds(const sk_path_t* cpath, sk_rect_t* crect) {
     const SkPath& path = AsPath(*cpath);
 
index 4a2de83..86da457 100644 (file)
@@ -413,6 +413,20 @@ const struct {
 #include "sk_c_from_to.h"
 
 const struct {
+    sk_path_filltype_t fC;
+    SkPath::FillType   fSK;
+} MAKE_FROM_TO_NAME(sk_path_filltype_t)[] = {
+    { WINDING_SK_PATH_FILLTYPE,  SkPath::kWinding_FillType },
+    { EVENODD_SK_PATH_FILLTYPE, SkPath::kEvenOdd_FillType },
+    { INVERSE_WINDING_SK_PATH_FILLTYPE,  SkPath::kInverseWinding_FillType },
+    { INVERSE_EVENODD_SK_PATH_FILLTYPE, SkPath::kInverseEvenOdd_FillType },
+};
+#define CType           sk_path_filltype_t
+#define SKType          SkPath::FillType
+#define CTypeSkTypeMap  MAKE_FROM_TO_NAME(sk_path_filltype_t)
+#include "sk_c_from_to.h"
+
+const struct {
     sk_blurstyle_t  fC;
     SkBlurStyle     fSK;
 } MAKE_FROM_TO_NAME(sk_blurstyle_t)[] = {