2 * Copyright 2014 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 // EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
9 // DO NOT USE -- FOR INTERNAL TESTING ONLY
11 #ifndef sk_paint_DEFINED
12 #define sk_paint_DEFINED
16 SK_C_PLUS_PLUS_BEGIN_GUARD
19 Create a new paint with default settings:
22 stroke width : 0.0f (hairline)
24 stroke cap : BUTT_SK_STROKE_CAP
25 stroke join : MITER_SK_STROKE_JOIN
29 xfermode_mode : SRCOVER_SK_XFERMODE_MODE
31 SK_API sk_paint_t* sk_paint_new();
33 Release the memory storing the sk_paint_t and unref() all
36 SK_API void sk_paint_delete(sk_paint_t*);
38 Return true iff the paint has antialiasing enabled.
40 SK_API bool sk_paint_is_antialias(const sk_paint_t*);
42 Set to true to enable antialiasing, false to disable it on this
45 SK_API void sk_paint_set_antialias(sk_paint_t*, bool);
47 Return the paint's curent drawing color.
49 SK_API sk_color_t sk_paint_get_color(const sk_paint_t*);
51 Set the paint's curent drawing color.
53 SK_API void sk_paint_set_color(sk_paint_t*, sk_color_t);
55 Return true iff stroking is enabled rather than filling on this
58 SK_API bool sk_paint_is_stroke(const sk_paint_t*);
60 Set to true to enable stroking rather than filling with this
63 SK_API void sk_paint_set_stroke(sk_paint_t*, bool);
65 Return the width for stroking. A value of 0 strokes in hairline mode.
67 SK_API float sk_paint_get_stroke_width(const sk_paint_t*);
69 Set the width for stroking. A value of 0 strokes in hairline mode
70 (always draw 1-pixel wide, regardless of the matrix).
72 SK_API void sk_paint_set_stroke_width(sk_paint_t*, float width);
74 Return the paint's stroke miter value. This is used to control the
75 behavior of miter joins when the joins angle is sharp.
77 SK_API float sk_paint_get_stroke_miter(const sk_paint_t*);
79 Set the paint's stroke miter value. This is used to control the
80 behavior of miter joins when the joins angle is sharp. This value
83 SK_API void sk_paint_set_stroke_miter(sk_paint_t*, float miter);
85 Return the paint's stroke cap type, controlling how the start and
86 end of stroked lines and paths are treated.
88 SK_API sk_stroke_cap_t sk_paint_get_stroke_cap(const sk_paint_t*);
90 Set the paint's stroke cap type, controlling how the start and
91 end of stroked lines and paths are treated.
93 SK_API void sk_paint_set_stroke_cap(sk_paint_t*, sk_stroke_cap_t);
95 Return the paint's stroke join type, specifies the treatment that
96 is applied to corners in paths and rectangles
98 SK_API sk_stroke_join_t sk_paint_get_stroke_join(const sk_paint_t*);
100 Set the paint's stroke join type, specifies the treatment that
101 is applied to corners in paths and rectangles
103 SK_API void sk_paint_set_stroke_join(sk_paint_t*, sk_stroke_join_t);
105 * Set the paint's shader to the specified parameter. This will automatically call unref() on
106 * any previous value, and call ref() on the new value.
108 SK_API void sk_paint_set_shader(sk_paint_t*, sk_shader_t*);
110 * Set the paint's maskfilter to the specified parameter. This will automatically call unref() on
111 * any previous value, and call ref() on the new value.
113 SK_API void sk_paint_set_maskfilter(sk_paint_t*, sk_maskfilter_t*);
115 * Set the paint's xfermode to the specified parameter.
117 SK_API void sk_paint_set_xfermode_mode(sk_paint_t*, sk_xfermode_mode_t);
119 * Return true iff the paint has dithering enabled.
121 SK_API bool sk_paint_is_dither(const sk_paint_t*);
123 * Set to true to enable dithering, false to disable it on this
126 SK_API void sk_paint_set_dither(sk_paint_t*, bool);
128 * Return true iff the paint has verticaltext enabled.
130 SK_API bool sk_paint_is_verticaltext(const sk_paint_t*);
132 * Set to true to enable verticaltext, false to disable it on this
135 SK_API void sk_paint_set_verticaltext(sk_paint_t*, bool);
137 * Get the paint's shader object.
139 SK_API sk_shader_t* sk_paint_get_shader(sk_paint_t*);
141 * Get the paint's mask filter object.
143 SK_API sk_maskfilter_t* sk_paint_get_maskfilter(sk_paint_t*);
145 * Set or clear the paint's color filter.
147 SK_API void sk_paint_set_colorfilter(sk_paint_t*, sk_colorfilter_t*);
149 * Get the paint's color filter object.
151 SK_API sk_colorfilter_t* sk_paint_get_colorfilter(sk_paint_t*);
153 * Set or clear the paint's image filter.
155 SK_API void sk_paint_set_imagefilter(sk_paint_t*, sk_imagefilter_t*);
157 * Get the paint's image filter object.
159 SK_API sk_imagefilter_t* sk_paint_get_imagefilter(sk_paint_t*);
161 * Get the paint's xfermode object.
163 SK_API sk_xfermode_mode_t sk_paint_get_xfermode_mode(sk_paint_t*);
165 * Set the paint's filter quality.
167 SK_API void sk_paint_set_filter_quality(sk_paint_t*, sk_filter_quality_t);
169 * Get the paint's filter quality.
171 SK_API sk_filter_quality_t sk_paint_get_filter_quality(sk_paint_t *);
173 * Get the paint's typeface
175 SK_API sk_typeface_t* sk_paint_get_typeface(sk_paint_t*);
177 * Set the paint's typeface
179 SK_API void sk_paint_set_typeface(sk_paint_t*, sk_typeface_t*);
181 * Get the paint's text sixe
183 SK_API float sk_paint_get_textsize(sk_paint_t*);
185 * Set the paint's text sixe
187 SK_API void sk_paint_set_textsize(sk_paint_t*, float);
189 * Get the paint's text alignment
191 SK_API sk_text_align_t sk_paint_get_text_align(const sk_paint_t*);
193 * Set the paint's text alignment
195 SK_API void sk_paint_set_text_align(sk_paint_t*, sk_text_align_t);
197 * Get the paint's text encoding
199 SK_API sk_text_encoding_t sk_paint_get_text_encoding(const sk_paint_t*);
201 * Set the paint's text encoding
203 SK_API void sk_paint_set_text_encoding(sk_paint_t*, sk_text_encoding_t);
205 * Set the paint's horizontal scale factor for text
207 SK_API float sk_paint_get_text_scale_x(const sk_paint_t* cpaint);
209 * Set the paint's horizontal scale factor for text
211 SK_API void sk_paint_set_text_scale_x(sk_paint_t* cpaint, float scale);
213 * Set the paint's horizontal skew factor for text
215 SK_API float sk_paint_get_text_skew_x(const sk_paint_t* cpaint);
217 * Set the paint's horizontal skew factor for text
219 SK_API void sk_paint_set_text_skew_x(sk_paint_t* cpaint, float skew);
221 * Return the number of bytes of text that were measured
223 SK_API size_t sk_paint_break_text(const sk_paint_t* cpaint, const void* text, size_t length, float maxWidth, float* measuredWidth);
225 * Return the width of the text
227 SK_API float sk_paint_measure_text(const sk_paint_t* cpaint, const void* text, size_t length, sk_rect_t* cbounds);
229 * Get the path outline of text.
231 SK_API sk_path_t* sk_paint_get_text_path(sk_paint_t* cpaint, const void* text, size_t length, float x, float y);
233 * Get the path outline of text with each glyph positioned.
235 SK_API sk_path_t* sk_paint_get_pos_text_path(sk_paint_t* cpaint, const void* text, size_t length, const sk_point_t pos[]);
237 * Return the recommend spacing between lines (which will be fDescent - fAscent + fLeading).
238 * Also get the font metrics for the current typeface and type size if cfontmetrics is not null.
240 SK_API float sk_paint_get_fontmetrics(sk_paint_t* cpaint, sk_fontmetrics_t* cfontmetrics, float scale);
242 * Return the paint's patheffect object
244 SK_API sk_path_effect_t* sk_paint_get_path_effect(sk_paint_t* cpaint);
246 * Sets the paint's patheffect object
248 SK_API void sk_paint_set_path_effect(sk_paint_t* cpaint, sk_path_effect_t* effect);
250 SK_C_PLUS_PLUS_END_GUARD