| 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, NULL, 2, |
| 22 SkShader::kClamp_TileMode, NULL, 0, &loc
alMatrix); | 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) |
| 32 : fShaderMaker(maker), | 32 : fShaderMaker(maker), |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 /////////////////////////////////////////////////////////////////////////////// | 103 /////////////////////////////////////////////////////////////////////////////// |
| 104 | 104 |
| 105 static GM* MyFactory(void*) { | 105 static GM* MyFactory(void*) { |
| 106 return new ShaderBoundsGM(MakeLinear, SkString("shaderbounds_linear")); | 106 return new ShaderBoundsGM(MakeLinear, SkString("shaderbounds_linear")); |
| 107 } | 107 } |
| 108 static GMRegistry reg(MyFactory); | 108 static GMRegistry reg(MyFactory); |
| 109 | 109 |
| 110 } | 110 } |
| OLD | NEW |