OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #include "gm.h" | 7 #include "gm.h" |
8 #include "SkGradientShader.h" | 8 #include "SkGradientShader.h" |
9 | 9 |
10 namespace skiagm { | 10 namespace skiagm { |
11 | 11 |
12 static SkShader* MakeLinear(SkScalar width, SkScalar height, bool alternate, | 12 static SkShader* MakeLinear(SkScalar width, SkScalar height, bool alternate, |
13 const SkMatrix& localMatrix) { | 13 const SkMatrix& localMatrix) { |
14 SkPoint pts[2] = { {0, 0}, {width, height}}; | 14 SkPoint pts[2] = { {0, 0}, {width, height}}; |
15 SkColor colors[2] = {SK_ColorRED, SK_ColorGREEN}; | 15 SkColor colors[2] = {SK_ColorRED, SK_ColorGREEN}; |
16 if (alternate) { | 16 if (alternate) { |
17 pts[1].fY = 0; | 17 pts[1].fY = 0; |
18 colors[0] = SK_ColorBLUE; | 18 colors[0] = SK_ColorBLUE; |
19 colors[1] = SK_ColorYELLOW; | 19 colors[1] = SK_ColorYELLOW; |
20 } | 20 } |
21 return SkGradientShader::CreateLinear(pts, colors, NULL, 2, | 21 return SkGradientShader::CreateLinear(pts, colors, nullptr, 2, |
22 SkShader::kClamp_TileMode, 0, &localMatr
ix); | 22 SkShader::kClamp_TileMode, 0, &localMatr
ix); |
23 } | 23 } |
24 | 24 |
25 /////////////////////////////////////////////////////////////////////////////// | 25 /////////////////////////////////////////////////////////////////////////////// |
26 | 26 |
27 class ShaderBoundsGM : public GM { | 27 class ShaderBoundsGM : public GM { |
28 public: | 28 public: |
29 typedef SkShader* (*ShaderGenFunc)(SkScalar width, SkScalar height, | 29 typedef SkShader* (*ShaderGenFunc)(SkScalar width, SkScalar height, |
30 bool alternate, const SkMatrix& localMatr
ix); | 30 bool alternate, const SkMatrix& localMatr
ix); |
31 ShaderBoundsGM(ShaderGenFunc maker, const SkString& name) | 31 ShaderBoundsGM(ShaderGenFunc maker, const SkString& name) |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 }; | 97 }; |
98 | 98 |
99 /////////////////////////////////////////////////////////////////////////////// | 99 /////////////////////////////////////////////////////////////////////////////// |
100 | 100 |
101 static GM* MyFactory(void*) { | 101 static GM* MyFactory(void*) { |
102 return new ShaderBoundsGM(MakeLinear, SkString("shaderbounds_linear")); | 102 return new ShaderBoundsGM(MakeLinear, SkString("shaderbounds_linear")); |
103 } | 103 } |
104 static GMRegistry reg(MyFactory); | 104 static GMRegistry reg(MyFactory); |
105 | 105 |
106 } | 106 } |
OLD | NEW |