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

Side by Side Diff: bench/GradientBench.cpp

Issue 1135053002: stop calling SkScalarDiv (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix xpsdevice 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 | « no previous file | experimental/StrokePathRenderer/GrStrokePathRenderer.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "Benchmark.h" 8 #include "Benchmark.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4)); 94 SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
95 return SkGradientShader::CreateTwoPointConical(center1, 0.0, 95 return SkGradientShader::CreateTwoPointConical(center1, 0.0,
96 center0, (pts[1].fX - pts[0]. fX) / 2, 96 center0, (pts[1].fX - pts[0]. fX) / 2,
97 data.fColors, data.fPos, data .fCount, tm); 97 data.fColors, data.fPos, data .fCount, tm);
98 } 98 }
99 99
100 /// Ignores scale 100 /// Ignores scale
101 static SkShader* MakeConicalOutside(const SkPoint pts[2], const GradData& data, 101 static SkShader* MakeConicalOutside(const SkPoint pts[2], const GradData& data,
102 SkShader::TileMode tm, float scale) { 102 SkShader::TileMode tm, float scale) {
103 SkPoint center0, center1; 103 SkPoint center0, center1;
104 SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 10); 104 SkScalar radius0 = (pts[1].fX - pts[0].fX) / 10;
105 SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3); 105 SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3;
106 center0.set(pts[0].fX + radius0, pts[0].fY + radius0); 106 center0.set(pts[0].fX + radius0, pts[0].fY + radius0);
107 center1.set(pts[1].fX - radius1, pts[1].fY - radius1); 107 center1.set(pts[1].fX - radius1, pts[1].fY - radius1);
108 return SkGradientShader::CreateTwoPointConical(center0, radius0, 108 return SkGradientShader::CreateTwoPointConical(center0, radius0,
109 center1, radius1, 109 center1, radius1,
110 data.fColors, data.fPos, 110 data.fColors, data.fPos,
111 data.fCount, tm); 111 data.fCount, tm);
112 } 112 }
113 113
114 /// Ignores scale 114 /// Ignores scale
115 static SkShader* MakeConicalOutsideZeroRad(const SkPoint pts[2], const GradData& data, 115 static SkShader* MakeConicalOutsideZeroRad(const SkPoint pts[2], const GradData& data,
116 SkShader::TileMode tm, float scale) { 116 SkShader::TileMode tm, float scale) {
117 SkPoint center0, center1; 117 SkPoint center0, center1;
118 SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 10); 118 SkScalar radius0 = (pts[1].fX - pts[0].fX) / 10;
119 SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3); 119 SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3;
120 center0.set(pts[0].fX + radius0, pts[0].fY + radius0); 120 center0.set(pts[0].fX + radius0, pts[0].fY + radius0);
121 center1.set(pts[1].fX - radius1, pts[1].fY - radius1); 121 center1.set(pts[1].fX - radius1, pts[1].fY - radius1);
122 return SkGradientShader::CreateTwoPointConical(center0, 0.0, 122 return SkGradientShader::CreateTwoPointConical(center0, 0.0,
123 center1, radius1, 123 center1, radius1,
124 data.fColors, data.fPos, 124 data.fColors, data.fPos,
125 data.fCount, tm); 125 data.fCount, tm);
126 } 126 }
127 127
128 typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data, 128 typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data,
129 SkShader::TileMode tm, float scale); 129 SkShader::TileMode tm, float scale);
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 canvas->drawRect(r, paint); 361 canvas->drawRect(r, paint);
362 } 362 }
363 } 363 }
364 364
365 private: 365 private:
366 typedef Benchmark INHERITED; 366 typedef Benchmark INHERITED;
367 }; 367 };
368 368
369 DEF_BENCH( return new Gradient2Bench(false); ) 369 DEF_BENCH( return new Gradient2Bench(false); )
370 DEF_BENCH( return new Gradient2Bench(true); ) 370 DEF_BENCH( return new Gradient2Bench(true); )
OLDNEW
« no previous file with comments | « no previous file | experimental/StrokePathRenderer/GrStrokePathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698