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 30 matching lines...) Expand all Loading... |
41 static sk_sp<SkShader> MakeLinear(const SkPoint pts[2], | 41 static sk_sp<SkShader> MakeLinear(const SkPoint pts[2], |
42 const SkColor colors[], const SkScalar pos
[], int count, | 42 const SkColor colors[], const SkScalar pos
[], int count, |
43 SkShader::TileMode mode, | 43 SkShader::TileMode mode, |
44 uint32_t flags, const SkMatrix* localMatri
x); | 44 uint32_t flags, const SkMatrix* localMatri
x); |
45 static sk_sp<SkShader> MakeLinear(const SkPoint pts[2], | 45 static sk_sp<SkShader> MakeLinear(const SkPoint pts[2], |
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 return MakeLinear(pts, colors, pos, count, mode, 0, NULL); | 48 return MakeLinear(pts, colors, pos, count, mode, 0, NULL); |
49 } | 49 } |
50 | 50 |
| 51 /** Returns a shader that generates a linear gradient between the two specif
ied points. |
| 52 <p /> |
| 53 @param pts The start and end points for the gradient. |
| 54 @param colors The array[count] of colors, to be distributed between th
e two points |
| 55 @param pos May be NULL. array[count] of SkScalars, or NULL, of the
relative position of |
| 56 each corresponding color in the colors array. If this is
NULL, |
| 57 the the colors are distributed evenly between the start
and end point. |
| 58 If this is not null, the values must begin with 0, end w
ith 1.0, and |
| 59 intermediate values must be strictly increasing. |
| 60 @param count Must be >=2. The number of colors (and pos if not NULL)
entries. |
| 61 @param mode The tiling mode |
| 62 */ |
| 63 static sk_sp<SkShader> MakeLinear(const SkPoint pts[2], |
| 64 const SkColor4f colors[], sk_sp<SkColorSpa
ce> colorSpace, |
| 65 const SkScalar pos[], int count, SkShader:
:TileMode mode, |
| 66 uint32_t flags, const SkMatrix* localMatri
x); |
| 67 static sk_sp<SkShader> MakeLinear(const SkPoint pts[2], |
| 68 const SkColor4f colors[], sk_sp<SkColorSpa
ce> colorSpace, |
| 69 const SkScalar pos[], int count, SkShader:
:TileMode mode) { |
| 70 return MakeLinear(pts, colors, std::move(colorSpace), pos, count, mode,
0, NULL); |
| 71 } |
| 72 |
51 /** Returns a shader that generates a radial gradient given the center and r
adius. | 73 /** Returns a shader that generates a radial gradient given the center and r
adius. |
52 <p /> | 74 <p /> |
53 @param center The center of the circle for this gradient | 75 @param center The center of the circle for this gradient |
54 @param radius Must be positive. The radius of the circle for this grad
ient | 76 @param radius Must be positive. The radius of the circle for this grad
ient |
55 @param colors The array[count] of colors, to be distributed between th
e center and edge of the circle | 77 @param colors The array[count] of colors, to be distributed between th
e center and edge of the circle |
56 @param pos May be NULL. The array[count] of SkScalars, or NULL, of
the relative position of | 78 @param pos May be NULL. The array[count] of SkScalars, or NULL, of
the relative position of |
57 each corresponding color in the colors array. If this is
NULL, | 79 each corresponding color in the colors array. If this is
NULL, |
58 the the colors are distributed evenly between the center
and edge of the circle. | 80 the the colors are distributed evenly between the center
and edge of the circle. |
59 If this is not null, the values must begin with 0, end w
ith 1.0, and | 81 If this is not null, the values must begin with 0, end w
ith 1.0, and |
60 intermediate values must be strictly increasing. | 82 intermediate values must be strictly increasing. |
61 @param count Must be >= 2. The number of colors (and pos if not NULL)
entries | 83 @param count Must be >= 2. The number of colors (and pos if not NULL)
entries |
62 @param mode The tiling mode | 84 @param mode The tiling mode |
63 */ | 85 */ |
64 static sk_sp<SkShader> MakeRadial(const SkPoint& center, SkScalar radius, | 86 static sk_sp<SkShader> MakeRadial(const SkPoint& center, SkScalar radius, |
65 const SkColor colors[], const SkScalar pos
[], int count, | 87 const SkColor colors[], const SkScalar pos
[], int count, |
66 SkShader::TileMode mode, | 88 SkShader::TileMode mode, |
67 uint32_t flags, const SkMatrix* localMatri
x); | 89 uint32_t flags, const SkMatrix* localMatri
x); |
68 static sk_sp<SkShader> MakeRadial(const SkPoint& center, SkScalar radius, | 90 static sk_sp<SkShader> MakeRadial(const SkPoint& center, SkScalar radius, |
69 const SkColor colors[], const SkScalar pos
[], int count, | 91 const SkColor colors[], const SkScalar pos
[], int count, |
70 SkShader::TileMode mode) { | 92 SkShader::TileMode mode) { |
71 return MakeRadial(center, radius, colors, pos, count, mode, 0, NULL); | 93 return MakeRadial(center, radius, colors, pos, count, mode, 0, NULL); |
72 } | 94 } |
73 | 95 |
| 96 /** Returns a shader that generates a radial gradient given the center and r
adius. |
| 97 <p /> |
| 98 @param center The center of the circle for this gradient |
| 99 @param radius Must be positive. The radius of the circle for this grad
ient |
| 100 @param colors The array[count] of colors, to be distributed between th
e center and edge of the circle |
| 101 @param pos May be NULL. The array[count] of SkScalars, or NULL, of
the relative position of |
| 102 each corresponding color in the colors array. If this is
NULL, |
| 103 the the colors are distributed evenly between the center
and edge of the circle. |
| 104 If this is not null, the values must begin with 0, end w
ith 1.0, and |
| 105 intermediate values must be strictly increasing. |
| 106 @param count Must be >= 2. The number of colors (and pos if not NULL)
entries |
| 107 @param mode The tiling mode |
| 108 */ |
| 109 static sk_sp<SkShader> MakeRadial(const SkPoint& center, SkScalar radius, |
| 110 const SkColor4f colors[], sk_sp<SkColorSpa
ce> colorSpace, |
| 111 const SkScalar pos[], int count, SkShader:
:TileMode mode, |
| 112 uint32_t flags, const SkMatrix* localMatri
x); |
| 113 static sk_sp<SkShader> MakeRadial(const SkPoint& center, SkScalar radius, |
| 114 const SkColor4f colors[], sk_sp<SkColorSpa
ce> colorSpace, |
| 115 const SkScalar pos[], int count, SkShader:
:TileMode mode) { |
| 116 return MakeRadial(center, radius, colors, std::move(colorSpace), pos, co
unt, mode, 0, NULL); |
| 117 } |
| 118 |
74 /** | 119 /** |
75 * Returns a shader that generates a conical gradient given two circles, or | 120 * Returns a shader that generates a conical gradient given two circles, or |
76 * returns NULL if the inputs are invalid. The gradient interprets the | 121 * returns NULL if the inputs are invalid. The gradient interprets the |
77 * two circles according to the following HTML spec. | 122 * two circles according to the following HTML spec. |
78 * http://dev.w3.org/html5/2dcontext/#dom-context-2d-createradialgradient | 123 * http://dev.w3.org/html5/2dcontext/#dom-context-2d-createradialgradient |
79 */ | 124 */ |
80 static sk_sp<SkShader> MakeTwoPointConical(const SkPoint& start, SkScalar st
artRadius, | 125 static sk_sp<SkShader> MakeTwoPointConical(const SkPoint& start, SkScalar st
artRadius, |
81 const SkPoint& end, SkScalar endR
adius, | 126 const SkPoint& end, SkScalar endR
adius, |
82 const SkColor colors[], const SkS
calar pos[], | 127 const SkColor colors[], const SkS
calar pos[], |
83 int count, SkShader::TileMode mod
e, | 128 int count, SkShader::TileMode mod
e, |
84 uint32_t flags, const SkMatrix* l
ocalMatrix); | 129 uint32_t flags, const SkMatrix* l
ocalMatrix); |
85 static sk_sp<SkShader> MakeTwoPointConical(const SkPoint& start, SkScalar st
artRadius, | 130 static sk_sp<SkShader> MakeTwoPointConical(const SkPoint& start, SkScalar st
artRadius, |
86 const SkPoint& end, SkScalar endR
adius, | 131 const SkPoint& end, SkScalar endR
adius, |
87 const SkColor colors[], const SkS
calar pos[], | 132 const SkColor colors[], const SkS
calar pos[], |
88 int count, SkShader::TileMode mod
e) { | 133 int count, SkShader::TileMode mod
e) { |
89 return MakeTwoPointConical(start, startRadius, end, endRadius, colors, p
os, count, mode, | 134 return MakeTwoPointConical(start, startRadius, end, endRadius, colors, p
os, count, mode, |
90 0, NULL); | 135 0, NULL); |
91 } | 136 } |
92 | 137 |
| 138 /** |
| 139 * Returns a shader that generates a conical gradient given two circles, or |
| 140 * returns NULL if the inputs are invalid. The gradient interprets the |
| 141 * two circles according to the following HTML spec. |
| 142 * http://dev.w3.org/html5/2dcontext/#dom-context-2d-createradialgradient |
| 143 */ |
| 144 static sk_sp<SkShader> MakeTwoPointConical(const SkPoint& start, SkScalar st
artRadius, |
| 145 const SkPoint& end, SkScalar endR
adius, |
| 146 const SkColor4f colors[], |
| 147 sk_sp<SkColorSpace> colorSpace, c
onst SkScalar pos[], |
| 148 int count, SkShader::TileMode mod
e, |
| 149 uint32_t flags, const SkMatrix* l
ocalMatrix); |
| 150 static sk_sp<SkShader> MakeTwoPointConical(const SkPoint& start, SkScalar st
artRadius, |
| 151 const SkPoint& end, SkScalar endR
adius, |
| 152 const SkColor4f colors[], |
| 153 sk_sp<SkColorSpace> colorSpace, c
onst SkScalar pos[], |
| 154 int count, SkShader::TileMode mod
e) { |
| 155 return MakeTwoPointConical(start, startRadius, end, endRadius, colors, |
| 156 std::move(colorSpace), pos, count, mode, 0, N
ULL); |
| 157 } |
| 158 |
93 /** Returns a shader that generates a sweep gradient given a center. | 159 /** Returns a shader that generates a sweep gradient given a center. |
94 <p /> | 160 <p /> |
95 @param cx The X coordinate of the center of the sweep | 161 @param cx The X coordinate of the center of the sweep |
96 @param cx The Y coordinate of the center of the sweep | 162 @param cx The Y coordinate of the center of the sweep |
97 @param colors The array[count] of colors, to be distributed around the
center. | 163 @param colors The array[count] of colors, to be distributed around the
center. |
98 @param pos May be NULL. The array[count] of SkScalars, or NULL, of
the relative position of | 164 @param pos May be NULL. The array[count] of SkScalars, or NULL, of
the relative position of |
99 each corresponding color in the colors array. If this is
NULL, | 165 each corresponding color in the colors array. If this is
NULL, |
100 the the colors are distributed evenly between the center
and edge of the circle. | 166 the the colors are distributed evenly between the center
and edge of the circle. |
101 If this is not null, the values must begin with 0, end w
ith 1.0, and | 167 If this is not null, the values must begin with 0, end w
ith 1.0, and |
102 intermediate values must be strictly increasing. | 168 intermediate values must be strictly increasing. |
103 @param count Must be >= 2. The number of colors (and pos if not NULL)
entries | 169 @param count Must be >= 2. The number of colors (and pos if not NULL)
entries |
104 */ | 170 */ |
105 static sk_sp<SkShader> MakeSweep(SkScalar cx, SkScalar cy, | 171 static sk_sp<SkShader> MakeSweep(SkScalar cx, SkScalar cy, |
106 const SkColor colors[], const SkScalar pos[
], int count, | 172 const SkColor colors[], const SkScalar pos[
], int count, |
107 uint32_t flags, const SkMatrix* localMatrix
); | 173 uint32_t flags, const SkMatrix* localMatrix
); |
108 static sk_sp<SkShader> MakeSweep(SkScalar cx, SkScalar cy, | 174 static sk_sp<SkShader> MakeSweep(SkScalar cx, SkScalar cy, |
109 const SkColor colors[], const SkScalar pos[
], int count) { | 175 const SkColor colors[], const SkScalar pos[
], int count) { |
110 return MakeSweep(cx, cy, colors, pos, count, 0, NULL); | 176 return MakeSweep(cx, cy, colors, pos, count, 0, NULL); |
111 } | 177 } |
112 | 178 |
| 179 /** Returns a shader that generates a sweep gradient given a center. |
| 180 <p /> |
| 181 @param cx The X coordinate of the center of the sweep |
| 182 @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. |
| 184 @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, |
| 186 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 |
| 188 intermediate values must be strictly increasing. |
| 189 @param count Must be >= 2. The number of colors (and pos if not NULL)
entries |
| 190 */ |
| 191 static sk_sp<SkShader> MakeSweep(SkScalar cx, SkScalar cy, |
| 192 const SkColor4f colors[], sk_sp<SkColorSpac
e> colorSpace, |
| 193 const SkScalar pos[], int count, |
| 194 uint32_t flags, const SkMatrix* localMatrix
); |
| 195 static sk_sp<SkShader> MakeSweep(SkScalar cx, SkScalar cy, |
| 196 const SkColor4f colors[], sk_sp<SkColorSpac
e> colorSpace, |
| 197 const SkScalar pos[], int count) { |
| 198 return MakeSweep(cx, cy, colors, std::move(colorSpace), pos, count, 0, N
ULL); |
| 199 } |
| 200 |
113 #ifdef SK_SUPPORT_LEGACY_CREATESHADER_PTR | 201 #ifdef SK_SUPPORT_LEGACY_CREATESHADER_PTR |
114 static SkShader* CreateLinear(const SkPoint pts[2], | 202 static SkShader* CreateLinear(const SkPoint pts[2], |
115 const SkColor colors[], const SkScalar pos[],
int count, | 203 const SkColor colors[], const SkScalar pos[],
int count, |
116 SkShader::TileMode mode, | 204 SkShader::TileMode mode, |
117 uint32_t flags, const SkMatrix* localMatrix) { | 205 uint32_t flags, const SkMatrix* localMatrix) { |
118 return MakeLinear(pts, colors, pos, count, mode, flags, localMatrix).rel
ease(); | 206 return MakeLinear(pts, colors, pos, count, mode, flags, localMatrix).rel
ease(); |
119 } | 207 } |
120 static SkShader* CreateLinear(const SkPoint pts[2], | 208 static SkShader* CreateLinear(const SkPoint pts[2], |
121 const SkColor colors[], const SkScalar pos[],
int count, | 209 const SkColor colors[], const SkScalar pos[],
int count, |
122 SkShader::TileMode mode) { | 210 SkShader::TileMode mode) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 const SkColor colors[], const SkScalar pos[], i
nt count) { | 249 const SkColor colors[], const SkScalar pos[], i
nt count) { |
162 return CreateSweep(cx, cy, colors, pos, count, 0, NULL); | 250 return CreateSweep(cx, cy, colors, pos, count, 0, NULL); |
163 } | 251 } |
164 #endif | 252 #endif |
165 | 253 |
166 | 254 |
167 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() | 255 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() |
168 }; | 256 }; |
169 | 257 |
170 #endif | 258 #endif |
OLD | NEW |