OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
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 #include "gm.h" | 8 #include "gm.h" |
9 #include "SkGradientShader.h" | 9 #include "SkGradientShader.h" |
10 | 10 |
11 typedef SkShader* (*MakeShaderProc)(const SkColor[], int count, const SkSize&); | 11 typedef SkShader* (*MakeShaderProc)(const SkColor[], int count, const SkSize&); |
12 | 12 |
13 static SkShader* shader_linear(const SkColor colors[], int count, const SkSize&
size) { | 13 static SkShader* shader_linear(const SkColor colors[], int count, const SkSize&
size) { |
14 SkPoint pts[] = { { 0, 0 }, { size.width(), size.height() } }; | 14 SkPoint pts[] = { { 0, 0 }, { size.width(), size.height() } }; |
15 return SkGradientShader::CreateLinear(pts, colors, NULL, count, | 15 return SkGradientShader::CreateLinear(pts, colors, nullptr, count, |
16 SkShader::kClamp_TileMode); | 16 SkShader::kClamp_TileMode); |
17 } | 17 } |
18 | 18 |
19 static SkShader* shader_radial(const SkColor colors[], int count, const SkSize&
size) { | 19 static SkShader* shader_radial(const SkColor colors[], int count, const SkSize&
size) { |
20 SkPoint center = { size.width()/2, size.height()/2 }; | 20 SkPoint center = { size.width()/2, size.height()/2 }; |
21 return SkGradientShader::CreateRadial(center, size.width()/2, colors, NULL,
count, | 21 return SkGradientShader::CreateRadial(center, size.width()/2, colors, nullpt
r, count, |
22 SkShader::kClamp_TileMode); | 22 SkShader::kClamp_TileMode); |
23 } | 23 } |
24 | 24 |
25 static SkShader* shader_conical(const SkColor colors[], int count, const SkSize&
size) { | 25 static SkShader* shader_conical(const SkColor colors[], int count, const SkSize&
size) { |
26 SkPoint center = { size.width()/2, size.height()/2 }; | 26 SkPoint center = { size.width()/2, size.height()/2 }; |
27 return SkGradientShader::CreateTwoPointConical(center, size.width()/64, | 27 return SkGradientShader::CreateTwoPointConical(center, size.width()/64, |
28 center, size.width()/2, | 28 center, size.width()/2, |
29 colors, NULL, count, | 29 colors, nullptr, count, |
30 SkShader::kClamp_TileMode); | 30 SkShader::kClamp_TileMode); |
31 } | 31 } |
32 | 32 |
33 static SkShader* shader_sweep(const SkColor colors[], int count, const SkSize& s
ize) { | 33 static SkShader* shader_sweep(const SkColor colors[], int count, const SkSize& s
ize) { |
34 return SkGradientShader::CreateSweep(size.width()/2, size.height()/2, | 34 return SkGradientShader::CreateSweep(size.width()/2, size.height()/2, |
35 colors, NULL, count); | 35 colors, nullptr, count); |
36 } | 36 } |
37 | 37 |
38 class ShallowGradientGM : public skiagm::GM { | 38 class ShallowGradientGM : public skiagm::GM { |
39 public: | 39 public: |
40 ShallowGradientGM(MakeShaderProc proc, const char name[]) : fProc(proc) { | 40 ShallowGradientGM(MakeShaderProc proc, const char name[]) : fProc(proc) { |
41 fName.printf("shallow_gradient_%s", name); | 41 fName.printf("shallow_gradient_%s", name); |
42 } | 42 } |
43 | 43 |
44 protected: | 44 protected: |
45 | 45 |
(...skipping 24 matching lines...) Expand all Loading... |
70 | 70 |
71 typedef skiagm::GM INHERITED; | 71 typedef skiagm::GM INHERITED; |
72 }; | 72 }; |
73 | 73 |
74 /////////////////////////////////////////////////////////////////////////////// | 74 /////////////////////////////////////////////////////////////////////////////// |
75 | 75 |
76 DEF_GM( return new ShallowGradientGM(shader_linear, "linear"); ) | 76 DEF_GM( return new ShallowGradientGM(shader_linear, "linear"); ) |
77 DEF_GM( return new ShallowGradientGM(shader_radial, "radial"); ) | 77 DEF_GM( return new ShallowGradientGM(shader_radial, "radial"); ) |
78 DEF_GM( return new ShallowGradientGM(shader_conical, "conical"); ) | 78 DEF_GM( return new ShallowGradientGM(shader_conical, "conical"); ) |
79 DEF_GM( return new ShallowGradientGM(shader_sweep, "sweep"); ) | 79 DEF_GM( return new ShallowGradientGM(shader_sweep, "sweep"); ) |
OLD | NEW |