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
16SK_C_PLUS_PLUS_BEGIN_GUARD
17
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*/
31SK_API sk_paint_t* sk_paint_new(void);
32/**
33    Release the memory storing the sk_paint_t and unref() all
34    associated objects.
35*/
36SK_API void sk_paint_delete(sk_paint_t*);
37
38/**
39    Return true iff the paint has antialiasing enabled.
40*/
41SK_API bool sk_paint_is_antialias(const sk_paint_t*);
42/**
43    Set to true to enable antialiasing, false to disable it on this
44    sk_paint_t.
45*/
46SK_API void sk_paint_set_antialias(sk_paint_t*, bool);
47
48/**
49    Return the paint's curent drawing color.
50*/
51SK_API sk_color_t sk_paint_get_color(const sk_paint_t*);
52/**
53    Set the paint's curent drawing color.
54*/
55SK_API void sk_paint_set_color(sk_paint_t*, sk_color_t);
56
57/* stroke settings */
58
59/**
60    Return true iff stroking is enabled rather than filling on this
61    sk_paint_t.
62*/
63SK_API bool sk_paint_is_stroke(const sk_paint_t*);
64/**
65    Set to true to enable stroking rather than filling with this
66    sk_paint_t.
67*/
68SK_API void sk_paint_set_stroke(sk_paint_t*, bool);
69
70/**
71    Return the width for stroking.  A value of 0 strokes in hairline mode.
72 */
73SK_API float sk_paint_get_stroke_width(const sk_paint_t*);
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 */
78SK_API void sk_paint_set_stroke_width(sk_paint_t*, float width);
79
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*/
84SK_API float sk_paint_get_stroke_miter(const sk_paint_t*);
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*/
90SK_API void sk_paint_set_stroke_miter(sk_paint_t*, float miter);
91
92typedef enum {
93    BUTT_SK_STROKE_CAP,
94    ROUND_SK_STROKE_CAP,
95    SQUARE_SK_STROKE_CAP
96} sk_stroke_cap_t;
97
98/**
99    Return the paint's stroke cap type, controlling how the start and
100    end of stroked lines and paths are treated.
101*/
102SK_API sk_stroke_cap_t sk_paint_get_stroke_cap(const sk_paint_t*);
103/**
104    Set the paint's stroke cap type, controlling how the start and
105    end of stroked lines and paths are treated.
106*/
107SK_API void sk_paint_set_stroke_cap(sk_paint_t*, sk_stroke_cap_t);
108
109typedef enum {
110    MITER_SK_STROKE_JOIN,
111    ROUND_SK_STROKE_JOIN,
112    BEVEL_SK_STROKE_JOIN
113} sk_stroke_join_t;
114
115/**
116    Return the paint's stroke join type, specifies the treatment that
117    is applied to corners in paths and rectangles
118 */
119SK_API sk_stroke_join_t sk_paint_get_stroke_join(const sk_paint_t*);
120/**
121    Set the paint's stroke join type, specifies the treatment that
122    is applied to corners in paths and rectangles
123 */
124SK_API void sk_paint_set_stroke_join(sk_paint_t*, sk_stroke_join_t);
125
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 */
130SK_API void sk_paint_set_shader(sk_paint_t*, sk_shader_t*);
131
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 */
136SK_API void sk_paint_set_maskfilter(sk_paint_t*, sk_maskfilter_t*);
137
138/**
139 *  Set the paint's xfermode to the specified parameter.
140 */
141SK_API void sk_paint_set_xfermode_mode(sk_paint_t*, sk_xfermode_mode_t);
142
143SK_C_PLUS_PLUS_END_GUARD
144
145#endif
146