OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "gm.h" | 8 #include "gm.h" |
9 #include "SkPath.h" | 9 #include "SkPath.h" |
10 #include "SkRegion.h" | 10 #include "SkRegion.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 164 |
165 static SkShader* make_grad(SkShader::TileMode tx, SkShader::TileMode ty) { | 165 static SkShader* make_grad(SkShader::TileMode tx, SkShader::TileMode ty) { |
166 SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(gWidth), SkIntToScalar(gHeight)}
}; | 166 SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(gWidth), SkIntToScalar(gHeight)}
}; |
167 SkPoint center = { SkIntToScalar(gWidth)/2, SkIntToScalar(gHeight)/2 }; | 167 SkPoint center = { SkIntToScalar(gWidth)/2, SkIntToScalar(gHeight)/2 }; |
168 SkScalar rad = SkIntToScalar(gWidth)/2; | 168 SkScalar rad = SkIntToScalar(gWidth)/2; |
169 SkColor colors[] = { 0xFFFF0000, sk_tool_utils::color_to_565(0xFF0044FF) }; | 169 SkColor colors[] = { 0xFFFF0000, sk_tool_utils::color_to_565(0xFF0044FF) }; |
170 | 170 |
171 int index = (int)ty; | 171 int index = (int)ty; |
172 switch (index % 3) { | 172 switch (index % 3) { |
173 case 0: | 173 case 0: |
174 return SkGradientShader::CreateLinear(pts, colors, NULL, SK_ARRAY_CO
UNT(colors), tx); | 174 return SkGradientShader::CreateLinear(pts, colors, nullptr, SK_ARRAY
_COUNT(colors), tx); |
175 case 1: | 175 case 1: |
176 return SkGradientShader::CreateRadial(center, rad, colors, NULL, SK_
ARRAY_COUNT(colors), tx); | 176 return SkGradientShader::CreateRadial(center, rad, colors, nullptr,
SK_ARRAY_COUNT(colors), tx); |
177 case 2: | 177 case 2: |
178 return SkGradientShader::CreateSweep(center.fX, center.fY, colors, N
ULL, SK_ARRAY_COUNT(colors)); | 178 return SkGradientShader::CreateSweep(center.fX, center.fY, colors, n
ullptr, SK_ARRAY_COUNT(colors)); |
179 } | 179 } |
180 | 180 |
181 return NULL; | 181 return nullptr; |
182 } | 182 } |
183 | 183 |
184 typedef SkShader* (*ShaderProc)(SkShader::TileMode, SkShader::TileMode); | 184 typedef SkShader* (*ShaderProc)(SkShader::TileMode, SkShader::TileMode); |
185 | 185 |
186 class Tiling2GM : public skiagm::GM { | 186 class Tiling2GM : public skiagm::GM { |
187 ShaderProc fProc; | 187 ShaderProc fProc; |
188 SkString fName; | 188 SkString fName; |
189 public: | 189 public: |
190 Tiling2GM(ShaderProc proc, const char name[]) : fProc(proc) { | 190 Tiling2GM(ShaderProc proc, const char name[]) : fProc(proc) { |
191 fName.printf("tilemode_%s", name); | 191 fName.printf("tilemode_%s", name); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 private: | 255 private: |
256 typedef skiagm::GM INHERITED; | 256 typedef skiagm::GM INHERITED; |
257 }; | 257 }; |
258 | 258 |
259 ////////////////////////////////////////////////////////////////////////////// | 259 ////////////////////////////////////////////////////////////////////////////// |
260 | 260 |
261 DEF_GM( return new TilingGM(true); ) | 261 DEF_GM( return new TilingGM(true); ) |
262 DEF_GM( return new TilingGM(false); ) | 262 DEF_GM( return new TilingGM(false); ) |
263 DEF_GM( return new Tiling2GM(make_bm, "bitmap"); ) | 263 DEF_GM( return new Tiling2GM(make_bm, "bitmap"); ) |
264 DEF_GM( return new Tiling2GM(make_grad, "gradient"); ) | 264 DEF_GM( return new Tiling2GM(make_grad, "gradient"); ) |
OLD | NEW |