| 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 = SkScalarDiv(SkIntToScalar(width), scale); | 83 SkScalar shaderWidth = width / scale; |
| 84 SkScalar shaderHeight = SkScalarDiv(SkIntToScalar(height), scale); | 84 SkScalar shaderHeight = height / scale; |
| 85 SkMatrix shaderScale; | 85 SkMatrix shaderScale = SkMatrix::MakeScale(scale); |
| 86 shaderScale.setScale(scale, scale); | |
| 87 SkShader* shader = fShaderMaker(shaderWidth, shaderHeight, background, s
haderScale); | 86 SkShader* shader = fShaderMaker(shaderWidth, shaderHeight, background, s
haderScale); |
| 88 return shader; | 87 return shader; |
| 89 } | 88 } |
| 90 | 89 |
| 91 private: | 90 private: |
| 92 typedef GM INHERITED; | 91 typedef GM INHERITED; |
| 93 | 92 |
| 94 ShaderGenFunc fShaderMaker; | 93 ShaderGenFunc fShaderMaker; |
| 95 SkString fName; | 94 SkString fName; |
| 96 | 95 |
| 97 SkShader* MakeShader(bool background); | 96 SkShader* MakeShader(bool background); |
| 98 }; | 97 }; |
| 99 | 98 |
| 100 /////////////////////////////////////////////////////////////////////////////// | 99 /////////////////////////////////////////////////////////////////////////////// |
| 101 | 100 |
| 102 static GM* MyFactory(void*) { | 101 static GM* MyFactory(void*) { |
| 103 return new ShaderBoundsGM(MakeLinear, SkString("shaderbounds_linear")); | 102 return new ShaderBoundsGM(MakeLinear, SkString("shaderbounds_linear")); |
| 104 } | 103 } |
| 105 static GMRegistry reg(MyFactory); | 104 static GMRegistry reg(MyFactory); |
| 106 | 105 |
| 107 } | 106 } |
| OLD | NEW |