OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkGradientShader_DEFINED | 8 #ifndef SkGradientShader_DEFINED |
9 #define SkGradientShader_DEFINED | 9 #define SkGradientShader_DEFINED |
10 | 10 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 const SkColor colors[], const SkScalar pos[],
int count, | 46 const SkColor colors[], const SkScalar pos[],
int count, |
47 SkShader::TileMode mode, | 47 SkShader::TileMode mode, |
48 uint32_t flags, const SkMatrix* localMatrix); | 48 uint32_t flags, const SkMatrix* localMatrix); |
49 | 49 |
50 static SkShader* CreateLinear(const SkPoint pts[2], | 50 static SkShader* CreateLinear(const SkPoint pts[2], |
51 const SkColor colors[], const SkScalar pos[],
int count, | 51 const SkColor colors[], const SkScalar pos[],
int count, |
52 SkShader::TileMode mode) { | 52 SkShader::TileMode mode) { |
53 return CreateLinear(pts, colors, pos, count, mode, 0, NULL); | 53 return CreateLinear(pts, colors, pos, count, mode, 0, NULL); |
54 } | 54 } |
55 | 55 |
56 #ifdef SK_SUPPORT_LEGACY_GRADIENT_FACTORIES | |
57 static SkShader* CreateLinear(const SkPoint pts[2], | |
58 const SkColor colors[], const SkScalar pos[],
int count, | |
59 SkShader::TileMode mode, void* /*ignored*/, | |
60 uint32_t flags, const SkMatrix* localMatrix) { | |
61 return CreateLinear(pts, colors, pos, count, mode, flags, localMatrix); | |
62 } | |
63 #endif | |
64 | |
65 /** Returns a shader that generates a radial gradient given the center and r
adius. | 56 /** Returns a shader that generates a radial gradient given the center and r
adius. |
66 <p /> | 57 <p /> |
67 CreateRadial returns a shader with a reference count of 1. | 58 CreateRadial returns a shader with a reference count of 1. |
68 The caller should decrement the shader's reference count when done with
the shader. | 59 The caller should decrement the shader's reference count when done with
the shader. |
69 It is an error for colorCount to be < 2, or for radius to be <= 0. | 60 It is an error for colorCount to be < 2, or for radius to be <= 0. |
70 @param center The center of the circle for this gradient | 61 @param center The center of the circle for this gradient |
71 @param radius Must be positive. The radius of the circle for this grad
ient | 62 @param radius Must be positive. The radius of the circle for this grad
ient |
72 @param colors The array[count] of colors, to be distributed between th
e center and edge of the circle | 63 @param colors The array[count] of colors, to be distributed between th
e center and edge of the circle |
73 @param pos May be NULL. The array[count] of SkScalars, or NULL, of
the relative position of | 64 @param pos May be NULL. The array[count] of SkScalars, or NULL, of
the relative position of |
74 each corresponding color in the colors array. If this is
NULL, | 65 each corresponding color in the colors array. If this is
NULL, |
75 the the colors are distributed evenly between the center
and edge of the circle. | 66 the the colors are distributed evenly between the center
and edge of the circle. |
76 If this is not null, the values must begin with 0, end w
ith 1.0, and | 67 If this is not null, the values must begin with 0, end w
ith 1.0, and |
77 intermediate values must be strictly increasing. | 68 intermediate values must be strictly increasing. |
78 @param count Must be >= 2. The number of colors (and pos if not NULL)
entries | 69 @param count Must be >= 2. The number of colors (and pos if not NULL)
entries |
79 @param mode The tiling mode | 70 @param mode The tiling mode |
80 */ | 71 */ |
81 static SkShader* CreateRadial(const SkPoint& center, SkScalar radius, | 72 static SkShader* CreateRadial(const SkPoint& center, SkScalar radius, |
82 const SkColor colors[], const SkScalar pos[],
int count, | 73 const SkColor colors[], const SkScalar pos[],
int count, |
83 SkShader::TileMode mode, | 74 SkShader::TileMode mode, |
84 uint32_t flags, const SkMatrix* localMatrix); | 75 uint32_t flags, const SkMatrix* localMatrix); |
85 | 76 |
86 static SkShader* CreateRadial(const SkPoint& center, SkScalar radius, | 77 static SkShader* CreateRadial(const SkPoint& center, SkScalar radius, |
87 const SkColor colors[], const SkScalar pos[],
int count, | 78 const SkColor colors[], const SkScalar pos[],
int count, |
88 SkShader::TileMode mode) { | 79 SkShader::TileMode mode) { |
89 return CreateRadial(center, radius, colors, pos, count, mode, 0, NULL); | 80 return CreateRadial(center, radius, colors, pos, count, mode, 0, NULL); |
90 } | 81 } |
91 | 82 |
92 #ifdef SK_SUPPORT_LEGACY_GRADIENT_FACTORIES | |
93 static SkShader* CreateRadial(const SkPoint& center, SkScalar radius, | |
94 const SkColor colors[], const SkScalar pos[],
int count, | |
95 SkShader::TileMode mode, void* /*ignored*/, | |
96 uint32_t flags, const SkMatrix* localMatrix) { | |
97 return CreateRadial(center, radius, colors, pos, count, mode, flags, loc
alMatrix); | |
98 } | |
99 #endif | |
100 | |
101 /** Returns a shader that generates a radial gradient given the start positi
on, start radius, end position and end radius. | 83 /** Returns a shader that generates a radial gradient given the start positi
on, start radius, end position and end radius. |
102 <p /> | 84 <p /> |
103 CreateTwoPointRadial returns a shader with a reference count of 1. | 85 CreateTwoPointRadial returns a shader with a reference count of 1. |
104 The caller should decrement the shader's reference count when done with
the shader. | 86 The caller should decrement the shader's reference count when done with
the shader. |
105 It is an error for colorCount to be < 2, for startRadius or endRadius to
be < 0, or for | 87 It is an error for colorCount to be < 2, for startRadius or endRadius to
be < 0, or for |
106 startRadius to be equal to endRadius. | 88 startRadius to be equal to endRadius. |
107 @param start The center of the start circle for this gradient | 89 @param start The center of the start circle for this gradient |
108 @param startRadius Must be positive. The radius of the start circle f
or this gradient. | 90 @param startRadius Must be positive. The radius of the start circle f
or this gradient. |
109 @param end The center of the end circle for this gradient | 91 @param end The center of the end circle for this gradient |
110 @param endRadius Must be positive. The radius of the end circle for th
is gradient. | 92 @param endRadius Must be positive. The radius of the end circle for th
is gradient. |
(...skipping 13 matching lines...) Expand all Loading... |
124 uint32_t flags, const SkMatrix* localM
atrix); | 106 uint32_t flags, const SkMatrix* localM
atrix); |
125 | 107 |
126 static SkShader* CreateTwoPointRadial(const SkPoint& start, SkScalar startRa
dius, | 108 static SkShader* CreateTwoPointRadial(const SkPoint& start, SkScalar startRa
dius, |
127 const SkPoint& end, SkScalar endRadius
, | 109 const SkPoint& end, SkScalar endRadius
, |
128 const SkColor colors[], const SkScalar
pos[], int count, | 110 const SkColor colors[], const SkScalar
pos[], int count, |
129 SkShader::TileMode mode) { | 111 SkShader::TileMode mode) { |
130 return CreateTwoPointRadial(start, startRadius, end, endRadius, colors,
pos, count, mode, | 112 return CreateTwoPointRadial(start, startRadius, end, endRadius, colors,
pos, count, mode, |
131 0, NULL); | 113 0, NULL); |
132 } | 114 } |
133 | 115 |
134 #ifdef SK_SUPPORT_LEGACY_GRADIENT_FACTORIES | |
135 static SkShader* CreateTwoPointRadial(const SkPoint& start, SkScalar startRa
dius, | |
136 const SkPoint& end, SkScalar endRadius
, | |
137 const SkColor colors[], const SkScalar
pos[], int count, | |
138 SkShader::TileMode mode, void* /*ignor
ed*/, | |
139 uint32_t flags, const SkMatrix* localM
atrix) { | |
140 return CreateTwoPointRadial(start, startRadius, end, endRadius, colors,
pos, count, mode, | |
141 flags, localMatrix); | |
142 } | |
143 #endif | |
144 | |
145 /** | 116 /** |
146 * Returns a shader that generates a conical gradient given two circles, or | 117 * Returns a shader that generates a conical gradient given two circles, or |
147 * returns NULL if the inputs are invalid. The gradient interprets the | 118 * returns NULL if the inputs are invalid. The gradient interprets the |
148 * two circles according to the following HTML spec. | 119 * two circles according to the following HTML spec. |
149 * http://dev.w3.org/html5/2dcontext/#dom-context-2d-createradialgradient | 120 * http://dev.w3.org/html5/2dcontext/#dom-context-2d-createradialgradient |
150 */ | 121 */ |
151 static SkShader* CreateTwoPointConical(const SkPoint& start, SkScalar startR
adius, | 122 static SkShader* CreateTwoPointConical(const SkPoint& start, SkScalar startR
adius, |
152 const SkPoint& end, SkScalar endRadiu
s, | 123 const SkPoint& end, SkScalar endRadiu
s, |
153 const SkColor colors[], const SkScala
r pos[], int count, | 124 const SkColor colors[], const SkScala
r pos[], int count, |
154 SkShader::TileMode mode, | 125 SkShader::TileMode mode, |
155 uint32_t flags, const SkMatrix* local
Matrix); | 126 uint32_t flags, const SkMatrix* local
Matrix); |
156 | 127 |
157 static SkShader* CreateTwoPointConical(const SkPoint& start, SkScalar startR
adius, | 128 static SkShader* CreateTwoPointConical(const SkPoint& start, SkScalar startR
adius, |
158 const SkPoint& end, SkScalar endRadiu
s, | 129 const SkPoint& end, SkScalar endRadiu
s, |
159 const SkColor colors[], const SkScala
r pos[], int count, | 130 const SkColor colors[], const SkScala
r pos[], int count, |
160 SkShader::TileMode mode) { | 131 SkShader::TileMode mode) { |
161 return CreateTwoPointConical(start, startRadius, end, endRadius, colors,
pos, count, mode, | 132 return CreateTwoPointConical(start, startRadius, end, endRadius, colors,
pos, count, mode, |
162 0, NULL); | 133 0, NULL); |
163 } | 134 } |
164 | 135 |
165 #ifdef SK_SUPPORT_LEGACY_GRADIENT_FACTORIES | |
166 static SkShader* CreateTwoPointConical(const SkPoint& start, SkScalar startR
adius, | |
167 const SkPoint& end, SkScalar endRadiu
s, | |
168 const SkColor colors[], const SkScala
r pos[], int count, | |
169 SkShader::TileMode mode, void* /*igno
red*/, | |
170 uint32_t flags, const SkMatrix* local
Matrix) { | |
171 return CreateTwoPointConical(start, startRadius, end, endRadius, colors,
pos, count, mode, | |
172 flags, localMatrix); | |
173 } | |
174 #endif | |
175 | |
176 /** Returns a shader that generates a sweep gradient given a center. | 136 /** Returns a shader that generates a sweep gradient given a center. |
177 <p /> | 137 <p /> |
178 CreateSweep returns a shader with a reference count of 1. | 138 CreateSweep returns a shader with a reference count of 1. |
179 The caller should decrement the shader's reference count when done with
the shader. | 139 The caller should decrement the shader's reference count when done with
the shader. |
180 It is an error for colorCount to be < 2. | 140 It is an error for colorCount to be < 2. |
181 @param cx The X coordinate of the center of the sweep | 141 @param cx The X coordinate of the center of the sweep |
182 @param cx The Y coordinate of the center of the sweep | 142 @param cx The Y coordinate of the center of the sweep |
183 @param colors The array[count] of colors, to be distributed around the
center. | 143 @param colors The array[count] of colors, to be distributed around the
center. |
184 @param pos May be NULL. The array[count] of SkScalars, or NULL, of
the relative position of | 144 @param pos May be NULL. The array[count] of SkScalars, or NULL, of
the relative position of |
185 each corresponding color in the colors array. If this is
NULL, | 145 each corresponding color in the colors array. If this is
NULL, |
186 the the colors are distributed evenly between the center
and edge of the circle. | 146 the the colors are distributed evenly between the center
and edge of the circle. |
187 If this is not null, the values must begin with 0, end w
ith 1.0, and | 147 If this is not null, the values must begin with 0, end w
ith 1.0, and |
188 intermediate values must be strictly increasing. | 148 intermediate values must be strictly increasing. |
189 @param count Must be >= 2. The number of colors (and pos if not NULL)
entries | 149 @param count Must be >= 2. The number of colors (and pos if not NULL)
entries |
190 */ | 150 */ |
191 static SkShader* CreateSweep(SkScalar cx, SkScalar cy, | 151 static SkShader* CreateSweep(SkScalar cx, SkScalar cy, |
192 const SkColor colors[], const SkScalar pos[], i
nt count, | 152 const SkColor colors[], const SkScalar pos[], i
nt count, |
193 uint32_t flags, const SkMatrix* localMatrix); | 153 uint32_t flags, const SkMatrix* localMatrix); |
194 | 154 |
195 static SkShader* CreateSweep(SkScalar cx, SkScalar cy, | 155 static SkShader* CreateSweep(SkScalar cx, SkScalar cy, |
196 const SkColor colors[], const SkScalar pos[], i
nt count) { | 156 const SkColor colors[], const SkScalar pos[], i
nt count) { |
197 return CreateSweep(cx, cy, colors, pos, count, 0, NULL); | 157 return CreateSweep(cx, cy, colors, pos, count, 0, NULL); |
198 } | 158 } |
199 | 159 |
200 #ifdef SK_SUPPORT_LEGACY_GRADIENT_FACTORIES | |
201 static SkShader* CreateSweep(SkScalar cx, SkScalar cy, | |
202 const SkColor colors[], const SkScalar pos[], i
nt count, | |
203 void* /*ignored*/, | |
204 uint32_t flags, const SkMatrix* localMatrix) { | |
205 return CreateSweep(cx, cy, colors, pos, count, flags, localMatrix); | |
206 } | |
207 #endif | |
208 | |
209 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() | 160 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() |
210 }; | 161 }; |
211 | 162 |
212 #endif | 163 #endif |
OLD | NEW |