blob: ef7e624aa500f5022285eb784692e41a03d9079f [file] [log] [blame]
reed73c25012014-11-17 06:15:42 -08001/*
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
halcanaryc9119062015-09-01 10:45:09 -070018/**
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 Salomon75518982016-12-28 15:56:16 -050031SK_API sk_paint_t* sk_paint_new(void);
halcanaryc9119062015-09-01 10:45:09 -070032/**
33 Release the memory storing the sk_paint_t and unref() all
34 associated objects.
35*/
halcanary219f18f2015-09-01 10:01:38 -070036SK_API void sk_paint_delete(sk_paint_t*);
reedafa278e2014-11-24 19:11:48 -080037
halcanaryc9119062015-09-01 10:45:09 -070038/**
39 Return true iff the paint has antialiasing enabled.
40*/
halcanary219f18f2015-09-01 10:01:38 -070041SK_API bool sk_paint_is_antialias(const sk_paint_t*);
halcanaryc9119062015-09-01 10:45:09 -070042/**
43 Set to true to enable antialiasing, false to disable it on this
44 sk_paint_t.
45*/
halcanary219f18f2015-09-01 10:01:38 -070046SK_API void sk_paint_set_antialias(sk_paint_t*, bool);
reedafa278e2014-11-24 19:11:48 -080047
halcanaryc9119062015-09-01 10:45:09 -070048/**
49 Return the paint's curent drawing color.
50*/
halcanary219f18f2015-09-01 10:01:38 -070051SK_API sk_color_t sk_paint_get_color(const sk_paint_t*);
halcanaryc9119062015-09-01 10:45:09 -070052/**
53 Set the paint's curent drawing color.
54*/
halcanary219f18f2015-09-01 10:01:38 -070055SK_API void sk_paint_set_color(sk_paint_t*, sk_color_t);
reed73c25012014-11-17 06:15:42 -080056
reedf5872d22015-01-10 17:59:31 -080057/* stroke settings */
58
halcanaryc9119062015-09-01 10:45:09 -070059/**
60 Return true iff stroking is enabled rather than filling on this
61 sk_paint_t.
62*/
halcanary219f18f2015-09-01 10:01:38 -070063SK_API bool sk_paint_is_stroke(const sk_paint_t*);
halcanaryc9119062015-09-01 10:45:09 -070064/**
65 Set to true to enable stroking rather than filling with this
66 sk_paint_t.
67*/
halcanary219f18f2015-09-01 10:01:38 -070068SK_API void sk_paint_set_stroke(sk_paint_t*, bool);
reedf5872d22015-01-10 17:59:31 -080069
halcanaryc9119062015-09-01 10:45:09 -070070/**
71 Return the width for stroking. A value of 0 strokes in hairline mode.
72 */
halcanary219f18f2015-09-01 10:01:38 -070073SK_API float sk_paint_get_stroke_width(const sk_paint_t*);
halcanaryc9119062015-09-01 10:45:09 -070074/**
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 */
halcanary219f18f2015-09-01 10:01:38 -070078SK_API void sk_paint_set_stroke_width(sk_paint_t*, float width);
reedf5872d22015-01-10 17:59:31 -080079
halcanaryc9119062015-09-01 10:45:09 -070080/**
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*/
halcanary219f18f2015-09-01 10:01:38 -070084SK_API float sk_paint_get_stroke_miter(const sk_paint_t*);
halcanaryc9119062015-09-01 10:45:09 -070085/**
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*/
halcanary219f18f2015-09-01 10:01:38 -070090SK_API void sk_paint_set_stroke_miter(sk_paint_t*, float miter);
reedf5872d22015-01-10 17:59:31 -080091
92typedef enum {
93 BUTT_SK_STROKE_CAP,
94 ROUND_SK_STROKE_CAP,
95 SQUARE_SK_STROKE_CAP
96} sk_stroke_cap_t;
97
halcanaryc9119062015-09-01 10:45:09 -070098/**
99 Return the paint's stroke cap type, controlling how the start and
100 end of stroked lines and paths are treated.
101*/
halcanary219f18f2015-09-01 10:01:38 -0700102SK_API sk_stroke_cap_t sk_paint_get_stroke_cap(const sk_paint_t*);
halcanaryc9119062015-09-01 10:45:09 -0700103/**
104 Set the paint's stroke cap type, controlling how the start and
105 end of stroked lines and paths are treated.
106*/
halcanary219f18f2015-09-01 10:01:38 -0700107SK_API void sk_paint_set_stroke_cap(sk_paint_t*, sk_stroke_cap_t);
reedf5872d22015-01-10 17:59:31 -0800108
109typedef enum {
110 MITER_SK_STROKE_JOIN,
111 ROUND_SK_STROKE_JOIN,
112 BEVEL_SK_STROKE_JOIN
113} sk_stroke_join_t;
114
halcanaryc9119062015-09-01 10:45:09 -0700115/**
116 Return the paint's stroke join type, specifies the treatment that
117 is applied to corners in paths and rectangles
118 */
halcanary219f18f2015-09-01 10:01:38 -0700119SK_API sk_stroke_join_t sk_paint_get_stroke_join(const sk_paint_t*);
halcanaryc9119062015-09-01 10:45:09 -0700120/**
121 Set the paint's stroke join type, specifies the treatment that
122 is applied to corners in paths and rectangles
123 */
halcanary219f18f2015-09-01 10:01:38 -0700124SK_API void sk_paint_set_stroke_join(sk_paint_t*, sk_stroke_join_t);
reedf5872d22015-01-10 17:59:31 -0800125
reedafa278e2014-11-24 19:11:48 -0800126/**
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 */
halcanary219f18f2015-09-01 10:01:38 -0700130SK_API void sk_paint_set_shader(sk_paint_t*, sk_shader_t*);
reedafa278e2014-11-24 19:11:48 -0800131
reed0eafc9b2014-12-23 14:11:11 -0800132/**
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 */
halcanary219f18f2015-09-01 10:01:38 -0700136SK_API void sk_paint_set_maskfilter(sk_paint_t*, sk_maskfilter_t*);
reed0eafc9b2014-12-23 14:11:11 -0800137
halcanary7568d0b2015-07-31 13:38:06 -0700138/**
139 * Set the paint's xfermode to the specified parameter.
140 */
halcanary219f18f2015-09-01 10:01:38 -0700141SK_API void sk_paint_set_xfermode_mode(sk_paint_t*, sk_xfermode_mode_t);
halcanary7568d0b2015-07-31 13:38:06 -0700142
reed73c25012014-11-17 06:15:42 -0800143SK_C_PLUS_PLUS_END_GUARD
144
145#endif