Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Side by Side Diff: gm/shaderbounds.cpp

Issue 1135693003: Revert of Revert of stop calling SkScalarDiv (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gm/resizeimagefilter.cpp ('k') | gm/stringart.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « gm/resizeimagefilter.cpp ('k') | gm/stringart.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698