Using the SkPaint::Style instead of a simple bool
authorMatthew Leibowitz <mattleibow@live.com>
Wed, 17 Aug 2016 02:28:29 +0000 (04:28 +0200)
committerMatthew Leibowitz <mattleibow@live.com>
Wed, 17 Aug 2016 02:28:29 +0000 (04:28 +0200)
include/c/sk_paint.h
include/c/sk_types.h
src/c/sk_enums.cpp
src/c/sk_paint.cpp

index 2968a4e..d2dc8f6 100644 (file)
@@ -55,12 +55,12 @@ SK_API void sk_paint_set_color(sk_paint_t*, sk_color_t);
     Return true iff stroking is enabled rather than filling on this
     sk_paint_t.
 */
-SK_API bool sk_paint_is_stroke(const sk_paint_t*);
+SK_API sk_paint_style_t sk_paint_get_style(const sk_paint_t*);
 /**
     Set to true to enable stroking rather than filling with this
     sk_paint_t.
 */
-SK_API void sk_paint_set_stroke(sk_paint_t*, bool);
+SK_API void sk_paint_set_style(sk_paint_t*, sk_paint_style_t);
 /**
     Return the width for stroking.  A value of 0 strokes in hairline mode.
  */
index c9cf8c6..3db095a 100644 (file)
@@ -502,6 +502,12 @@ typedef enum {
     LARGE_SK_PATH_ARC_SIZE,
 } sk_path_arc_size_t;
 
+typedef enum {
+    FILL_SK_PAINT_STYLE,
+    STROKE_SK_PAINT_STYLE,
+    STROKE_AND_FILL_SK_PAINT_STYLE,
+} sk_paint_style_t;
+
 typedef struct sk_colortable_t sk_colortable_t;
 
 typedef struct sk_pixelref_factory_t sk_pixelref_factory_t;
index 8987ff4..87b9e0e 100644 (file)
@@ -237,6 +237,11 @@ static_assert ((int)SkPath1DPathEffect::Style::kTranslate_Style   == (int)TRANSL
 static_assert ((int)SkPath1DPathEffect::Style::kRotate_Style      == (int)ROTATE_SK_PATH_EFFECT_1D_STYLE,      ASSERT_MSG(SkPath1DPathEffect::Style, sk_path_effect_1d_style_t));
 static_assert ((int)SkPath1DPathEffect::Style::kMorph_Style       == (int)MORPH_SK_PATH_EFFECT_1D_STYLE,       ASSERT_MSG(SkPath1DPathEffect::Style, sk_path_effect_1d_style_t));
 
+// sk_path_effect_1d_style_t
+static_assert ((int)SkPaint::Style::kFill_Style            == (int)FILL_SK_PAINT_STYLE,              ASSERT_MSG(SkPaint::Style, sk_paint_style_t));
+static_assert ((int)SkPaint::Style::kStrokeAndFill_Style   == (int)STROKE_AND_FILL_SK_PAINT_STYLE,   ASSERT_MSG(SkPaint::Style, sk_paint_style_t));
+static_assert ((int)SkPaint::Style::kStroke_Style          == (int)STROKE_SK_PAINT_STYLE,            ASSERT_MSG(SkPaint::Style, sk_paint_style_t));
+
 // sk_point_mode_t
 static_assert ((int)SkCanvas::PointMode::kPoints_PointMode    == (int)POINTS_SK_POINT_MODE,    ASSERT_MSG(SkCanvas::PointMode, sk_point_mode_t));
 static_assert ((int)SkCanvas::PointMode::kLines_PointMode     == (int)LINES_SK_POINT_MODE,     ASSERT_MSG(SkCanvas::PointMode, sk_point_mode_t));
index 306c243..0be64b9 100644 (file)
@@ -45,12 +45,12 @@ void sk_paint_set_maskfilter(sk_paint_t* cpaint, sk_maskfilter_t* cfilter) {
     AsPaint(cpaint)->setMaskFilter(sk_ref_sp(AsMaskFilter(cfilter)));
 }
 
-bool sk_paint_is_stroke(const sk_paint_t* cpaint) {
-    return AsPaint(*cpaint).getStyle() != SkPaint::kFill_Style;
+sk_paint_style_t sk_paint_get_style(const sk_paint_t* cpaint) {
+    return (sk_paint_style_t)AsPaint(*cpaint).getStyle();
 }
 
-void sk_paint_set_stroke(sk_paint_t* cpaint, bool doStroke) {
-    AsPaint(cpaint)->setStyle(doStroke ? SkPaint::kStroke_Style : SkPaint::kFill_Style);
+void sk_paint_set_style(sk_paint_t* cpaint, sk_paint_style_t style) {
+    AsPaint(cpaint)->setStyle((SkPaint::Style)style);
 }
 
 float sk_paint_get_stroke_width(const sk_paint_t* cpaint) {