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

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

Issue 1772463002: use Make instead of Create to return a shared shader (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: partial update of skia call-sites Created 4 years, 9 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
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
(...skipping 24 matching lines...) Expand all
35 @param pts The start and end points for the gradient. 35 @param pts The start and end points for the gradient.
36 @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
37 @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
38 each corresponding color in the colors array. If this is NULL, 38 each corresponding color in the colors array. If this is NULL,
39 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.
40 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
41 intermediate values must be strictly increasing. 41 intermediate values must be strictly increasing.
42 @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.
43 @param mode The tiling mode 43 @param mode The tiling mode
44 */ 44 */
45 static SkShader* CreateLinear(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 uint32_t flags, const SkMatrix* localMatrix); 48 uint32_t flags, const SkMatrix* localMatri x);
49 49 static sk_sp<SkShader> MakeLinear(const SkPoint pts[2],
50 static SkShader* CreateLinear(const SkPoint pts[2], 50 const SkColor colors[], const SkScalar pos [], int count,
51 const SkColor colors[], const SkScalar pos[], int count, 51 SkShader::TileMode mode) {
52 SkShader::TileMode mode) { 52 return MakeLinear(pts, colors, pos, count, mode, 0, NULL);
53 return CreateLinear(pts, colors, pos, count, mode, 0, NULL);
54 } 53 }
55 54
56 /** Returns a shader that generates a radial gradient given the center and r adius. 55 /** Returns a shader that generates a radial gradient given the center and r adius.
57 <p /> 56 <p />
58 CreateRadial returns a shader with a reference count of 1. 57 CreateRadial returns a shader with a reference count of 1.
59 The caller should decrement the shader's reference count when done with the shader. 58 The caller should decrement the shader's reference count when done with the shader.
60 It is an error for colorCount to be < 2, or for radius to be <= 0. 59 It is an error for colorCount to be < 2, or for radius to be <= 0.
61 @param center The center of the circle for this gradient 60 @param center The center of the circle for this gradient
62 @param radius Must be positive. The radius of the circle for this grad ient 61 @param radius Must be positive. The radius of the circle for this grad ient
63 @param colors The array[count] of colors, to be distributed between th e center and edge of the circle 62 @param colors The array[count] of colors, to be distributed between th e center and edge of the circle
64 @param pos May be NULL. The array[count] of SkScalars, or NULL, of the relative position of 63 @param pos May be NULL. The array[count] of SkScalars, or NULL, of the relative position of
65 each corresponding color in the colors array. If this is NULL, 64 each corresponding color in the colors array. If this is NULL,
66 the the colors are distributed evenly between the center and edge of the circle. 65 the the colors are distributed evenly between the center and edge of the circle.
67 If this is not null, the values must begin with 0, end w ith 1.0, and 66 If this is not null, the values must begin with 0, end w ith 1.0, and
68 intermediate values must be strictly increasing. 67 intermediate values must be strictly increasing.
69 @param count Must be >= 2. The number of colors (and pos if not NULL) entries 68 @param count Must be >= 2. The number of colors (and pos if not NULL) entries
70 @param mode The tiling mode 69 @param mode The tiling mode
71 */ 70 */
72 static SkShader* CreateRadial(const SkPoint& center, SkScalar radius, 71 static sk_sp<SkShader> MakeRadial(const SkPoint& center, SkScalar radius,
73 const SkColor colors[], const SkScalar pos[], int count, 72 const SkColor colors[], const SkScalar pos [], int count,
74 SkShader::TileMode mode, 73 SkShader::TileMode mode,
75 uint32_t flags, const SkMatrix* localMatrix); 74 uint32_t flags, const SkMatrix* localMatri x);
76 75 static sk_sp<SkShader> MakeRadial(const SkPoint& center, SkScalar radius,
77 static SkShader* CreateRadial(const SkPoint& center, SkScalar radius, 76 const SkColor colors[], const SkScalar pos [], int count,
78 const SkColor colors[], const SkScalar pos[], int count, 77 SkShader::TileMode mode) {
79 SkShader::TileMode mode) { 78 return MakeRadial(center, radius, colors, pos, count, mode, 0, NULL);
80 return CreateRadial(center, radius, colors, pos, count, mode, 0, NULL);
81 } 79 }
82 80
83 /** 81 /**
84 * Returns a shader that generates a conical gradient given two circles, or 82 * Returns a shader that generates a conical gradient given two circles, or
85 * returns NULL if the inputs are invalid. The gradient interprets the 83 * returns NULL if the inputs are invalid. The gradient interprets the
86 * two circles according to the following HTML spec. 84 * two circles according to the following HTML spec.
87 * http://dev.w3.org/html5/2dcontext/#dom-context-2d-createradialgradient 85 * http://dev.w3.org/html5/2dcontext/#dom-context-2d-createradialgradient
88 */ 86 */
89 static SkShader* CreateTwoPointConical(const SkPoint& start, SkScalar startR adius, 87 static sk_sp<SkShader> MakeTwoPointConical(const SkPoint& start, SkScalar st artRadius,
90 const SkPoint& end, SkScalar endRadiu s, 88 const SkPoint& end, SkScalar endR adius,
91 const SkColor colors[], const SkScala r pos[], int count, 89 const SkColor colors[], const SkS calar pos[],
92 SkShader::TileMode mode, 90 int count, SkShader::TileMode mod e,
93 uint32_t flags, const SkMatrix* local Matrix); 91 uint32_t flags, const SkMatrix* l ocalMatrix);
94 92 static sk_sp<SkShader> MakeTwoPointConical(const SkPoint& start, SkScalar st artRadius,
95 static SkShader* CreateTwoPointConical(const SkPoint& start, SkScalar startR adius, 93 const SkPoint& end, SkScalar endR adius,
96 const SkPoint& end, SkScalar endRadiu s, 94 const SkColor colors[], const SkS calar pos[],
97 const SkColor colors[], const SkScala r pos[], int count, 95 int count, SkShader::TileMode mod e) {
98 SkShader::TileMode mode) { 96 return MakeTwoPointConical(start, startRadius, end, endRadius, colors, p os, count, mode,
99 return CreateTwoPointConical(start, startRadius, end, endRadius, colors, pos, count, mode, 97 0, NULL);
100 0, NULL);
101 } 98 }
102 99
103 /** Returns a shader that generates a sweep gradient given a center. 100 /** Returns a shader that generates a sweep gradient given a center.
104 <p /> 101 <p />
105 CreateSweep returns a shader with a reference count of 1. 102 CreateSweep returns a shader with a reference count of 1.
106 The caller should decrement the shader's reference count when done with the shader. 103 The caller should decrement the shader's reference count when done with the shader.
107 It is an error for colorCount to be < 2. 104 It is an error for colorCount to be < 2.
108 @param cx The X coordinate of the center of the sweep 105 @param cx The X coordinate of the center of the sweep
109 @param cx The Y coordinate of the center of the sweep 106 @param cx The Y coordinate of the center of the sweep
110 @param colors The array[count] of colors, to be distributed around the center. 107 @param colors The array[count] of colors, to be distributed around the center.
111 @param pos May be NULL. The array[count] of SkScalars, or NULL, of the relative position of 108 @param pos May be NULL. The array[count] of SkScalars, or NULL, of the relative position of
112 each corresponding color in the colors array. If this is NULL, 109 each corresponding color in the colors array. If this is NULL,
113 the the colors are distributed evenly between the center and edge of the circle. 110 the the colors are distributed evenly between the center and edge of the circle.
114 If this is not null, the values must begin with 0, end w ith 1.0, and 111 If this is not null, the values must begin with 0, end w ith 1.0, and
115 intermediate values must be strictly increasing. 112 intermediate values must be strictly increasing.
116 @param count Must be >= 2. The number of colors (and pos if not NULL) entries 113 @param count Must be >= 2. The number of colors (and pos if not NULL) entries
117 */ 114 */
115 static sk_sp<SkShader> MakeSweep(SkScalar cx, SkScalar cy,
116 const SkColor colors[], const SkScalar pos[ ], int count,
117 uint32_t flags, const SkMatrix* localMatrix );
118 static sk_sp<SkShader> MakeSweep(SkScalar cx, SkScalar cy,
119 const SkColor colors[], const SkScalar pos[ ], int count) {
120 return MakeSweep(cx, cy, colors, pos, count, 0, NULL);
121 }
122
123 #ifdef SK_SUPPORT_LEGACY_CREATESHADER_PTR
124 static SkShader* CreateLinear(const SkPoint pts[2],
125 const SkColor colors[], const SkScalar pos[], int count,
126 SkShader::TileMode mode,
127 uint32_t flags, const SkMatrix* localMatrix) {
128 return MakeLinear(pts, colors, pos, count, mode, flags, localMatrix).rel ease();
129 }
130 static SkShader* CreateLinear(const SkPoint pts[2],
131 const SkColor colors[], const SkScalar pos[], int count,
132 SkShader::TileMode mode) {
133 return CreateLinear(pts, colors, pos, count, mode, 0, NULL);
134 }
135
136 static SkShader* CreateRadial(const SkPoint& center, SkScalar radius,
137 const SkColor colors[], const SkScalar pos[], int count,
138 SkShader::TileMode mode,
139 uint32_t flags, const SkMatrix* localMatrix) {
140 return MakeRadial(center, radius, colors, pos, count, mode, flags, local Matrix).release();
141 }
142
143 static SkShader* CreateRadial(const SkPoint& center, SkScalar radius,
144 const SkColor colors[], const SkScalar pos[], int count,
145 SkShader::TileMode mode) {
146 return CreateRadial(center, radius, colors, pos, count, mode, 0, NULL);
147 }
148
149 static SkShader* CreateTwoPointConical(const SkPoint& start, SkScalar startR adius,
150 const SkPoint& end, SkScalar endRadiu s,
151 const SkColor colors[], const SkScala r pos[], int count,
152 SkShader::TileMode mode,
153 uint32_t flags, const SkMatrix* local Matrix) {
154 return MakeTwoPointConical(start, startRadius, end, endRadius, colors, p os, count, mode,
155 flags, localMatrix).release();
156 }
157 static SkShader* CreateTwoPointConical(const SkPoint& start, SkScalar startR adius,
158 const SkPoint& end, SkScalar endRadiu s,
159 const SkColor colors[], const SkScala r pos[], int count,
160 SkShader::TileMode mode) {
161 return CreateTwoPointConical(start, startRadius, end, endRadius, colors, pos, count, mode,
162 0, NULL);
163 }
164
118 static SkShader* CreateSweep(SkScalar cx, SkScalar cy, 165 static SkShader* CreateSweep(SkScalar cx, SkScalar cy,
119 const SkColor colors[], const SkScalar pos[], i nt count, 166 const SkColor colors[], const SkScalar pos[], i nt count,
120 uint32_t flags, const SkMatrix* localMatrix); 167 uint32_t flags, const SkMatrix* localMatrix) {
121 168 return MakeSweep(cx, cy, colors, pos, count, flags, localMatrix).release ();
169 }
122 static SkShader* CreateSweep(SkScalar cx, SkScalar cy, 170 static SkShader* CreateSweep(SkScalar cx, SkScalar cy,
123 const SkColor colors[], const SkScalar pos[], i nt count) { 171 const SkColor colors[], const SkScalar pos[], i nt count) {
124 return CreateSweep(cx, cy, colors, pos, count, 0, NULL); 172 return CreateSweep(cx, cy, colors, pos, count, 0, NULL);
125 } 173 }
174 #endif
175
126 176
127 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() 177 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
128 }; 178 };
129 179
130 #endif 180 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698