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

Side by Side Diff: bench/MorphologyBench.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/MergeBench.cpp ('k') | bench/MutexBench.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 "SkBenchmark.h" 7 #include "SkBenchmark.h"
8 #include "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkPaint.h" 9 #include "SkPaint.h"
10 #include "SkRandom.h" 10 #include "SkRandom.h"
(...skipping 18 matching lines...) Expand all
29 "erode", 29 "erode",
30 "dilate" 30 "dilate"
31 }; 31 };
32 32
33 class MorphologyBench : public SkBenchmark { 33 class MorphologyBench : public SkBenchmark {
34 SkScalar fRadius; 34 SkScalar fRadius;
35 MorphologyType fStyle; 35 MorphologyType fStyle;
36 SkString fName; 36 SkString fName;
37 37
38 public: 38 public:
39 MorphologyBench(void* param, SkScalar rad, MorphologyType style) 39 MorphologyBench(SkScalar rad, MorphologyType style)
40 : INHERITED(param) { 40 {
41 fRadius = rad; 41 fRadius = rad;
42 fStyle = style; 42 fStyle = style;
43 const char* name = rad > 0 ? gStyleName[style] : "none"; 43 const char* name = rad > 0 ? gStyleName[style] : "none";
44 if (SkScalarFraction(rad) != 0) { 44 if (SkScalarFraction(rad) != 0) {
45 fName.printf("morph_%.2f_%s", SkScalarToFloat(rad), name); 45 fName.printf("morph_%.2f_%s", SkScalarToFloat(rad), name);
46 } else { 46 } else {
47 fName.printf("morph_%d_%s", SkScalarRound(rad), name); 47 fName.printf("morph_%d_%s", SkScalarRound(rad), name);
48 } 48 }
49 } 49 }
50 50
(...skipping 29 matching lines...) Expand all
80 paint.setImageFilter(mf)->unref(); 80 paint.setImageFilter(mf)->unref();
81 } 81 }
82 canvas->drawOval(r, paint); 82 canvas->drawOval(r, paint);
83 } 83 }
84 } 84 }
85 85
86 private: 86 private:
87 typedef SkBenchmark INHERITED; 87 typedef SkBenchmark INHERITED;
88 }; 88 };
89 89
90 static SkBenchmark* Fact00(void* p) { return new MorphologyBench(p, SMALL, kErod e_MT); }
91 static SkBenchmark* Fact01(void* p) { return new MorphologyBench(p, SMALL, kDila te_MT); }
92
93 static SkBenchmark* Fact10(void* p) { return new MorphologyBench(p, BIG, kErode_ MT); }
94 static SkBenchmark* Fact11(void* p) { return new MorphologyBench(p, BIG, kDilate _MT); }
95
96 static SkBenchmark* Fact20(void* p) { return new MorphologyBench(p, REAL, kErode _MT); }
97 static SkBenchmark* Fact21(void* p) { return new MorphologyBench(p, REAL, kDilat e_MT); }
98
99 static SkBenchmark* FactNone(void* p) { return new MorphologyBench(p, 0, kErode_ MT); }
100
101 // Fixed point can be 100x slower than float on these tests, causing 90 // Fixed point can be 100x slower than float on these tests, causing
102 // bench to timeout. 91 // bench to timeout.
103 #ifndef SK_SCALAR_IS_FIXED 92 #ifndef SK_SCALAR_IS_FIXED
93 DEF_BENCH( return new MorphologyBench(SMALL, kErode_MT); )
94 DEF_BENCH( return new MorphologyBench(SMALL, kDilate_MT); )
104 95
105 static BenchRegistry gReg00(Fact00); 96 DEF_BENCH( return new MorphologyBench(BIG, kErode_MT); )
106 static BenchRegistry gReg01(Fact01); 97 DEF_BENCH( return new MorphologyBench(BIG, kDilate_MT); )
107 98
108 static BenchRegistry gReg10(Fact10); 99 DEF_BENCH( return new MorphologyBench(REAL, kErode_MT); )
109 static BenchRegistry gReg11(Fact11); 100 DEF_BENCH( return new MorphologyBench(REAL, kDilate_MT); )
110 101
111 static BenchRegistry gReg20(Fact20); 102 DEF_BENCH( return new MorphologyBench(0, kErode_MT); )
112 static BenchRegistry gReg21(Fact21);
113
114 static BenchRegistry gRegNone(FactNone);
115
116 #endif 103 #endif
OLDNEW
« no previous file with comments | « bench/MergeBench.cpp ('k') | bench/MutexBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698