reed | 73c2501 | 2014-11-17 06:15:42 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | // EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL |
| 9 | // DO NOT USE -- FOR INTERNAL TESTING ONLY |
| 10 | |
| 11 | #ifndef sk_paint_DEFINED |
| 12 | #define sk_paint_DEFINED |
| 13 | |
| 14 | #include "sk_types.h" |
| 15 | |
| 16 | SK_C_PLUS_PLUS_BEGIN_GUARD |
| 17 | |
halcanary | c911906 | 2015-09-01 10:45:09 -0700 | [diff] [blame] | 18 | /** |
| 19 | Create a new paint with default settings: |
| 20 | antialias : false |
| 21 | stroke : false |
| 22 | stroke width : 0.0f (hairline) |
| 23 | stroke miter : 4.0f |
| 24 | stroke cap : BUTT_SK_STROKE_CAP |
| 25 | stroke join : MITER_SK_STROKE_JOIN |
| 26 | color : opaque black |
| 27 | shader : NULL |
| 28 | maskfilter : NULL |
| 29 | xfermode_mode : SRCOVER_SK_XFERMODE_MODE |
| 30 | */ |
Brian Salomon | 7551898 | 2016-12-28 15:56:16 -0500 | [diff] [blame] | 31 | SK_API sk_paint_t* sk_paint_new(void); |
halcanary | c911906 | 2015-09-01 10:45:09 -0700 | [diff] [blame] | 32 | /** |
| 33 | Release the memory storing the sk_paint_t and unref() all |
| 34 | associated objects. |
| 35 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 36 | SK_API void sk_paint_delete(sk_paint_t*); |
reed | afa278e | 2014-11-24 19:11:48 -0800 | [diff] [blame] | 37 | |
halcanary | c911906 | 2015-09-01 10:45:09 -0700 | [diff] [blame] | 38 | /** |
| 39 | Return true iff the paint has antialiasing enabled. |
| 40 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 41 | SK_API bool sk_paint_is_antialias(const sk_paint_t*); |
halcanary | c911906 | 2015-09-01 10:45:09 -0700 | [diff] [blame] | 42 | /** |
| 43 | Set to true to enable antialiasing, false to disable it on this |
| 44 | sk_paint_t. |
| 45 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 46 | SK_API void sk_paint_set_antialias(sk_paint_t*, bool); |
reed | afa278e | 2014-11-24 19:11:48 -0800 | [diff] [blame] | 47 | |
halcanary | c911906 | 2015-09-01 10:45:09 -0700 | [diff] [blame] | 48 | /** |
| 49 | Return the paint's curent drawing color. |
| 50 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 51 | SK_API sk_color_t sk_paint_get_color(const sk_paint_t*); |
halcanary | c911906 | 2015-09-01 10:45:09 -0700 | [diff] [blame] | 52 | /** |
| 53 | Set the paint's curent drawing color. |
| 54 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 55 | SK_API void sk_paint_set_color(sk_paint_t*, sk_color_t); |
reed | 73c2501 | 2014-11-17 06:15:42 -0800 | [diff] [blame] | 56 | |
reed | f5872d2 | 2015-01-10 17:59:31 -0800 | [diff] [blame] | 57 | /* stroke settings */ |
| 58 | |
halcanary | c911906 | 2015-09-01 10:45:09 -0700 | [diff] [blame] | 59 | /** |
| 60 | Return true iff stroking is enabled rather than filling on this |
| 61 | sk_paint_t. |
| 62 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 63 | SK_API bool sk_paint_is_stroke(const sk_paint_t*); |
halcanary | c911906 | 2015-09-01 10:45:09 -0700 | [diff] [blame] | 64 | /** |
| 65 | Set to true to enable stroking rather than filling with this |
| 66 | sk_paint_t. |
| 67 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 68 | SK_API void sk_paint_set_stroke(sk_paint_t*, bool); |
reed | f5872d2 | 2015-01-10 17:59:31 -0800 | [diff] [blame] | 69 | |
halcanary | c911906 | 2015-09-01 10:45:09 -0700 | [diff] [blame] | 70 | /** |
| 71 | Return the width for stroking. A value of 0 strokes in hairline mode. |
| 72 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 73 | SK_API float sk_paint_get_stroke_width(const sk_paint_t*); |
halcanary | c911906 | 2015-09-01 10:45:09 -0700 | [diff] [blame] | 74 | /** |
| 75 | Set the width for stroking. A value of 0 strokes in hairline mode |
| 76 | (always draw 1-pixel wide, regardless of the matrix). |
| 77 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 78 | SK_API void sk_paint_set_stroke_width(sk_paint_t*, float width); |
reed | f5872d2 | 2015-01-10 17:59:31 -0800 | [diff] [blame] | 79 | |
halcanary | c911906 | 2015-09-01 10:45:09 -0700 | [diff] [blame] | 80 | /** |
| 81 | Return the paint's stroke miter value. This is used to control the |
| 82 | behavior of miter joins when the joins angle is sharp. |
| 83 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 84 | SK_API float sk_paint_get_stroke_miter(const sk_paint_t*); |
halcanary | c911906 | 2015-09-01 10:45:09 -0700 | [diff] [blame] | 85 | /** |
| 86 | Set the paint's stroke miter value. This is used to control the |
| 87 | behavior of miter joins when the joins angle is sharp. This value |
| 88 | must be >= 0. |
| 89 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 90 | SK_API void sk_paint_set_stroke_miter(sk_paint_t*, float miter); |
reed | f5872d2 | 2015-01-10 17:59:31 -0800 | [diff] [blame] | 91 | |
| 92 | typedef enum { |
| 93 | BUTT_SK_STROKE_CAP, |
| 94 | ROUND_SK_STROKE_CAP, |
| 95 | SQUARE_SK_STROKE_CAP |
| 96 | } sk_stroke_cap_t; |
| 97 | |
halcanary | c911906 | 2015-09-01 10:45:09 -0700 | [diff] [blame] | 98 | /** |
| 99 | Return the paint's stroke cap type, controlling how the start and |
| 100 | end of stroked lines and paths are treated. |
| 101 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 102 | SK_API sk_stroke_cap_t sk_paint_get_stroke_cap(const sk_paint_t*); |
halcanary | c911906 | 2015-09-01 10:45:09 -0700 | [diff] [blame] | 103 | /** |
| 104 | Set the paint's stroke cap type, controlling how the start and |
| 105 | end of stroked lines and paths are treated. |
| 106 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 107 | SK_API void sk_paint_set_stroke_cap(sk_paint_t*, sk_stroke_cap_t); |
reed | f5872d2 | 2015-01-10 17:59:31 -0800 | [diff] [blame] | 108 | |
| 109 | typedef enum { |
| 110 | MITER_SK_STROKE_JOIN, |
| 111 | ROUND_SK_STROKE_JOIN, |
| 112 | BEVEL_SK_STROKE_JOIN |
| 113 | } sk_stroke_join_t; |
| 114 | |
halcanary | c911906 | 2015-09-01 10:45:09 -0700 | [diff] [blame] | 115 | /** |
| 116 | Return the paint's stroke join type, specifies the treatment that |
| 117 | is applied to corners in paths and rectangles |
| 118 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 119 | SK_API sk_stroke_join_t sk_paint_get_stroke_join(const sk_paint_t*); |
halcanary | c911906 | 2015-09-01 10:45:09 -0700 | [diff] [blame] | 120 | /** |
| 121 | Set the paint's stroke join type, specifies the treatment that |
| 122 | is applied to corners in paths and rectangles |
| 123 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 124 | SK_API void sk_paint_set_stroke_join(sk_paint_t*, sk_stroke_join_t); |
reed | f5872d2 | 2015-01-10 17:59:31 -0800 | [diff] [blame] | 125 | |
reed | afa278e | 2014-11-24 19:11:48 -0800 | [diff] [blame] | 126 | /** |
| 127 | * Set the paint's shader to the specified parameter. This will automatically call unref() on |
| 128 | * any previous value, and call ref() on the new value. |
| 129 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 130 | SK_API void sk_paint_set_shader(sk_paint_t*, sk_shader_t*); |
reed | afa278e | 2014-11-24 19:11:48 -0800 | [diff] [blame] | 131 | |
reed | 0eafc9b | 2014-12-23 14:11:11 -0800 | [diff] [blame] | 132 | /** |
| 133 | * Set the paint's maskfilter to the specified parameter. This will automatically call unref() on |
| 134 | * any previous value, and call ref() on the new value. |
| 135 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 136 | SK_API void sk_paint_set_maskfilter(sk_paint_t*, sk_maskfilter_t*); |
reed | 0eafc9b | 2014-12-23 14:11:11 -0800 | [diff] [blame] | 137 | |
halcanary | 7568d0b | 2015-07-31 13:38:06 -0700 | [diff] [blame] | 138 | /** |
| 139 | * Set the paint's xfermode to the specified parameter. |
| 140 | */ |
halcanary | 219f18f | 2015-09-01 10:01:38 -0700 | [diff] [blame] | 141 | SK_API void sk_paint_set_xfermode_mode(sk_paint_t*, sk_xfermode_mode_t); |
halcanary | 7568d0b | 2015-07-31 13:38:06 -0700 | [diff] [blame] | 142 | |
reed | 73c2501 | 2014-11-17 06:15:42 -0800 | [diff] [blame] | 143 | SK_C_PLUS_PLUS_END_GUARD |
| 144 | |
| 145 | #endif |