| 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 { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 SkIntToScalar(101), SkIntToScalar(151)); | 73 SkIntToScalar(101), SkIntToScalar(151)); |
| 74 canvas->clipRect(r); | 74 canvas->clipRect(r); |
| 75 canvas->drawRect(r, paint); | 75 canvas->drawRect(r, paint); |
| 76 } | 76 } |
| 77 | 77 |
| 78 SkShader* MakeShader(int width, int height, bool background) { | 78 SkShader* MakeShader(int width, int height, bool background) { |
| 79 SkScalar scale = 0.5f; | 79 SkScalar scale = 0.5f; |
| 80 if (background) { | 80 if (background) { |
| 81 scale = 0.6f; | 81 scale = 0.6f; |
| 82 } | 82 } |
| 83 SkScalar shaderWidth = width / scale; | 83 SkScalar shaderWidth = SkScalarDiv(SkIntToScalar(width), scale); |
| 84 SkScalar shaderHeight = height / scale; | 84 SkScalar shaderHeight = SkScalarDiv(SkIntToScalar(height), scale); |
| 85 SkMatrix shaderScale = SkMatrix::MakeScale(scale); | 85 SkMatrix shaderScale; |
| 86 shaderScale.setScale(scale, scale); |
| 86 SkShader* shader = fShaderMaker(shaderWidth, shaderHeight, background, s
haderScale); | 87 SkShader* shader = fShaderMaker(shaderWidth, shaderHeight, background, s
haderScale); |
| 87 return shader; | 88 return shader; |
| 88 } | 89 } |
| 89 | 90 |
| 90 private: | 91 private: |
| 91 typedef GM INHERITED; | 92 typedef GM INHERITED; |
| 92 | 93 |
| 93 ShaderGenFunc fShaderMaker; | 94 ShaderGenFunc fShaderMaker; |
| 94 SkString fName; | 95 SkString fName; |
| 95 | 96 |
| 96 SkShader* MakeShader(bool background); | 97 SkShader* MakeShader(bool background); |
| 97 }; | 98 }; |
| 98 | 99 |
| 99 /////////////////////////////////////////////////////////////////////////////// | 100 /////////////////////////////////////////////////////////////////////////////// |
| 100 | 101 |
| 101 static GM* MyFactory(void*) { | 102 static GM* MyFactory(void*) { |
| 102 return new ShaderBoundsGM(MakeLinear, SkString("shaderbounds_linear")); | 103 return new ShaderBoundsGM(MakeLinear, SkString("shaderbounds_linear")); |
| 103 } | 104 } |
| 104 static GMRegistry reg(MyFactory); | 105 static GMRegistry reg(MyFactory); |
| 105 | 106 |
| 106 } | 107 } |
| OLD | NEW |