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

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

Issue 283273002: remove unused (by clients) SkUnitMapper (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 . 44 @param mapper May be NULL. Callback to modify the spread of the colors .
scroggo 2014/05/15 14:33:38 This comment can be removed.
reed1 2014/05/15 15:37:21 Done.
47 */ 45 */
48 static SkShader* CreateLinear(const SkPoint pts[2], 46 static SkShader* CreateLinear(const SkPoint pts[2],
49 const SkColor colors[], const SkScalar pos[], int count, 47 const SkColor colors[], const SkScalar pos[], int count,
50 SkShader::TileMode mode, 48 SkShader::TileMode mode,
51 SkUnitMapper* mapper = NULL, 49 uint32_t flags, const SkMatrix* localMatrix);
52 uint32_t flags = 0, 50
53 const SkMatrix* localMatrix = NULL); 51 static SkShader* CreateLinear(const SkPoint pts[2],
52 const SkColor colors[], const SkScalar pos[], int count,
53 SkShader::TileMode mode) {
54 return CreateLinear(pts, colors, pos, count, mode, 0, NULL);
55 }
56
57 #ifdef SK_SUPPORT_LEGACY_DEADUNITMAPPERTYPE
58 static SkShader* CreateLinear(const SkPoint pts[2],
59 const SkColor colors[], const SkScalar pos[], int count,
60 SkShader::TileMode mode,
61 SkDeadUnitMapperType*, // this type is now go ne
62 uint32_t flags,
63 const SkMatrix* localMatrix) {
64 return CreateLinear(pts, colors, pos, count, mode, flags, localMatrix);
65 }
66 #endif
54 67
55 /** Returns a shader that generates a radial gradient given the center and r adius. 68 /** Returns a shader that generates a radial gradient given the center and r adius.
56 <p /> 69 <p />
57 CreateRadial returns a shader with a reference count of 1. 70 CreateRadial returns a shader with a reference count of 1.
58 The caller should decrement the shader's reference count when done with the shader. 71 The caller should decrement the shader's reference count when done with the shader.
59 It is an error for colorCount to be < 2, or for radius to be <= 0. 72 It is an error for colorCount to be < 2, or for radius to be <= 0.
60 @param center The center of the circle for this gradient 73 @param center The center of the circle for this gradient
61 @param radius Must be positive. The radius of the circle for this grad ient 74 @param radius Must be positive. The radius of the circle for this grad ient
62 @param colors The array[count] of colors, to be distributed between th e center and edge of the circle 75 @param colors The array[count] of colors, to be distributed between th e center and edge of the circle
63 @param pos May be NULL. The array[count] of SkScalars, or NULL, of the relative position of 76 @param pos May be NULL. The array[count] of SkScalars, or NULL, of the relative position of
64 each corresponding color in the colors array. If this is NULL, 77 each corresponding color in the colors array. If this is NULL,
65 the the colors are distributed evenly between the center and edge of the circle. 78 the the colors are distributed evenly between the center and edge of the circle.
66 If this is not null, the values must begin with 0, end w ith 1.0, and 79 If this is not null, the values must begin with 0, end w ith 1.0, and
67 intermediate values must be strictly increasing. 80 intermediate values must be strictly increasing.
68 @param count Must be >= 2. The number of colors (and pos if not NULL) entries 81 @param count Must be >= 2. The number of colors (and pos if not NULL) entries
69 @param mode The tiling mode 82 @param mode The tiling mode
70 @param mapper May be NULL. Callback to modify the spread of the colors . 83 @param mapper May be NULL. Callback to modify the spread of the colors .
scroggo 2014/05/15 14:33:38 No longer needed.
reed1 2014/05/15 15:37:21 Done.
71 */ 84 */
72 static SkShader* CreateRadial(const SkPoint& center, SkScalar radius, 85 static SkShader* CreateRadial(const SkPoint& center, SkScalar radius,
73 const SkColor colors[], const SkScalar pos[], int count, 86 const SkColor colors[], const SkScalar pos[], int count,
74 SkShader::TileMode mode, 87 SkShader::TileMode mode,
75 SkUnitMapper* mapper = NULL, 88 uint32_t flags, const SkMatrix* localMatrix);
76 uint32_t flags = 0, 89
77 const SkMatrix* localMatrix = NULL); 90 static SkShader* CreateRadial(const SkPoint& center, SkScalar radius,
91 const SkColor colors[], const SkScalar pos[], int count,
92 SkShader::TileMode mode) {
93 return CreateRadial(center, radius, colors, pos, count, mode, 0, NULL);
94 }
95
96 #ifdef SK_SUPPORT_LEGACY_DEADUNITMAPPERTYPE
97 static SkShader* CreateRadial(const SkPoint& center, SkScalar radius,
98 const SkColor colors[], const SkScalar pos[], int count,
99 SkShader::TileMode mode,
100 SkDeadUnitMapperType*,
101 uint32_t flags, const SkMatrix* localMatrix) {
102 return CreateRadial(center, radius, colors, pos, count, mode, flags, loc alMatrix);
103 }
104 #endif
78 105
79 /** Returns a shader that generates a radial gradient given the start positi on, start radius, end position and end radius. 106 /** Returns a shader that generates a radial gradient given the start positi on, start radius, end position and end radius.
80 <p /> 107 <p />
81 CreateTwoPointRadial returns a shader with a reference count of 1. 108 CreateTwoPointRadial returns a shader with a reference count of 1.
82 The caller should decrement the shader's reference count when done with the shader. 109 The caller should decrement the shader's reference count when done with the shader.
83 It is an error for colorCount to be < 2, for startRadius or endRadius to be < 0, or for 110 It is an error for colorCount to be < 2, for startRadius or endRadius to be < 0, or for
84 startRadius to be equal to endRadius. 111 startRadius to be equal to endRadius.
85 @param start The center of the start circle for this gradient 112 @param start The center of the start circle for this gradient
86 @param startRadius Must be positive. The radius of the start circle f or this gradient. 113 @param startRadius Must be positive. The radius of the start circle f or this gradient.
87 @param end The center of the end circle for this gradient 114 @param end The center of the end circle for this gradient
88 @param endRadius Must be positive. The radius of the end circle for th is gradient. 115 @param endRadius Must be positive. The radius of the end circle for th is gradient.
89 @param colors The array[count] of colors, to be distributed between th e center and edge of the circle 116 @param colors The array[count] of colors, to be distributed between th e center and edge of the circle
90 @param pos May be NULL. The array[count] of SkScalars, or NULL, of the relative position of 117 @param pos May be NULL. The array[count] of SkScalars, or NULL, of the relative position of
91 each corresponding color in the colors array. If this is NULL, 118 each corresponding color in the colors array. If this is NULL,
92 the the colors are distributed evenly between the center and edge of the circle. 119 the the colors are distributed evenly between the center and edge of the circle.
93 If this is not null, the values must begin with 0, end w ith 1.0, and 120 If this is not null, the values must begin with 0, end w ith 1.0, and
94 intermediate values must be strictly increasing. 121 intermediate values must be strictly increasing.
95 @param count Must be >= 2. The number of colors (and pos if not NULL) entries 122 @param count Must be >= 2. The number of colors (and pos if not NULL) entries
96 @param mode The tiling mode 123 @param mode The tiling mode
97 @param mapper May be NULL. Callback to modify the spread of the colors . 124 @param mapper May be NULL. Callback to modify the spread of the colors .
scroggo 2014/05/15 14:33:38 No longer needed.
reed1 2014/05/15 15:37:21 Done.
98 */ 125 */
99 static SkShader* CreateTwoPointRadial(const SkPoint& start, 126 static SkShader* CreateTwoPointRadial(const SkPoint& start, SkScalar startRa dius,
100 SkScalar startRadius, 127 const SkPoint& end, SkScalar endRadius ,
101 const SkPoint& end, 128 const SkColor colors[], const SkScalar pos[], int count,
102 SkScalar endRadius,
103 const SkColor colors[],
104 const SkScalar pos[], int count,
105 SkShader::TileMode mode, 129 SkShader::TileMode mode,
106 SkUnitMapper* mapper = NULL, 130 uint32_t flags, const SkMatrix* localM atrix);
107 uint32_t flags = 0, 131
108 const SkMatrix* localMatrix = NULL); 132 static SkShader* CreateTwoPointRadial(const SkPoint& start, SkScalar startRa dius,
133 const SkPoint& end, SkScalar endRadius ,
134 const SkColor colors[], const SkScalar pos[], int count,
135 SkShader::TileMode mode) {
136 return CreateTwoPointRadial(start, startRadius, end, endRadius, colors, pos, count, mode,
137 0, NULL);
138 }
139
140 #ifdef SK_SUPPORT_LEGACY_DEADUNITMAPPERTYPE
141 static SkShader* CreateTwoPointRadial(const SkPoint& start, SkScalar startRa dius,
142 const SkPoint& end, SkScalar endRadius ,
143 const SkColor colors[], const SkScalar pos[], int count,
144 SkShader::TileMode mode,
145 SkDeadUnitMapperType*,
146 uint32_t flags, const SkMatrix* localM atrix) {
147 return CreateTwoPointRadial(start, startRadius, end, endRadius, colors, pos, count, mode,
148 flags, localMatrix)
149 }
150 #endif
109 151
110 /** 152 /**
111 * Returns a shader that generates a conical gradient given two circles, or 153 * Returns a shader that generates a conical gradient given two circles, or
112 * returns NULL if the inputs are invalid. The gradient interprets the 154 * returns NULL if the inputs are invalid. The gradient interprets the
113 * two circles according to the following HTML spec. 155 * two circles according to the following HTML spec.
114 * http://dev.w3.org/html5/2dcontext/#dom-context-2d-createradialgradient 156 * http://dev.w3.org/html5/2dcontext/#dom-context-2d-createradialgradient
115 */ 157 */
116 static SkShader* CreateTwoPointConical(const SkPoint& start, 158 static SkShader* CreateTwoPointConical(const SkPoint& start, SkScalar startR adius,
117 SkScalar startRadius, 159 const SkPoint& end, SkScalar endRadiu s,
118 const SkPoint& end, 160 const SkColor colors[], const SkScala r pos[], int count,
119 SkScalar endRadius,
120 const SkColor colors[],
121 const SkScalar pos[], int count,
122 SkShader::TileMode mode, 161 SkShader::TileMode mode,
123 SkUnitMapper* mapper = NULL, 162 uint32_t flags, const SkMatrix* local Matrix);
124 uint32_t flags = 0, 163
125 const SkMatrix* localMatrix = NULL); 164 static SkShader* CreateTwoPointConical(const SkPoint& start, SkScalar startR adius,
165 const SkPoint& end, SkScalar endRadiu s,
166 const SkColor colors[], const SkScala r pos[], int count,
167 SkShader::TileMode mode) {
168 return CreateTwoPointConical(start, startRadius, end, endRadius, colors, pos, count, mode,
169 0, NULL);
170 }
171
172 #ifdef SK_SUPPORT_LEGACY_DEADUNITMAPPERTYPE
173 static SkShader* CreateTwoPointConical(const SkPoint& start, SkScalar startR adius,
174 const SkPoint& end, SkScalar endRadiu s,
175 const SkColor colors[], const SkScala r pos[], int count,
176 SkShader::TileMode mode,
177 SkDeadUnitMapperType*,
178 uint32_t flags, const SkMatrix* local Matrix) {
179 return CreateTwoPointConical(start, startRadius, end, endRadius, colors, pos, count, mode,
180 flags, localMatrix);
181 }
182 #endif
126 183
127 /** Returns a shader that generates a sweep gradient given a center. 184 /** Returns a shader that generates a sweep gradient given a center.
128 <p /> 185 <p />
129 CreateSweep returns a shader with a reference count of 1. 186 CreateSweep returns a shader with a reference count of 1.
130 The caller should decrement the shader's reference count when done with the shader. 187 The caller should decrement the shader's reference count when done with the shader.
131 It is an error for colorCount to be < 2. 188 It is an error for colorCount to be < 2.
132 @param cx The X coordinate of the center of the sweep 189 @param cx The X coordinate of the center of the sweep
133 @param cx The Y coordinate of the center of the sweep 190 @param cx The Y coordinate of the center of the sweep
134 @param colors The array[count] of colors, to be distributed around the center. 191 @param colors The array[count] of colors, to be distributed around the center.
135 @param pos May be NULL. The array[count] of SkScalars, or NULL, of the relative position of 192 @param pos May be NULL. The array[count] of SkScalars, or NULL, of the relative position of
136 each corresponding color in the colors array. If this is NULL, 193 each corresponding color in the colors array. If this is NULL,
137 the the colors are distributed evenly between the center and edge of the circle. 194 the the colors are distributed evenly between the center and edge of the circle.
138 If this is not null, the values must begin with 0, end w ith 1.0, and 195 If this is not null, the values must begin with 0, end w ith 1.0, and
139 intermediate values must be strictly increasing. 196 intermediate values must be strictly increasing.
140 @param count Must be >= 2. The number of colors (and pos if not NULL) entries 197 @param count Must be >= 2. The number of colors (and pos if not NULL) entries
141 @param mapper May be NULL. Callback to modify the spread of the colors . 198 @param mapper May be NULL. Callback to modify the spread of the colors .
scroggo 2014/05/15 14:33:38 No longer needed.
reed1 2014/05/15 15:37:21 Done.
142 */ 199 */
143 static SkShader* CreateSweep(SkScalar cx, SkScalar cy, 200 static SkShader* CreateSweep(SkScalar cx, SkScalar cy,
144 const SkColor colors[], const SkScalar pos[], 201 const SkColor colors[], const SkScalar pos[], i nt count,
145 int count, SkUnitMapper* mapper = NULL, 202 uint32_t flags, const SkMatrix* localMatrix);
146 uint32_t flags = 0, 203
147 const SkMatrix* localMatrix = NULL); 204 static SkShader* CreateSweep(SkScalar cx, SkScalar cy,
205 const SkColor colors[], const SkScalar pos[], i nt count) {
206 return CreateSweep(cx, cy, colors, pos, count, 0, NULL);
207 }
208
209 #ifdef SK_SUPPORT_LEGACY_DEADUNITMAPPERTYPE
210 static SkShader* CreateSweep(SkScalar cx, SkScalar cy,
211 const SkColor colors[], const SkScalar pos[], i nt count,
212 SkDeadUnitMapperType*,
213 uint32_t flags, const SkMatrix* localMatrix) {
214 return CreateSweep(cx, cy, colors, pos, count, flags, localMatrix);
215 }
216 #endif
148 217
149 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() 218 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
150 }; 219 };
151 220
152 #endif 221 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698