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

Side by Side Diff: bench/GradientBench.cpp

Issue 1117423003: remove redundant/deprecated TwoPointRadial gradiet -- use TwoPointConical (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 | « no previous file | gm/blurrect.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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 static SkShader* MakeSweep(const SkPoint pts[2], const GradData& data, 65 static SkShader* MakeSweep(const SkPoint pts[2], const GradData& data,
66 SkShader::TileMode tm, float scale) { 66 SkShader::TileMode tm, float scale) {
67 SkPoint center; 67 SkPoint center;
68 center.set(SkScalarAve(pts[0].fX, pts[1].fX), 68 center.set(SkScalarAve(pts[0].fX, pts[1].fX),
69 SkScalarAve(pts[0].fY, pts[1].fY)); 69 SkScalarAve(pts[0].fY, pts[1].fY));
70 return SkGradientShader::CreateSweep(center.fX, center.fY, data.fColors, 70 return SkGradientShader::CreateSweep(center.fX, center.fY, data.fColors,
71 data.fPos, data.fCount); 71 data.fPos, data.fCount);
72 } 72 }
73 73
74 /// Ignores scale 74 /// Ignores scale
75 static SkShader* Make2Radial(const SkPoint pts[2], const GradData& data,
76 SkShader::TileMode tm, float scale) {
77 SkPoint center0, center1;
78 center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
79 SkScalarAve(pts[0].fY, pts[1].fY));
80 center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
81 SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
82 return SkGradientShader::CreateTwoPointRadial(
83 center1, (pts[1].fX - pts[0].f X) / 7,
84 center0, (pts[1].fX - pts[0].f X) / 2,
85 data.fColors, data.fPos, data. fCount, tm);
86 }
87
88 /// Ignores scale
89 static SkShader* MakeConical(const SkPoint pts[2], const GradData& data, 75 static SkShader* MakeConical(const SkPoint pts[2], const GradData& data,
90 SkShader::TileMode tm, float scale) { 76 SkShader::TileMode tm, float scale) {
91 SkPoint center0, center1; 77 SkPoint center0, center1;
92 center0.set(SkScalarAve(pts[0].fX, pts[1].fX), 78 center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
93 SkScalarAve(pts[0].fY, pts[1].fY)); 79 SkScalarAve(pts[0].fY, pts[1].fY));
94 center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5), 80 center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
95 SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4)); 81 SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
96 return SkGradientShader::CreateTwoPointConical(center1, (pts[1].fX - pts[0]. fX) / 7, 82 return SkGradientShader::CreateTwoPointConical(center1, (pts[1].fX - pts[0]. fX) / 7,
97 center0, (pts[1].fX - pts[0]. fX) / 2, 83 center0, (pts[1].fX - pts[0]. fX) / 2,
98 data.fColors, data.fPos, data .fCount, tm); 84 data.fColors, data.fPos, data .fCount, tm);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data, 128 typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data,
143 SkShader::TileMode tm, float scale); 129 SkShader::TileMode tm, float scale);
144 130
145 static const struct { 131 static const struct {
146 GradMaker fMaker; 132 GradMaker fMaker;
147 const char* fName; 133 const char* fName;
148 } gGrads[] = { 134 } gGrads[] = {
149 { MakeLinear, "linear" }, 135 { MakeLinear, "linear" },
150 { MakeRadial, "radial1" }, 136 { MakeRadial, "radial1" },
151 { MakeSweep, "sweep" }, 137 { MakeSweep, "sweep" },
152 { Make2Radial, "radial2" },
153 { MakeConical, "conical" }, 138 { MakeConical, "conical" },
154 { MakeConicalZeroRad, "conicalZero" }, 139 { MakeConicalZeroRad, "conicalZero" },
155 { MakeConicalOutside, "conicalOut" }, 140 { MakeConicalOutside, "conicalOut" },
156 { MakeConicalOutsideZeroRad, "conicalOutZero" }, 141 { MakeConicalOutsideZeroRad, "conicalOutZero" },
157 }; 142 };
158 143
159 enum GradType { // these must match the order in gGrads 144 enum GradType { // these must match the order in gGrads
160 kLinear_GradType, 145 kLinear_GradType,
161 kRadial_GradType, 146 kRadial_GradType,
162 kSweep_GradType, 147 kSweep_GradType,
163 kRadial2_GradType,
164 kConical_GradType, 148 kConical_GradType,
165 kConicalZero_GradType, 149 kConicalZero_GradType,
166 kConicalOut_GradType, 150 kConicalOut_GradType,
167 kConicalOutZero_GradType 151 kConicalOutZero_GradType
168 }; 152 };
169 153
170 enum GeomType { 154 enum GeomType {
171 kRect_GeomType, 155 kRect_GeomType,
172 kOval_GeomType 156 kOval_GeomType
173 }; 157 };
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 290
307 // Draw a radial gradient on a circle of equal size; all the lines should 291 // Draw a radial gradient on a circle of equal size; all the lines should
308 // hit the unpinned fast path (so long as GradientBench.W == H) 292 // hit the unpinned fast path (so long as GradientBench.W == H)
309 DEF_BENCH( return new GradientBench(kRadial_GradType, gGradData[0], SkShader::kC lamp_TileMode, kOval_GeomType); ) 293 DEF_BENCH( return new GradientBench(kRadial_GradType, gGradData[0], SkShader::kC lamp_TileMode, kOval_GeomType); )
310 294
311 DEF_BENCH( return new GradientBench(kRadial_GradType, gGradData[0], SkShader::kM irror_TileMode); ) 295 DEF_BENCH( return new GradientBench(kRadial_GradType, gGradData[0], SkShader::kM irror_TileMode); )
312 DEF_BENCH( return new GradientBench(kRadial_GradType, gGradData[0], SkShader::kR epeat_TileMode); ) 296 DEF_BENCH( return new GradientBench(kRadial_GradType, gGradData[0], SkShader::kR epeat_TileMode); )
313 DEF_BENCH( return new GradientBench(kSweep_GradType); ) 297 DEF_BENCH( return new GradientBench(kSweep_GradType); )
314 DEF_BENCH( return new GradientBench(kSweep_GradType, gGradData[1]); ) 298 DEF_BENCH( return new GradientBench(kSweep_GradType, gGradData[1]); )
315 DEF_BENCH( return new GradientBench(kSweep_GradType, gGradData[2]); ) 299 DEF_BENCH( return new GradientBench(kSweep_GradType, gGradData[2]); )
316 DEF_BENCH( return new GradientBench(kRadial2_GradType); )
317 DEF_BENCH( return new GradientBench(kRadial2_GradType, gGradData[1]); )
318 DEF_BENCH( return new GradientBench(kRadial2_GradType, gGradData[0], SkShader::k Mirror_TileMode); )
319 DEF_BENCH( return new GradientBench(kConical_GradType); ) 300 DEF_BENCH( return new GradientBench(kConical_GradType); )
320 DEF_BENCH( return new GradientBench(kConical_GradType, gGradData[1]); ) 301 DEF_BENCH( return new GradientBench(kConical_GradType, gGradData[1]); )
321 DEF_BENCH( return new GradientBench(kConical_GradType, gGradData[2]); ) 302 DEF_BENCH( return new GradientBench(kConical_GradType, gGradData[2]); )
322 DEF_BENCH( return new GradientBench(kConicalZero_GradType); ) 303 DEF_BENCH( return new GradientBench(kConicalZero_GradType); )
323 DEF_BENCH( return new GradientBench(kConicalZero_GradType, gGradData[1]); ) 304 DEF_BENCH( return new GradientBench(kConicalZero_GradType, gGradData[1]); )
324 DEF_BENCH( return new GradientBench(kConicalZero_GradType, gGradData[2]); ) 305 DEF_BENCH( return new GradientBench(kConicalZero_GradType, gGradData[2]); )
325 DEF_BENCH( return new GradientBench(kConicalOut_GradType); ) 306 DEF_BENCH( return new GradientBench(kConicalOut_GradType); )
326 DEF_BENCH( return new GradientBench(kConicalOut_GradType, gGradData[1]); ) 307 DEF_BENCH( return new GradientBench(kConicalOut_GradType, gGradData[1]); )
327 DEF_BENCH( return new GradientBench(kConicalOut_GradType, gGradData[2]); ) 308 DEF_BENCH( return new GradientBench(kConicalOut_GradType, gGradData[2]); )
328 DEF_BENCH( return new GradientBench(kConicalOutZero_GradType); ) 309 DEF_BENCH( return new GradientBench(kConicalOutZero_GradType); )
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 canvas->drawRect(r, paint); 361 canvas->drawRect(r, paint);
381 } 362 }
382 } 363 }
383 364
384 private: 365 private:
385 typedef Benchmark INHERITED; 366 typedef Benchmark INHERITED;
386 }; 367 };
387 368
388 DEF_BENCH( return new Gradient2Bench(false); ) 369 DEF_BENCH( return new Gradient2Bench(false); )
389 DEF_BENCH( return new Gradient2Bench(true); ) 370 DEF_BENCH( return new Gradient2Bench(true); )
OLDNEW
« no previous file with comments | « no previous file | gm/blurrect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698