blob: 28ed8bb965ea6ad4f53a29f9ffb1ef19c035bed2 [file] [log] [blame]
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +00001/*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
commit-bot@chromium.org83f23d82014-05-22 12:27:41 +00007
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +00008#include "gm.h"
9#include "SkGradientShader.h"
10
11namespace skiagm {
12
13struct GradData {
14 int fCount;
15 const SkColor* fColors;
16 const SkScalar* fPos;
17};
18
19static const SkColor gColors[] = {
20 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK
21};
22static const SkScalar gPos0[] = { 0, SK_Scalar1 };
23static const SkScalar gPos1[] = { SK_Scalar1/4, SK_Scalar1*3/4 };
24static const SkScalar gPos2[] = {
25 0, SK_Scalar1/8, SK_Scalar1/2, SK_Scalar1*7/8, SK_Scalar1
26};
27
28static const SkScalar gPosClamp[] = {0.0f, 0.0f, 1.0f, 1.0f};
29static const SkColor gColorClamp[] = {
30 SK_ColorRED, SK_ColorGREEN, SK_ColorGREEN, SK_ColorBLUE
31};
32
33static const GradData gGradData[] = {
34 { 2, gColors, gPos0 },
35 { 2, gColors, gPos1 },
36 { 5, gColors, gPos2 },
37 { 4, gColorClamp, gPosClamp }
38};
39
reed1a9b9642016-03-13 14:13:58 -070040static sk_sp<SkShader> Make2ConicalOutside(const SkPoint pts[2], const GradData& data,
41 SkShader::TileMode tm, const SkMatrix& localMatrix) {
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +000042 SkPoint center0, center1;
reed80ea19c2015-05-12 10:37:34 -070043 SkScalar radius0 = (pts[1].fX - pts[0].fX) / 10;
44 SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3;
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +000045 center0.set(pts[0].fX + radius0, pts[0].fY + radius0);
46 center1.set(pts[1].fX - radius1, pts[1].fY - radius1);
reed1a9b9642016-03-13 14:13:58 -070047 return SkGradientShader::MakeTwoPointConical(center0, radius0, center1, radius1, data.fColors,
48 data.fPos, data.fCount, tm, 0, &localMatrix);
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +000049}
50
reed1a9b9642016-03-13 14:13:58 -070051static sk_sp<SkShader> Make2ConicalOutsideFlip(const SkPoint pts[2], const GradData& data,
commit-bot@chromium.org83f23d82014-05-22 12:27:41 +000052 SkShader::TileMode tm, const SkMatrix& localMatrix) {
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +000053 SkPoint center0, center1;
reed80ea19c2015-05-12 10:37:34 -070054 SkScalar radius0 = (pts[1].fX - pts[0].fX) / 10;
55 SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3;
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +000056 center0.set(pts[0].fX + radius0, pts[0].fY + radius0);
57 center1.set(pts[1].fX - radius1, pts[1].fY - radius1);
reed1a9b9642016-03-13 14:13:58 -070058 return SkGradientShader::MakeTwoPointConical(center1, radius1, center0, radius0, data.fColors,
59 data.fPos, data.fCount, tm, 0, &localMatrix);
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +000060}
61
reed1a9b9642016-03-13 14:13:58 -070062static sk_sp<SkShader> Make2ConicalInside(const SkPoint pts[2], const GradData& data,
63 SkShader::TileMode tm, const SkMatrix& localMatrix) {
64 SkPoint center0, center1;
65 center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
66 SkScalarAve(pts[0].fY, pts[1].fY));
67 center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
68 SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
69 return SkGradientShader::MakeTwoPointConical(center1, (pts[1].fX - pts[0].fX) / 7,
70 center0, (pts[1].fX - pts[0].fX) / 2,
71 data.fColors, data.fPos, data.fCount, tm,
72 0, &localMatrix);
73}
74
75static sk_sp<SkShader> Make2ConicalInsideFlip(const SkPoint pts[2], const GradData& data,
76 SkShader::TileMode tm, const SkMatrix& localMatrix) {
77 SkPoint center0, center1;
78 center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
79 SkScalarAve(pts[0].fY, pts[1].fY));
80 center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
81 SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
82 return SkGradientShader::MakeTwoPointConical(center0, (pts[1].fX - pts[0].fX) / 2,
83 center1, (pts[1].fX - pts[0].fX) / 7,
84 data.fColors, data.fPos, data.fCount, tm,
85 0, &localMatrix);
86}
87
88static sk_sp<SkShader> Make2ConicalInsideCenter(const SkPoint pts[2], const GradData& data,
commit-bot@chromium.org83f23d82014-05-22 12:27:41 +000089 SkShader::TileMode tm, const SkMatrix& localMatrix) {
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +000090 SkPoint center0, center1;
91 center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
92 SkScalarAve(pts[0].fY, pts[1].fY));
93 center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
94 SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
reed1a9b9642016-03-13 14:13:58 -070095 return SkGradientShader::MakeTwoPointConical(center0, (pts[1].fX - pts[0].fX) / 7,
96 center0, (pts[1].fX - pts[0].fX) / 2,
97 data.fColors, data.fPos, data.fCount, tm,
98 0, &localMatrix);
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +000099}
100
reed1a9b9642016-03-13 14:13:58 -0700101static sk_sp<SkShader> Make2ConicalZeroRad(const SkPoint pts[2], const GradData& data,
102 SkShader::TileMode tm, const SkMatrix& localMatrix) {
103 SkPoint center0, center1;
104 center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
105 SkScalarAve(pts[0].fY, pts[1].fY));
106 center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
107 SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
108 return SkGradientShader::MakeTwoPointConical(center1, 0.f,
109 center0, (pts[1].fX - pts[0].fX) / 2,
110 data.fColors, data.fPos, data.fCount, tm,
111 0, &localMatrix);
112}
113
114static sk_sp<SkShader> Make2ConicalZeroRadFlip(const SkPoint pts[2], const GradData& data,
115 SkShader::TileMode tm, const SkMatrix& localMatrix) {
116 SkPoint center0, center1;
117 center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
118 SkScalarAve(pts[0].fY, pts[1].fY));
119 center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
120 SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
121 return SkGradientShader::MakeTwoPointConical(center1, (pts[1].fX - pts[0].fX) / 2,
122 center0, 0.f,
123 data.fColors, data.fPos, data.fCount, tm,
124 0, &localMatrix);
125}
126
127static sk_sp<SkShader> Make2ConicalZeroRadCenter(const SkPoint pts[2], const GradData& data,
commit-bot@chromium.org83f23d82014-05-22 12:27:41 +0000128 SkShader::TileMode tm, const SkMatrix& localMatrix) {
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000129 SkPoint center0, center1;
130 center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
131 SkScalarAve(pts[0].fY, pts[1].fY));
132 center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
133 SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
reed1a9b9642016-03-13 14:13:58 -0700134 return SkGradientShader::MakeTwoPointConical(center0, 0.f, center0, (pts[1].fX - pts[0].fX) / 2,
135 data.fColors, data.fPos, data.fCount, tm,
136 0, &localMatrix);
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000137}
138
reed1a9b9642016-03-13 14:13:58 -0700139static sk_sp<SkShader> Make2ConicalZeroRadOutside(const SkPoint pts[2], const GradData& data,
140 SkShader::TileMode tm,
141 const SkMatrix& localMatrix) {
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000142 SkPoint center0, center1;
commit-bot@chromium.org80894672014-04-22 21:24:22 +0000143 SkScalar radius0 = 0.f;
reed80ea19c2015-05-12 10:37:34 -0700144 SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3;
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000145 center0.set(pts[0].fX + radius0, pts[0].fY + radius0);
146 center1.set(pts[1].fX - radius1, pts[1].fY - radius1);
reed1a9b9642016-03-13 14:13:58 -0700147 return SkGradientShader::MakeTwoPointConical(center0, radius0, center1, radius1,
148 data.fColors, data.fPos,
149 data.fCount, tm, 0, &localMatrix);
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000150}
151
reed1a9b9642016-03-13 14:13:58 -0700152static sk_sp<SkShader> Make2ConicalZeroRadFlipOutside(const SkPoint pts[2], const GradData& data,
153 SkShader::TileMode tm,
154 const SkMatrix& localMatrix) {
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000155 SkPoint center0, center1;
commit-bot@chromium.org80894672014-04-22 21:24:22 +0000156 SkScalar radius0 = 0.f;
reed80ea19c2015-05-12 10:37:34 -0700157 SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3;
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000158 center0.set(pts[0].fX + radius0, pts[0].fY + radius0);
159 center1.set(pts[1].fX - radius1, pts[1].fY - radius1);
reed1a9b9642016-03-13 14:13:58 -0700160 return SkGradientShader::MakeTwoPointConical(center1, radius1, center0, radius0, data.fColors,
161 data.fPos, data.fCount, tm, 0, &localMatrix);
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000162}
163
reed1a9b9642016-03-13 14:13:58 -0700164static sk_sp<SkShader> Make2ConicalEdgeX(const SkPoint pts[2], const GradData& data,
165 SkShader::TileMode tm, const SkMatrix& localMatrix) {
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000166 SkPoint center0, center1;
reed80ea19c2015-05-12 10:37:34 -0700167 SkScalar radius0 = (pts[1].fX - pts[0].fX) / 7;
168 SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3;
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000169 center1.set(SkScalarAve(pts[0].fX, pts[1].fX),
170 SkScalarAve(pts[0].fY, pts[1].fY));
171 center0.set(center1.fX + radius1, center1.fY);
reed1a9b9642016-03-13 14:13:58 -0700172 return SkGradientShader::MakeTwoPointConical(center0, radius0, center1, radius1, data.fColors,
173 data.fPos, data.fCount, tm, 0, &localMatrix);
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000174}
175
reed1a9b9642016-03-13 14:13:58 -0700176static sk_sp<SkShader> Make2ConicalEdgeY(const SkPoint pts[2], const GradData& data,
177 SkShader::TileMode tm, const SkMatrix& localMatrix) {
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000178 SkPoint center0, center1;
reed80ea19c2015-05-12 10:37:34 -0700179 SkScalar radius0 = (pts[1].fX - pts[0].fX) / 7;
180 SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3;
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000181 center1.set(SkScalarAve(pts[0].fX, pts[1].fX),
182 SkScalarAve(pts[0].fY, pts[1].fY));
183 center0.set(center1.fX, center1.fY + radius1);
reed1a9b9642016-03-13 14:13:58 -0700184 return SkGradientShader::MakeTwoPointConical(center0, radius0, center1, radius1, data.fColors,
185 data.fPos, data.fCount, tm, 0, &localMatrix);
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000186}
egdaniel8405ef92014-06-09 11:57:28 -0700187
reed1a9b9642016-03-13 14:13:58 -0700188static sk_sp<SkShader> Make2ConicalZeroRadEdgeX(const SkPoint pts[2], const GradData& data,
189 SkShader::TileMode tm,
190 const SkMatrix& localMatrix) {
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000191 SkPoint center0, center1;
commit-bot@chromium.org80894672014-04-22 21:24:22 +0000192 SkScalar radius0 = 0.f;
reed80ea19c2015-05-12 10:37:34 -0700193 SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3;
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000194 center1.set(SkScalarAve(pts[0].fX, pts[1].fX),
195 SkScalarAve(pts[0].fY, pts[1].fY));
196 center0.set(center1.fX + radius1, center1.fY);
reed1a9b9642016-03-13 14:13:58 -0700197 return SkGradientShader::MakeTwoPointConical(center0, radius0, center1, radius1, data.fColors,
198 data.fPos, data.fCount, tm, 0, &localMatrix);
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000199}
200
reed1a9b9642016-03-13 14:13:58 -0700201static sk_sp<SkShader> Make2ConicalZeroRadEdgeY(const SkPoint pts[2], const GradData& data,
202 SkShader::TileMode tm, const SkMatrix& localMatrix) {
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000203 SkPoint center0, center1;
commit-bot@chromium.org80894672014-04-22 21:24:22 +0000204 SkScalar radius0 = 0.f;
reed80ea19c2015-05-12 10:37:34 -0700205 SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3;
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000206 center1.set(SkScalarAve(pts[0].fX, pts[1].fX),
207 SkScalarAve(pts[0].fY, pts[1].fY));
208 center0.set(center1.fX, center1.fY + radius1);
reed1a9b9642016-03-13 14:13:58 -0700209 return SkGradientShader::MakeTwoPointConical(center0, radius0, center1, radius1, data.fColors,
210 data.fPos, data.fCount, tm, 0, &localMatrix);
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000211}
212
reed1a9b9642016-03-13 14:13:58 -0700213static sk_sp<SkShader> Make2ConicalTouchX(const SkPoint pts[2], const GradData& data,
214 SkShader::TileMode tm, const SkMatrix& localMatrix) {
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000215 SkPoint center0, center1;
reed80ea19c2015-05-12 10:37:34 -0700216 SkScalar radius0 = (pts[1].fX - pts[0].fX) / 7;
217 SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3;
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000218 center1.set(SkScalarAve(pts[0].fX, pts[1].fX),
219 SkScalarAve(pts[0].fY, pts[1].fY));
220 center0.set(center1.fX - radius1 + radius0, center1.fY);
reed1a9b9642016-03-13 14:13:58 -0700221 return SkGradientShader::MakeTwoPointConical(center0, radius0, center1, radius1, data.fColors,
222 data.fPos, data.fCount, tm, 0, &localMatrix);
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000223}
224
reed1a9b9642016-03-13 14:13:58 -0700225static sk_sp<SkShader> Make2ConicalTouchY(const SkPoint pts[2], const GradData& data,
226 SkShader::TileMode tm, const SkMatrix& localMatrix) {
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000227 SkPoint center0, center1;
reed80ea19c2015-05-12 10:37:34 -0700228 SkScalar radius0 = (pts[1].fX - pts[0].fX) / 7;
229 SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3;
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000230 center1.set(SkScalarAve(pts[0].fX, pts[1].fX),
231 SkScalarAve(pts[0].fY, pts[1].fY));
232 center0.set(center1.fX, center1.fY + radius1 - radius0);
reed1a9b9642016-03-13 14:13:58 -0700233 return SkGradientShader::MakeTwoPointConical(center0, radius0, center1, radius1, data.fColors,
234 data.fPos, data.fCount, tm, 0, &localMatrix);
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000235}
236
reed1a9b9642016-03-13 14:13:58 -0700237static sk_sp<SkShader> Make2ConicalInsideSmallRad(const SkPoint pts[2], const GradData& data,
commit-bot@chromium.org83f23d82014-05-22 12:27:41 +0000238 SkShader::TileMode tm, const SkMatrix& localMatrix) {
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000239 SkPoint center0, center1;
240 center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
241 SkScalarAve(pts[0].fY, pts[1].fY));
242 center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
243 SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
reed1a9b9642016-03-13 14:13:58 -0700244 return SkGradientShader::MakeTwoPointConical(center0, 0.0000000000000000001f,
commit-bot@chromium.org9c9005a2014-04-28 14:55:39 +0000245 center0, (pts[1].fX - pts[0].fX) / 2,
commit-bot@chromium.org83f23d82014-05-22 12:27:41 +0000246 data.fColors, data.fPos, data.fCount, tm,
commit-bot@chromium.org9c9005a2014-04-28 14:55:39 +0000247 0, &localMatrix);
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000248}
249
reed1a9b9642016-03-13 14:13:58 -0700250typedef sk_sp<SkShader> (*GradMaker)(const SkPoint pts[2], const GradData& data,
251 SkShader::TileMode tm, const SkMatrix& localMatrix);
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000252
253static const GradMaker gGradMakersOutside[] = {
254 Make2ConicalOutside, Make2ConicalOutsideFlip,
255 Make2ConicalZeroRadOutside, Make2ConicalZeroRadFlipOutside
256};
257
258static const GradMaker gGradMakersInside[] = {
259 Make2ConicalInside, Make2ConicalInsideFlip, Make2ConicalInsideCenter,
260 Make2ConicalZeroRad, Make2ConicalZeroRadFlip, Make2ConicalZeroRadCenter,
261};
262
263static const GradMaker gGradMakersEdgeCases[] = {
264 Make2ConicalEdgeX, Make2ConicalEdgeY,
265 Make2ConicalZeroRadEdgeX, Make2ConicalZeroRadEdgeY,
266 Make2ConicalTouchX, Make2ConicalTouchY,
267 Make2ConicalInsideSmallRad
268};
269
270
271static const struct {
272 const GradMaker* fMaker;
273 const int fCount;
274 const char* fName;
275} gGradCases[] = {
276 { gGradMakersOutside, SK_ARRAY_COUNT(gGradMakersOutside), "outside" },
277 { gGradMakersInside, SK_ARRAY_COUNT(gGradMakersInside), "inside" },
278 { gGradMakersEdgeCases, SK_ARRAY_COUNT(gGradMakersEdgeCases), "edge" },
279};
280
281enum GradCaseType { // these must match the order in gGradCases
282 kOutside_GradCaseType,
283 kInside_GradCaseType,
284 kEdge_GradCaseType,
285};
286
287///////////////////////////////////////////////////////////////////////////////
288
289class ConicalGradientsGM : public GM {
290public:
fmalita063675b2015-10-12 10:41:48 -0700291 ConicalGradientsGM(GradCaseType gradCaseType, bool dither)
292 : fGradCaseType(gradCaseType)
293 , fDither(dither) {
caryclark65cdba62015-06-15 06:51:08 -0700294 this->setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD));
fmalita063675b2015-10-12 10:41:48 -0700295 fName.printf("gradients_2pt_conical_%s%s", gGradCases[gradCaseType].fName,
296 fDither ? "" : "_nodither");
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000297 }
298
299protected:
300 SkString onShortName() {
301 return fName;
302 }
303
304 virtual SkISize onISize() { return SkISize::Make(840, 815); }
305
306 virtual void onDraw(SkCanvas* canvas) {
307
308 SkPoint pts[2] = {
309 { 0, 0 },
310 { SkIntToScalar(100), SkIntToScalar(100) }
311 };
312 SkShader::TileMode tm = SkShader::kClamp_TileMode;
313 SkRect r = { 0, 0, SkIntToScalar(100), SkIntToScalar(100) };
314 SkPaint paint;
315 paint.setAntiAlias(true);
fmalita063675b2015-10-12 10:41:48 -0700316 paint.setDither(fDither);
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000317
318 canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
319
320 const GradMaker* gradMaker = gGradCases[fGradCaseType].fMaker;
321 const int count = gGradCases[fGradCaseType].fCount;
322
323 for (size_t i = 0; i < SK_ARRAY_COUNT(gGradData); i++) {
324 canvas->save();
325 for (int j = 0; j < count; j++) {
commit-bot@chromium.org9c9005a2014-04-28 14:55:39 +0000326 SkMatrix scale = SkMatrix::I();
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000327
328 if (i == 3) { // if the clamp case
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000329 scale.setScale(0.5f, 0.5f);
330 scale.postTranslate(25.f, 25.f);
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000331 }
332
reed1a9b9642016-03-13 14:13:58 -0700333 paint.setShader(gradMaker[j](pts, gGradData[i], tm, scale));
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000334 canvas->drawRect(r, paint);
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000335 canvas->translate(0, SkIntToScalar(120));
336 }
337 canvas->restore();
338 canvas->translate(SkIntToScalar(120), 0);
339 }
340 }
341
342private:
343 typedef GM INHERITED;
344
345 GradCaseType fGradCaseType;
346 SkString fName;
fmalita063675b2015-10-12 10:41:48 -0700347 bool fDither;
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000348};
349///////////////////////////////////////////////////////////////////////////////
350
fmalita063675b2015-10-12 10:41:48 -0700351DEF_GM( return new ConicalGradientsGM(kInside_GradCaseType, true); )
352DEF_GM( return new ConicalGradientsGM(kOutside_GradCaseType, true); )
353DEF_GM( return new ConicalGradientsGM(kEdge_GradCaseType, true); )
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000354
fmalita063675b2015-10-12 10:41:48 -0700355DEF_GM( return new ConicalGradientsGM(kInside_GradCaseType, false); )
356DEF_GM( return new ConicalGradientsGM(kOutside_GradCaseType, false); )
357DEF_GM( return new ConicalGradientsGM(kEdge_GradCaseType, false); )
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000358
commit-bot@chromium.orgc8379d72014-04-22 20:56:37 +0000359}