blob: 702cda7fd454c0b9d84a63ee9ee3db68d41cdc47 [file] [log] [blame]
reedafa278e2014-11-24 19:11:48 -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_shader_DEFINED
12#define sk_shader_DEFINED
13
14#include "sk_types.h"
15
16SK_C_PLUS_PLUS_BEGIN_GUARD
17
18void sk_shader_ref(sk_shader_t*);
19void sk_shader_unref(sk_shader_t*);
20
21typedef enum {
22 CLAMP_SK_SHADER_TILEMODE,
23 REPEAT_SK_SHADER_TILEMODE,
24 MIRROR_SK_SHADER_TILEMODE,
25} sk_shader_tilemode_t;
26
halcanary65cc3e42015-08-12 07:37:34 -070027/**
28 Returns a shader that generates a linear gradient between the two
29 specified points.
30
31 @param points The start and end points for the gradient.
32 @param colors The array[count] of colors, to be distributed between
33 the two points
34 @param colorPos May be NULL. array[count] of SkScalars, or NULL, of
35 the relative position of each corresponding color
36 in the colors array. If this is NULL, the the
37 colors are distributed evenly between the start
38 and end point. If this is not null, the values
39 must begin with 0, end with 1.0, and intermediate
40 values must be strictly increasing.
41 @param colorCount Must be >=2. The number of colors (and pos if not
42 NULL) entries.
43 @param mode The tiling mode
44*/
45sk_shader_t* sk_shader_new_linear_gradient(const sk_point_t points[2],
reedafa278e2014-11-24 19:11:48 -080046 const sk_color_t colors[],
47 const float colorPos[],
48 int colorCount,
49 sk_shader_tilemode_t tileMode,
50 const sk_matrix_t* localMatrix);
51
52
halcanary65cc3e42015-08-12 07:37:34 -070053/**
54 Returns a shader that generates a radial gradient given the center
55 and radius.
56
57 @param center The center of the circle for this gradient
58 @param radius Must be positive. The radius of the circle for this
59 gradient
60 @param colors The array[count] of colors, to be distributed
61 between the center and edge of the circle
62 @param colorPos May be NULL. The array[count] of the relative
63 position of each corresponding color in the colors
64 array. If this is NULL, the the colors are
65 distributed evenly between the center and edge of
66 the circle. If this is not null, the values must
67 begin with 0, end with 1.0, and intermediate
68 values must be strictly increasing.
69 @param count Must be >= 2. The number of colors (and pos if not
70 NULL) entries
71 @param tileMode The tiling mode
72 @param localMatrix May be NULL
73*/
74sk_shader_t* sk_shader_new_radial_gradient(const sk_point_t* center,
75 float radius,
76 const sk_color_t colors[],
77 const float colorPos[],
78 int colorCount,
79 sk_shader_tilemode_t tileMode,
80 const sk_matrix_t* localMatrix);
81
82/**
83 Returns a shader that generates a sweep gradient given a center.
84
85 @param center The coordinates of the center of the sweep
86 @param colors The array[count] of colors, to be distributed around
87 the center.
88 @param colorPos May be NULL. The array[count] of the relative
89 position of each corresponding color in the colors
90 array. If this is NULL, the the colors are
91 distributed evenly between the center and edge of
92 the circle. If this is not null, the values must
93 begin with 0, end with 1.0, and intermediate
94 values must be strictly increasing.
95 @param colorCount Must be >= 2. The number of colors (and pos if
96 not NULL) entries
97 @param localMatrix May be NULL
98*/
99sk_shader_t* sk_shader_new_sweep_gradient(const sk_point_t* center,
100 const sk_color_t colors[],
101 const float colorPos[],
102 int colorCount,
103 const sk_matrix_t* localMatrix);
104
105/**
106 Returns a shader that generates a conical gradient given two circles, or
107 returns NULL if the inputs are invalid. The gradient interprets the
108 two circles according to the following HTML spec.
109 http://dev.w3.org/html5/2dcontext/#dom-context-2d-createradialgradient
110
111 Returns a shader that generates a sweep gradient given a center.
112
113 @param start, startRadius Defines the first circle.
114 @param end, endRadius Defines the first circle.
115 @param colors The array[count] of colors, to be distributed between
116 the two circles.
117 @param colorPos May be NULL. The array[count] of the relative
118 position of each corresponding color in the colors
119 array. If this is NULL, the the colors are
120 distributed evenly between the two circles. If
121 this is not null, the values must begin with 0,
122 end with 1.0, and intermediate values must be
123 strictly increasing.
124 @param colorCount Must be >= 2. The number of colors (and pos if
125 not NULL) entries
126 @param tileMode The tiling mode
127 @param localMatrix May be NULL
128
129*/
130sk_shader_t* sk_shader_new_two_point_conical_gradient(
131 const sk_point_t* start,
132 float startRadius,
133 const sk_point_t* end,
134 float endRadius,
135 const sk_color_t colors[],
136 const float colorPos[],
137 int colorCount,
138 sk_shader_tilemode_t tileMode,
139 const sk_matrix_t* localMatrix);
140
reedafa278e2014-11-24 19:11:48 -0800141SK_C_PLUS_PLUS_END_GUARD
142
143#endif