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

Side by Side Diff: bench/GradientBench.cpp

Issue 23876006: Refactoring: get rid of the SkBenchmark void* parameter. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: sync to head Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « bench/GrMemoryPoolBench.cpp ('k') | bench/HairlinePathBench.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 "SkBenchmark.h" 8 #include "SkBenchmark.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 158
159 class GradientBench : public SkBenchmark { 159 class GradientBench : public SkBenchmark {
160 SkString fName; 160 SkString fName;
161 SkShader* fShader; 161 SkShader* fShader;
162 int fRepeat; 162 int fRepeat;
163 enum { 163 enum {
164 W = 400, 164 W = 400,
165 H = 400, 165 H = 400,
166 }; 166 };
167 public: 167 public:
168 GradientBench(void* param, GradType gradType, 168 GradientBench(GradType gradType,
169 GradData data = gGradData[0], 169 GradData data = gGradData[0],
170 SkShader::TileMode tm = SkShader::kClamp_TileMode, 170 SkShader::TileMode tm = SkShader::kClamp_TileMode,
171 GeomType geomType = kRect_GeomType, 171 GeomType geomType = kRect_GeomType,
172 float scale = 1.0f 172 float scale = 1.0f
173 ) 173 )
174 : INHERITED(param) { 174 {
175 fName.printf("gradient_%s_%s", gGrads[gradType].fName, 175 fName.printf("gradient_%s_%s", gGrads[gradType].fName,
176 tilemodename(tm)); 176 tilemodename(tm));
177 if (geomType != kRect_GeomType) { 177 if (geomType != kRect_GeomType) {
178 fName.append("_"); 178 fName.append("_");
179 fName.append(geomtypename(geomType)); 179 fName.append(geomtypename(geomType));
180 } 180 }
181 181
182 fName.append(data.fName); 182 fName.append(data.fName);
183 183
184 const SkPoint pts[2] = { 184 const SkPoint pts[2] = {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 typedef SkBenchmark INHERITED; 223 typedef SkBenchmark INHERITED;
224 224
225 GeomType fGeomType; 225 GeomType fGeomType;
226 }; 226 };
227 227
228 class Gradient2Bench : public SkBenchmark { 228 class Gradient2Bench : public SkBenchmark {
229 SkString fName; 229 SkString fName;
230 bool fHasAlpha; 230 bool fHasAlpha;
231 231
232 public: 232 public:
233 Gradient2Bench(void* param, bool hasAlpha) : INHERITED(param) { 233 Gradient2Bench(bool hasAlpha) {
234 fName.printf("gradient_create_%s", hasAlpha ? "alpha" : "opaque"); 234 fName.printf("gradient_create_%s", hasAlpha ? "alpha" : "opaque");
235 fHasAlpha = hasAlpha; 235 fHasAlpha = hasAlpha;
236 } 236 }
237 237
238 protected: 238 protected:
239 virtual const char* onGetName() { 239 virtual const char* onGetName() {
240 return fName.c_str(); 240 return fName.c_str();
241 } 241 }
242 242
243 virtual void onDraw(SkCanvas* canvas) { 243 virtual void onDraw(SkCanvas* canvas) {
(...skipping 18 matching lines...) Expand all
262 SkShader::kClamp_TileMo de); 262 SkShader::kClamp_TileMo de);
263 paint.setShader(s)->unref(); 263 paint.setShader(s)->unref();
264 canvas->drawRect(r, paint); 264 canvas->drawRect(r, paint);
265 } 265 }
266 } 266 }
267 267
268 private: 268 private:
269 typedef SkBenchmark INHERITED; 269 typedef SkBenchmark INHERITED;
270 }; 270 };
271 271
272 DEF_BENCH( return new GradientBench(p, kLinear_GradType); ) 272 DEF_BENCH( return new GradientBench(kLinear_GradType); )
273 DEF_BENCH( return new GradientBench(p, kLinear_GradType, gGradData[1]); ) 273 DEF_BENCH( return new GradientBench(kLinear_GradType, gGradData[1]); )
274 DEF_BENCH( return new GradientBench(p, kLinear_GradType, gGradData[0], SkShader: :kMirror_TileMode); ) 274 DEF_BENCH( return new GradientBench(kLinear_GradType, gGradData[0], SkShader::kM irror_TileMode); )
275 275
276 // Draw a radial gradient of radius 1/2 on a rectangle; half the lines should 276 // Draw a radial gradient of radius 1/2 on a rectangle; half the lines should
277 // be completely pinned, the other half should pe partially pinned 277 // be completely pinned, the other half should pe partially pinned
278 DEF_BENCH( return new GradientBench(p, kRadial_GradType, gGradData[0], SkShader: :kClamp_TileMode, kRect_GeomType, 0.5f); ) 278 DEF_BENCH( return new GradientBench(kRadial_GradType, gGradData[0], SkShader::kC lamp_TileMode, kRect_GeomType, 0.5f); )
279 279
280 // Draw a radial gradient on a circle of equal size; all the lines should 280 // Draw a radial gradient on a circle of equal size; all the lines should
281 // hit the unpinned fast path (so long as GradientBench.W == H) 281 // hit the unpinned fast path (so long as GradientBench.W == H)
282 DEF_BENCH( return new GradientBench(p, kRadial_GradType, gGradData[0], SkShader: :kClamp_TileMode, kOval_GeomType); ) 282 DEF_BENCH( return new GradientBench(kRadial_GradType, gGradData[0], SkShader::kC lamp_TileMode, kOval_GeomType); )
283 283
284 DEF_BENCH( return new GradientBench(p, kRadial_GradType, gGradData[0], SkShader: :kMirror_TileMode); ) 284 DEF_BENCH( return new GradientBench(kRadial_GradType, gGradData[0], SkShader::kM irror_TileMode); )
285 DEF_BENCH( return new GradientBench(p, kSweep_GradType); ) 285 DEF_BENCH( return new GradientBench(kSweep_GradType); )
286 DEF_BENCH( return new GradientBench(p, kSweep_GradType, gGradData[1]); ) 286 DEF_BENCH( return new GradientBench(kSweep_GradType, gGradData[1]); )
287 DEF_BENCH( return new GradientBench(p, kRadial2_GradType); ) 287 DEF_BENCH( return new GradientBench(kRadial2_GradType); )
288 DEF_BENCH( return new GradientBench(p, kRadial2_GradType, gGradData[1]); ) 288 DEF_BENCH( return new GradientBench(kRadial2_GradType, gGradData[1]); )
289 DEF_BENCH( return new GradientBench(p, kRadial2_GradType, gGradData[0], SkShader ::kMirror_TileMode); ) 289 DEF_BENCH( return new GradientBench(kRadial2_GradType, gGradData[0], SkShader::k Mirror_TileMode); )
290 DEF_BENCH( return new GradientBench(p, kConical_GradType); ) 290 DEF_BENCH( return new GradientBench(kConical_GradType); )
291 DEF_BENCH( return new GradientBench(p, kConical_GradType, gGradData[1]); ) 291 DEF_BENCH( return new GradientBench(kConical_GradType, gGradData[1]); )
292 292
293 DEF_BENCH( return new Gradient2Bench(p, false); ) 293 DEF_BENCH( return new Gradient2Bench(false); )
294 DEF_BENCH( return new Gradient2Bench(p, true); ) 294 DEF_BENCH( return new Gradient2Bench(true); )
OLDNEW
« no previous file with comments | « bench/GrMemoryPoolBench.cpp ('k') | bench/HairlinePathBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698