2968a4eb3a815544e51213dcd31abd50d79e6f87
[platform/upstream/libSkiaSharp.git] / include / c / sk_paint.h
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
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 */
31 SK_API sk_paint_t* sk_paint_new();
32 /**
33     Release the memory storing the sk_paint_t and unref() all
34     associated objects.
35 */
36 SK_API void sk_paint_delete(sk_paint_t*);
37 /**
38     Return true iff the paint has antialiasing enabled.
39 */
40 SK_API bool sk_paint_is_antialias(const sk_paint_t*);
41 /**
42     Set to true to enable antialiasing, false to disable it on this
43     sk_paint_t.
44 */
45 SK_API void sk_paint_set_antialias(sk_paint_t*, bool);
46 /**
47     Return the paint's curent drawing color.
48 */
49 SK_API sk_color_t sk_paint_get_color(const sk_paint_t*);
50 /**
51     Set the paint's curent drawing color.
52 */
53 SK_API void sk_paint_set_color(sk_paint_t*, sk_color_t);
54 /**
55     Return true iff stroking is enabled rather than filling on this
56     sk_paint_t.
57 */
58 SK_API bool sk_paint_is_stroke(const sk_paint_t*);
59 /**
60     Set to true to enable stroking rather than filling with this
61     sk_paint_t.
62 */
63 SK_API void sk_paint_set_stroke(sk_paint_t*, bool);
64 /**
65     Return the width for stroking.  A value of 0 strokes in hairline mode.
66  */
67 SK_API float sk_paint_get_stroke_width(const sk_paint_t*);
68 /**
69    Set the width for stroking.  A value of 0 strokes in hairline mode
70    (always draw 1-pixel wide, regardless of the matrix).
71  */
72 SK_API void sk_paint_set_stroke_width(sk_paint_t*, float width);
73 /**
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.
76 */
77 SK_API float sk_paint_get_stroke_miter(const sk_paint_t*);
78 /**
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
81    must be >= 0.
82 */
83 SK_API void sk_paint_set_stroke_miter(sk_paint_t*, float miter);
84 /**
85     Return the paint's stroke cap type, controlling how the start and
86     end of stroked lines and paths are treated.
87 */
88 SK_API sk_stroke_cap_t sk_paint_get_stroke_cap(const sk_paint_t*);
89 /**
90     Set the paint's stroke cap type, controlling how the start and
91     end of stroked lines and paths are treated.
92 */
93 SK_API void sk_paint_set_stroke_cap(sk_paint_t*, sk_stroke_cap_t);
94 /**
95     Return the paint's stroke join type, specifies the treatment that
96     is applied to corners in paths and rectangles
97  */
98 SK_API sk_stroke_join_t sk_paint_get_stroke_join(const sk_paint_t*);
99 /**
100     Set the paint's stroke join type, specifies the treatment that
101     is applied to corners in paths and rectangles
102  */
103 SK_API void sk_paint_set_stroke_join(sk_paint_t*, sk_stroke_join_t);
104 /**
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.
107  */
108 SK_API void sk_paint_set_shader(sk_paint_t*, sk_shader_t*);
109 /**
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.
112  */
113 SK_API void sk_paint_set_maskfilter(sk_paint_t*, sk_maskfilter_t*);
114 /**
115  *  Set the paint's xfermode to the specified parameter.
116  */
117 SK_API void sk_paint_set_xfermode_mode(sk_paint_t*, sk_xfermode_mode_t);
118 /**
119  *  Return true iff the paint has dithering enabled.
120  */
121 SK_API bool sk_paint_is_dither(const sk_paint_t*);
122 /**
123  *  Set to true to enable dithering, false to disable it on this
124  *  sk_paint_t.
125  */
126 SK_API void sk_paint_set_dither(sk_paint_t*, bool);
127 /**
128  *  Return true iff the paint has verticaltext enabled.
129  */
130 SK_API bool sk_paint_is_verticaltext(const sk_paint_t*);
131 /**
132  *  Set to true to enable verticaltext, false to disable it on this
133  *  sk_paint_t.
134  */
135 SK_API void sk_paint_set_verticaltext(sk_paint_t*, bool);
136 /**
137  *  Get the paint's shader object.
138  */
139 SK_API sk_shader_t* sk_paint_get_shader(sk_paint_t*);
140 /**
141  *  Get the paint's mask filter object.
142  */
143 SK_API sk_maskfilter_t* sk_paint_get_maskfilter(sk_paint_t*);
144 /**
145  *  Set or clear the paint's color filter.
146  */
147 SK_API void sk_paint_set_colorfilter(sk_paint_t*, sk_colorfilter_t*);
148 /**
149  *  Get the paint's color filter object.
150  */
151 SK_API sk_colorfilter_t* sk_paint_get_colorfilter(sk_paint_t*);
152 /**
153  *  Set or clear the paint's image filter.
154  */
155 SK_API void sk_paint_set_imagefilter(sk_paint_t*, sk_imagefilter_t*);
156 /**
157  *  Get the paint's image filter object.
158  */
159 SK_API sk_imagefilter_t* sk_paint_get_imagefilter(sk_paint_t*);
160 /**
161  *  Get the paint's xfermode object.
162  */
163 SK_API sk_xfermode_mode_t sk_paint_get_xfermode_mode(sk_paint_t*);
164 /**
165  *  Set the paint's filter quality.
166  */
167 SK_API void sk_paint_set_filter_quality(sk_paint_t*, sk_filter_quality_t);
168 /**
169  *  Get the paint's filter quality.
170  */
171 SK_API sk_filter_quality_t sk_paint_get_filter_quality(sk_paint_t *);
172 /**
173  *  Get the paint's typeface
174  */
175 SK_API sk_typeface_t* sk_paint_get_typeface(sk_paint_t*);
176 /**
177  *  Set the paint's typeface
178  */
179 SK_API void sk_paint_set_typeface(sk_paint_t*, sk_typeface_t*);
180 /**
181  *  Get the paint's text sixe
182  */
183 SK_API float sk_paint_get_textsize(sk_paint_t*);
184 /**
185  *  Set the paint's text sixe
186  */
187 SK_API void sk_paint_set_textsize(sk_paint_t*, float);
188 /**
189  *  Get the paint's text alignment
190  */
191 SK_API sk_text_align_t sk_paint_get_text_align(const sk_paint_t*);
192 /**
193  *  Set the paint's text alignment
194  */
195 SK_API void sk_paint_set_text_align(sk_paint_t*, sk_text_align_t);
196 /**
197  *  Get the paint's text encoding
198  */
199 SK_API sk_text_encoding_t sk_paint_get_text_encoding(const sk_paint_t*);
200 /**
201  *  Set the paint's text encoding
202  */
203 SK_API void sk_paint_set_text_encoding(sk_paint_t*, sk_text_encoding_t);
204 /**
205  *  Set the paint's horizontal scale factor for text
206  */
207 SK_API float sk_paint_get_text_scale_x(const sk_paint_t* cpaint);
208 /**
209  *  Set the paint's horizontal scale factor for text
210  */
211 SK_API void sk_paint_set_text_scale_x(sk_paint_t* cpaint, float scale);
212 /**
213  *  Set the paint's horizontal skew factor for text
214  */
215 SK_API float sk_paint_get_text_skew_x(const sk_paint_t* cpaint);
216 /**
217  *  Set the paint's horizontal skew factor for text
218  */
219 SK_API void sk_paint_set_text_skew_x(sk_paint_t* cpaint, float skew);
220 /**
221  *  Return the number of bytes of text that were measured
222  */
223 SK_API size_t sk_paint_break_text(const sk_paint_t* cpaint, const void* text, size_t length, float maxWidth, float* measuredWidth);
224 /**
225  *  Return the width of the text
226  */
227 SK_API float sk_paint_measure_text(const sk_paint_t* cpaint, const void* text, size_t length, sk_rect_t* cbounds);
228 /**
229  *  Get the path outline of text.
230  */
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);
232 /**
233  *  Get the path outline of text with each glyph positioned.
234  */
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[]);
236 /**
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.
239  */
240 SK_API float sk_paint_get_fontmetrics(sk_paint_t* cpaint, sk_fontmetrics_t* cfontmetrics, float scale);
241 /**
242  *  Return the paint's patheffect object  
243  */  
244 SK_API sk_path_effect_t* sk_paint_get_path_effect(sk_paint_t* cpaint);
245 /**
246  *  Sets the paint's patheffect object  
247  */  
248 SK_API void sk_paint_set_path_effect(sk_paint_t* cpaint, sk_path_effect_t* effect);  
249
250 SK_C_PLUS_PLUS_END_GUARD
251
252 #endif