Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(316)

Side by Side Diff: include/effects/SkGradientShader.h

Issue 288343009: Remove unused (by clients) SkUnitMapper (https://codereview.chromium.org/283273002/) (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
11 #include "SkShader.h" 11 #include "SkShader.h"
12 12
13 class SkUnitMapper;
14
15 /** \class SkGradientShader 13 /** \class SkGradientShader
16 14
17 SkGradientShader hosts factories for creating subclasses of SkShader that 15 SkGradientShader hosts factories for creating subclasses of SkShader that
18 render linear and radial gradients. 16 render linear and radial gradients.
19 */ 17 */
20 class SK_API SkGradientShader { 18 class SK_API SkGradientShader {
21 public: 19 public:
22 enum Flags { 20 enum Flags {
23 /** By default gradients will interpolate their colors in unpremul space 21 /** By default gradients will interpolate their colors in unpremul space
24 * and then premultiply each of the results. By setting this flag, the 22 * and then premultiply each of the results. By setting this flag, the
(...skipping 11 matching lines...) Expand all
36 It is an error for count to be < 2. 34 It is an error for count to be < 2.
37 @param pts The start and end points for the gradient. 35 @param pts The start and end points for the gradient.
38 @param colors The array[count] of colors, to be distributed between th e two points 36 @param colors The array[count] of colors, to be distributed between th e two points
39 @param pos May be NULL. array[count] of SkScalars, or NULL, of the relative position of 37 @param pos May be NULL. array[count] of SkScalars, or NULL, of the relative position of
40 each corresponding color in the colors array. If this is NULL, 38 each corresponding color in the colors array. If this is NULL,
41 the the colors are distributed evenly between the start and end point. 39 the the colors are distributed evenly between the start and end point.
42 If this is not null, the values must begin with 0, end w ith 1.0, and 40 If this is not null, the values must begin with 0, end w ith 1.0, and
43 intermediate values must be strictly increasing. 41 intermediate values must be strictly increasing.
44 @param count Must be >=2. The number of colors (and pos if not NULL) entries. 42 @param count Must be >=2. The number of colors (and pos if not NULL) entries.
45 @param mode The tiling mode 43 @param mode The tiling mode
46 @param mapper May be NULL. Callback to modify the spread of the colors .
47 */ 44 */
48 static SkShader* CreateLinear(const SkPoint pts[2], 45 static SkShader* CreateLinear(const SkPoint pts[2],
49 const SkColor colors[], const SkScalar pos[], int count, 46 const SkColor colors[], const SkScalar pos[], int count,
50 SkShader::TileMode mode, 47 SkShader::TileMode mode,
51 SkUnitMapper* mapper = NULL, 48 uint32_t flags, const SkMatrix* localMatrix);
52 uint32_t flags = 0,
53 const SkMatrix* localMatrix = NULL);
54 49
55 static SkShader* CreateLinear(const SkPoint pts[2], 50 static SkShader* CreateLinear(const SkPoint pts[2],
56 const SkColor colors[], const SkScalar pos[], int count, 51 const SkColor colors[], const SkScalar pos[], int count,
52 SkShader::TileMode mode) {
53 return CreateLinear(pts, colors, pos, count, mode, 0, NULL);
54 }
55
56 #ifdef SK_SUPPORT_LEGACY_DEADUNITMAPPERTYPE
57 static SkShader* CreateLinear(const SkPoint pts[2],
58 const SkColor colors[], const SkScalar pos[], int count,
57 SkShader::TileMode mode, 59 SkShader::TileMode mode,
60 SkDeadUnitMapperType*, // this type is now go ne
58 uint32_t flags, 61 uint32_t flags,
59 const SkMatrix* localMatrix) { 62 const SkMatrix* localMatrix) {
60 return CreateLinear(pts, colors, pos, count, mode, NULL, flags, localMat rix); 63 return CreateLinear(pts, colors, pos, count, mode, flags, localMatrix);
61 } 64 }
65 #endif
62 66
63 /** Returns a shader that generates a radial gradient given the center and r adius. 67 /** Returns a shader that generates a radial gradient given the center and r adius.
64 <p /> 68 <p />
65 CreateRadial returns a shader with a reference count of 1. 69 CreateRadial returns a shader with a reference count of 1.
66 The caller should decrement the shader's reference count when done with the shader. 70 The caller should decrement the shader's reference count when done with the shader.
67 It is an error for colorCount to be < 2, or for radius to be <= 0. 71 It is an error for colorCount to be < 2, or for radius to be <= 0.
68 @param center The center of the circle for this gradient 72 @param center The center of the circle for this gradient
69 @param radius Must be positive. The radius of the circle for this grad ient 73 @param radius Must be positive. The radius of the circle for this grad ient
70 @param colors The array[count] of colors, to be distributed between th e center and edge of the circle 74 @param colors The array[count] of colors, to be distributed between th e center and edge of the circle
71 @param pos May be NULL. The array[count] of SkScalars, or NULL, of the relative position of 75 @param pos May be NULL. The array[count] of SkScalars, or NULL, of the relative position of
72 each corresponding color in the colors array. If this is NULL, 76 each corresponding color in the colors array. If this is NULL,
73 the the colors are distributed evenly between the center and edge of the circle. 77 the the colors are distributed evenly between the center and edge of the circle.
74 If this is not null, the values must begin with 0, end w ith 1.0, and 78 If this is not null, the values must begin with 0, end w ith 1.0, and
75 intermediate values must be strictly increasing. 79 intermediate values must be strictly increasing.
76 @param count Must be >= 2. The number of colors (and pos if not NULL) entries 80 @param count Must be >= 2. The number of colors (and pos if not NULL) entries
77 @param mode The tiling mode 81 @param mode The tiling mode
78 @param mapper May be NULL. Callback to modify the spread of the colors .
79 */ 82 */
80 static SkShader* CreateRadial(const SkPoint& center, SkScalar radius, 83 static SkShader* CreateRadial(const SkPoint& center, SkScalar radius,
81 const SkColor colors[], const SkScalar pos[], int count, 84 const SkColor colors[], const SkScalar pos[], int count,
82 SkShader::TileMode mode, 85 SkShader::TileMode mode,
83 SkUnitMapper* mapper = NULL, 86 uint32_t flags, const SkMatrix* localMatrix);
84 uint32_t flags = 0,
85 const SkMatrix* localMatrix = NULL);
86 87
87 static SkShader* CreateRadial(const SkPoint& center, SkScalar radius, 88 static SkShader* CreateRadial(const SkPoint& center, SkScalar radius,
88 const SkColor colors[], const SkScalar pos[], int count, 89 const SkColor colors[], const SkScalar pos[], int count,
90 SkShader::TileMode mode) {
91 return CreateRadial(center, radius, colors, pos, count, mode, 0, NULL);
92 }
93
94 #ifdef SK_SUPPORT_LEGACY_DEADUNITMAPPERTYPE
95 static SkShader* CreateRadial(const SkPoint& center, SkScalar radius,
96 const SkColor colors[], const SkScalar pos[], int count,
89 SkShader::TileMode mode, 97 SkShader::TileMode mode,
90 uint32_t flags, 98 SkDeadUnitMapperType*,
91 const SkMatrix* localMatrix) { 99 uint32_t flags, const SkMatrix* localMatrix) {
92 return CreateRadial(center, radius, colors, pos, count, mode, NULL, flag s, localMatrix); 100 return CreateRadial(center, radius, colors, pos, count, mode, flags, loc alMatrix);
93 } 101 }
102 #endif
94 103
95 /** Returns a shader that generates a radial gradient given the start positi on, start radius, end position and end radius. 104 /** Returns a shader that generates a radial gradient given the start positi on, start radius, end position and end radius.
96 <p /> 105 <p />
97 CreateTwoPointRadial returns a shader with a reference count of 1. 106 CreateTwoPointRadial returns a shader with a reference count of 1.
98 The caller should decrement the shader's reference count when done with the shader. 107 The caller should decrement the shader's reference count when done with the shader.
99 It is an error for colorCount to be < 2, for startRadius or endRadius to be < 0, or for 108 It is an error for colorCount to be < 2, for startRadius or endRadius to be < 0, or for
100 startRadius to be equal to endRadius. 109 startRadius to be equal to endRadius.
101 @param start The center of the start circle for this gradient 110 @param start The center of the start circle for this gradient
102 @param startRadius Must be positive. The radius of the start circle f or this gradient. 111 @param startRadius Must be positive. The radius of the start circle f or this gradient.
103 @param end The center of the end circle for this gradient 112 @param end The center of the end circle for this gradient
104 @param endRadius Must be positive. The radius of the end circle for th is gradient. 113 @param endRadius Must be positive. The radius of the end circle for th is gradient.
105 @param colors The array[count] of colors, to be distributed between th e center and edge of the circle 114 @param colors The array[count] of colors, to be distributed between th e center and edge of the circle
106 @param pos May be NULL. The array[count] of SkScalars, or NULL, of the relative position of 115 @param pos May be NULL. The array[count] of SkScalars, or NULL, of the relative position of
107 each corresponding color in the colors array. If this is NULL, 116 each corresponding color in the colors array. If this is NULL,
108 the the colors are distributed evenly between the center and edge of the circle. 117 the the colors are distributed evenly between the center and edge of the circle.
109 If this is not null, the values must begin with 0, end w ith 1.0, and 118 If this is not null, the values must begin with 0, end w ith 1.0, and
110 intermediate values must be strictly increasing. 119 intermediate values must be strictly increasing.
111 @param count Must be >= 2. The number of colors (and pos if not NULL) entries 120 @param count Must be >= 2. The number of colors (and pos if not NULL) entries
112 @param mode The tiling mode 121 @param mode The tiling mode
113 @param mapper May be NULL. Callback to modify the spread of the colors .
114 */ 122 */
115 static SkShader* CreateTwoPointRadial(const SkPoint& start, 123 static SkShader* CreateTwoPointRadial(const SkPoint& start, SkScalar startRa dius,
116 SkScalar startRadius, 124 const SkPoint& end, SkScalar endRadius ,
117 const SkPoint& end, 125 const SkColor colors[], const SkScalar pos[], int count,
118 SkScalar endRadius,
119 const SkColor colors[],
120 const SkScalar pos[], int count,
121 SkShader::TileMode mode, 126 SkShader::TileMode mode,
122 SkUnitMapper* mapper = NULL, 127 uint32_t flags, const SkMatrix* localM atrix);
123 uint32_t flags = 0,
124 const SkMatrix* localMatrix = NULL);
125 128
126 static SkShader* CreateTwoPointRadial(const SkPoint& start, 129 static SkShader* CreateTwoPointRadial(const SkPoint& start, SkScalar startRa dius,
127 SkScalar startRadius, 130 const SkPoint& end, SkScalar endRadius ,
128 const SkPoint& end, 131 const SkColor colors[], const SkScalar pos[], int count,
129 SkScalar endRadius, 132 SkShader::TileMode mode) {
130 const SkColor colors[], 133 return CreateTwoPointRadial(start, startRadius, end, endRadius, colors, pos, count, mode,
131 const SkScalar pos[], int count, 134 0, NULL);
135 }
136
137 #ifdef SK_SUPPORT_LEGACY_DEADUNITMAPPERTYPE
138 static SkShader* CreateTwoPointRadial(const SkPoint& start, SkScalar startRa dius,
139 const SkPoint& end, SkScalar endRadius ,
140 const SkColor colors[], const SkScalar pos[], int count,
132 SkShader::TileMode mode, 141 SkShader::TileMode mode,
133 uint32_t flags, 142 SkDeadUnitMapperType*,
134 const SkMatrix* localMatrix) { 143 uint32_t flags, const SkMatrix* localM atrix) {
135 return CreateTwoPointRadial(start, startRadius, end, endRadius, colors, pos, count, mode, 144 return CreateTwoPointRadial(start, startRadius, end, endRadius, colors, pos, count, mode,
136 NULL, flags, localMatrix); 145 flags, localMatrix);
137 } 146 }
147 #endif
138 148
139 /** 149 /**
140 * Returns a shader that generates a conical gradient given two circles, or 150 * Returns a shader that generates a conical gradient given two circles, or
141 * returns NULL if the inputs are invalid. The gradient interprets the 151 * returns NULL if the inputs are invalid. The gradient interprets the
142 * two circles according to the following HTML spec. 152 * two circles according to the following HTML spec.
143 * http://dev.w3.org/html5/2dcontext/#dom-context-2d-createradialgradient 153 * http://dev.w3.org/html5/2dcontext/#dom-context-2d-createradialgradient
144 */ 154 */
145 static SkShader* CreateTwoPointConical(const SkPoint& start, 155 static SkShader* CreateTwoPointConical(const SkPoint& start, SkScalar startR adius,
146 SkScalar startRadius, 156 const SkPoint& end, SkScalar endRadiu s,
147 const SkPoint& end, 157 const SkColor colors[], const SkScala r pos[], int count,
148 SkScalar endRadius,
149 const SkColor colors[],
150 const SkScalar pos[], int count,
151 SkShader::TileMode mode, 158 SkShader::TileMode mode,
152 SkUnitMapper* mapper = NULL, 159 uint32_t flags, const SkMatrix* local Matrix);
153 uint32_t flags = 0,
154 const SkMatrix* localMatrix = NULL);
155 160
156 static SkShader* CreateTwoPointConical(const SkPoint& start, 161 static SkShader* CreateTwoPointConical(const SkPoint& start, SkScalar startR adius,
157 SkScalar startRadius, 162 const SkPoint& end, SkScalar endRadiu s,
158 const SkPoint& end, 163 const SkColor colors[], const SkScala r pos[], int count,
159 SkScalar endRadius, 164 SkShader::TileMode mode) {
160 const SkColor colors[], 165 return CreateTwoPointConical(start, startRadius, end, endRadius, colors, pos, count, mode,
161 const SkScalar pos[], int count, 166 0, NULL);
167 }
168
169 #ifdef SK_SUPPORT_LEGACY_DEADUNITMAPPERTYPE
170 static SkShader* CreateTwoPointConical(const SkPoint& start, SkScalar startR adius,
171 const SkPoint& end, SkScalar endRadiu s,
172 const SkColor colors[], const SkScala r pos[], int count,
162 SkShader::TileMode mode, 173 SkShader::TileMode mode,
163 uint32_t flags, 174 SkDeadUnitMapperType*,
164 const SkMatrix* localMatrix) { 175 uint32_t flags, const SkMatrix* local Matrix) {
165 return CreateTwoPointConical(start, startRadius, end, endRadius, colors, pos, count, mode, 176 return CreateTwoPointConical(start, startRadius, end, endRadius, colors, pos, count, mode,
166 NULL, flags, localMatrix); 177 flags, localMatrix);
167 } 178 }
179 #endif
168 180
169 /** Returns a shader that generates a sweep gradient given a center. 181 /** Returns a shader that generates a sweep gradient given a center.
170 <p /> 182 <p />
171 CreateSweep returns a shader with a reference count of 1. 183 CreateSweep returns a shader with a reference count of 1.
172 The caller should decrement the shader's reference count when done with the shader. 184 The caller should decrement the shader's reference count when done with the shader.
173 It is an error for colorCount to be < 2. 185 It is an error for colorCount to be < 2.
174 @param cx The X coordinate of the center of the sweep 186 @param cx The X coordinate of the center of the sweep
175 @param cx The Y coordinate of the center of the sweep 187 @param cx The Y coordinate of the center of the sweep
176 @param colors The array[count] of colors, to be distributed around the center. 188 @param colors The array[count] of colors, to be distributed around the center.
177 @param pos May be NULL. The array[count] of SkScalars, or NULL, of the relative position of 189 @param pos May be NULL. The array[count] of SkScalars, or NULL, of the relative position of
178 each corresponding color in the colors array. If this is NULL, 190 each corresponding color in the colors array. If this is NULL,
179 the the colors are distributed evenly between the center and edge of the circle. 191 the the colors are distributed evenly between the center and edge of the circle.
180 If this is not null, the values must begin with 0, end w ith 1.0, and 192 If this is not null, the values must begin with 0, end w ith 1.0, and
181 intermediate values must be strictly increasing. 193 intermediate values must be strictly increasing.
182 @param count Must be >= 2. The number of colors (and pos if not NULL) entries 194 @param count Must be >= 2. The number of colors (and pos if not NULL) entries
183 @param mapper May be NULL. Callback to modify the spread of the colors .
184 */ 195 */
185 static SkShader* CreateSweep(SkScalar cx, SkScalar cy, 196 static SkShader* CreateSweep(SkScalar cx, SkScalar cy,
186 const SkColor colors[], const SkScalar pos[], 197 const SkColor colors[], const SkScalar pos[], i nt count,
187 int count, SkUnitMapper* mapper = NULL, 198 uint32_t flags, const SkMatrix* localMatrix);
188 uint32_t flags = 0,
189 const SkMatrix* localMatrix = NULL);
190 199
191 static SkShader* CreateSweep(SkScalar cx, SkScalar cy, 200 static SkShader* CreateSweep(SkScalar cx, SkScalar cy,
201 const SkColor colors[], const SkScalar pos[], i nt count) {
202 return CreateSweep(cx, cy, colors, pos, count, 0, NULL);
203 }
204
205 #ifdef SK_SUPPORT_LEGACY_DEADUNITMAPPERTYPE
206 static SkShader* CreateSweep(SkScalar cx, SkScalar cy,
192 const SkColor colors[], const SkScalar pos[], i nt count, 207 const SkColor colors[], const SkScalar pos[], i nt count,
208 SkDeadUnitMapperType*,
193 uint32_t flags, const SkMatrix* localMatrix) { 209 uint32_t flags, const SkMatrix* localMatrix) {
194 return CreateSweep(cx, cy, colors, pos, count, NULL, flags, localMatrix) ; 210 return CreateSweep(cx, cy, colors, pos, count, flags, localMatrix);
195 } 211 }
212 #endif
196 213
197 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() 214 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
198 }; 215 };
199 216
200 #endif 217 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698