From 081595dac0040797ac8a964a75834f7d1c0b47d2 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Wed, 17 Aug 2016 04:28:29 +0200 Subject: [PATCH] Using the SkPaint::Style instead of a simple bool --- include/c/sk_paint.h | 4 ++-- include/c/sk_types.h | 6 ++++++ src/c/sk_enums.cpp | 5 +++++ src/c/sk_paint.cpp | 8 ++++---- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/include/c/sk_paint.h b/include/c/sk_paint.h index 2968a4e..d2dc8f6 100644 --- a/include/c/sk_paint.h +++ b/include/c/sk_paint.h @@ -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. */ diff --git a/include/c/sk_types.h b/include/c/sk_types.h index c9cf8c6..3db095a 100644 --- a/include/c/sk_types.h +++ b/include/c/sk_types.h @@ -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; diff --git a/src/c/sk_enums.cpp b/src/c/sk_enums.cpp index 8987ff4..87b9e0e 100644 --- a/src/c/sk_enums.cpp +++ b/src/c/sk_enums.cpp @@ -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)); diff --git a/src/c/sk_paint.cpp b/src/c/sk_paint.cpp index 306c243..0be64b9 100644 --- a/src/c/sk_paint.cpp +++ b/src/c/sk_paint.cpp @@ -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) { -- 2.7.4