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

Side by Side Diff: bench/AAClipBench.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 | « no previous file | bench/BicubicBench.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 2011 Google Inc. 2 * Copyright 2011 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 7
8 #include "SkBenchmark.h" 8 #include "SkBenchmark.h"
9 #include "SkAAClip.h" 9 #include "SkAAClip.h"
10 #include "SkPath.h" 10 #include "SkPath.h"
11 #include "SkRegion.h" 11 #include "SkRegion.h"
12 #include "SkString.h" 12 #include "SkString.h"
13 #include "SkCanvas.h" 13 #include "SkCanvas.h"
14 #include "SkRandom.h" 14 #include "SkRandom.h"
15 15
16 //////////////////////////////////////////////////////////////////////////////// 16 ////////////////////////////////////////////////////////////////////////////////
17 // This bench tests out AA/BW clipping via canvas' clipPath and clipRect calls 17 // This bench tests out AA/BW clipping via canvas' clipPath and clipRect calls
18 class AAClipBench : public SkBenchmark { 18 class AAClipBench : public SkBenchmark {
19 SkString fName; 19 SkString fName;
20 SkPath fClipPath; 20 SkPath fClipPath;
21 SkRect fClipRect; 21 SkRect fClipRect;
22 SkRect fDrawRect; 22 SkRect fDrawRect;
23 bool fDoPath; 23 bool fDoPath;
24 bool fDoAA; 24 bool fDoAA;
25 25
26 public: 26 public:
27 AAClipBench(void* param, bool doPath, bool doAA) 27 AAClipBench(bool doPath, bool doAA)
28 : INHERITED(param) 28 : fDoPath(doPath)
29 , fDoPath(doPath)
30 , fDoAA(doAA) { 29 , fDoAA(doAA) {
31 30
32 fName.printf("aaclip_%s_%s", 31 fName.printf("aaclip_%s_%s",
33 doPath ? "path" : "rect", 32 doPath ? "path" : "rect",
34 doAA ? "AA" : "BW"); 33 doAA ? "AA" : "BW");
35 34
36 fClipRect.set(SkFloatToScalar(10.5f), SkFloatToScalar(10.5f), 35 fClipRect.set(SkFloatToScalar(10.5f), SkFloatToScalar(10.5f),
37 SkFloatToScalar(50.5f), SkFloatToScalar(50.5f)); 36 SkFloatToScalar(50.5f), SkFloatToScalar(50.5f));
38 fClipPath.addRoundRect(fClipRect, SkIntToScalar(10), SkIntToScalar(10)); 37 fClipPath.addRoundRect(fClipRect, SkIntToScalar(10), SkIntToScalar(10));
39 fDrawRect.set(SkIntToScalar(0), SkIntToScalar(0), 38 fDrawRect.set(SkIntToScalar(0), SkIntToScalar(0),
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 bool fDoAA; 90 bool fDoAA;
92 SkRect fDrawRect; 91 SkRect fDrawRect;
93 SkRandom fRandom; 92 SkRandom fRandom;
94 93
95 static const int kNestingDepth = 3; 94 static const int kNestingDepth = 3;
96 static const int kImageSize = 400; 95 static const int kImageSize = 400;
97 96
98 SkPoint fSizes[kNestingDepth+1]; 97 SkPoint fSizes[kNestingDepth+1];
99 98
100 public: 99 public:
101 NestedAAClipBench(void* param, bool doAA) 100 NestedAAClipBench(bool doAA) : fDoAA(doAA) {
102 : INHERITED(param)
103 , fDoAA(doAA) {
104
105 fName.printf("nested_aaclip_%s", doAA ? "AA" : "BW"); 101 fName.printf("nested_aaclip_%s", doAA ? "AA" : "BW");
106 102
107 fDrawRect = SkRect::MakeLTRB(0, 0, 103 fDrawRect = SkRect::MakeLTRB(0, 0,
108 SkIntToScalar(kImageSize), 104 SkIntToScalar(kImageSize),
109 SkIntToScalar(kImageSize)); 105 SkIntToScalar(kImageSize));
110 106
111 fSizes[0].set(SkIntToScalar(kImageSize), SkIntToScalar(kImageSize)); 107 fSizes[0].set(SkIntToScalar(kImageSize), SkIntToScalar(kImageSize));
112 108
113 for (int i = 1; i < kNestingDepth+1; ++i) { 109 for (int i = 1; i < kNestingDepth+1; ++i) {
114 fSizes[i].set(fSizes[i-1].fX/2, fSizes[i-1].fY/2); 110 fSizes[i].set(fSizes[i-1].fX/2, fSizes[i-1].fY/2);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 //////////////////////////////////////////////////////////////////////////////// 173 ////////////////////////////////////////////////////////////////////////////////
178 class AAClipBuilderBench : public SkBenchmark { 174 class AAClipBuilderBench : public SkBenchmark {
179 SkString fName; 175 SkString fName;
180 SkPath fPath; 176 SkPath fPath;
181 SkRect fRect; 177 SkRect fRect;
182 SkRegion fRegion; 178 SkRegion fRegion;
183 bool fDoPath; 179 bool fDoPath;
184 bool fDoAA; 180 bool fDoAA;
185 181
186 public: 182 public:
187 AAClipBuilderBench(void* param, bool doPath, bool doAA) : INHERITED(param) { 183 AAClipBuilderBench(bool doPath, bool doAA) {
188 fDoPath = doPath; 184 fDoPath = doPath;
189 fDoAA = doAA; 185 fDoAA = doAA;
190 186
191 fName.printf("aaclip_build_%s_%s", doPath ? "path" : "rect", 187 fName.printf("aaclip_build_%s_%s", doPath ? "path" : "rect",
192 doAA ? "AA" : "BW"); 188 doAA ? "AA" : "BW");
193 189
194 fRegion.setRect(0, 0, 640, 480); 190 fRegion.setRect(0, 0, 640, 480);
195 fRect.set(fRegion.getBounds()); 191 fRect.set(fRegion.getBounds());
196 fRect.inset(SK_Scalar1/4, SK_Scalar1/4); 192 fRect.inset(SK_Scalar1/4, SK_Scalar1/4);
197 fPath.addRoundRect(fRect, SkIntToScalar(20), SkIntToScalar(20)); 193 fPath.addRoundRect(fRect, SkIntToScalar(20), SkIntToScalar(20));
(...skipping 14 matching lines...) Expand all
212 } 208 }
213 } 209 }
214 } 210 }
215 private: 211 private:
216 typedef SkBenchmark INHERITED; 212 typedef SkBenchmark INHERITED;
217 }; 213 };
218 214
219 //////////////////////////////////////////////////////////////////////////////// 215 ////////////////////////////////////////////////////////////////////////////////
220 class AAClipRegionBench : public SkBenchmark { 216 class AAClipRegionBench : public SkBenchmark {
221 public: 217 public:
222 AAClipRegionBench(void* param) : INHERITED(param) { 218 AAClipRegionBench() {
223 SkPath path; 219 SkPath path;
224 // test conversion of a complex clip to a aaclip 220 // test conversion of a complex clip to a aaclip
225 path.addCircle(0, 0, SkIntToScalar(200)); 221 path.addCircle(0, 0, SkIntToScalar(200));
226 path.addCircle(0, 0, SkIntToScalar(180)); 222 path.addCircle(0, 0, SkIntToScalar(180));
227 // evenodd means we've constructed basically a stroked circle 223 // evenodd means we've constructed basically a stroked circle
228 path.setFillType(SkPath::kEvenOdd_FillType); 224 path.setFillType(SkPath::kEvenOdd_FillType);
229 225
230 SkIRect bounds; 226 SkIRect bounds;
231 path.getBounds().roundOut(&bounds); 227 path.getBounds().roundOut(&bounds);
232 fRegion.setPath(path, SkRegion(bounds)); 228 fRegion.setPath(path, SkRegion(bounds));
233 } 229 }
234 230
235 protected: 231 protected:
236 virtual const char* onGetName() { return "aaclip_setregion"; } 232 virtual const char* onGetName() { return "aaclip_setregion"; }
237 virtual void onDraw(SkCanvas*) { 233 virtual void onDraw(SkCanvas*) {
238 for (int i = 0; i < this->getLoops(); ++i) { 234 for (int i = 0; i < this->getLoops(); ++i) {
239 SkAAClip clip; 235 SkAAClip clip;
240 clip.setRegion(fRegion); 236 clip.setRegion(fRegion);
241 } 237 }
242 } 238 }
243 239
244 private: 240 private:
245 SkRegion fRegion; 241 SkRegion fRegion;
246 typedef SkBenchmark INHERITED; 242 typedef SkBenchmark INHERITED;
247 }; 243 };
248 244
249 //////////////////////////////////////////////////////////////////////////////// 245 ////////////////////////////////////////////////////////////////////////////////
250 246
251 static SkBenchmark* Fact0(void* p) { return SkNEW_ARGS(AAClipBuilderBench, (p, f alse, false)); } 247 DEF_BENCH( return SkNEW_ARGS(AAClipBuilderBench, (false, false)); )
252 static SkBenchmark* Fact1(void* p) { return SkNEW_ARGS(AAClipBuilderBench, (p, f alse, true)); } 248 DEF_BENCH( return SkNEW_ARGS(AAClipBuilderBench, (false, true)); )
253 static SkBenchmark* Fact2(void* p) { return SkNEW_ARGS(AAClipBuilderBench, (p, t rue, false)); } 249 DEF_BENCH( return SkNEW_ARGS(AAClipBuilderBench, (true, false)); )
254 static SkBenchmark* Fact3(void* p) { return SkNEW_ARGS(AAClipBuilderBench, (p, t rue, true)); } 250 DEF_BENCH( return SkNEW_ARGS(AAClipBuilderBench, (true, true)); )
251 DEF_BENCH( return SkNEW_ARGS(AAClipRegionBench, ()); )
252 DEF_BENCH( return SkNEW_ARGS(AAClipBench, (false, false)); )
253 DEF_BENCH( return SkNEW_ARGS(AAClipBench, (false, true)); )
254 DEF_BENCH( return SkNEW_ARGS(AAClipBench, (true, false)); )
255 DEF_BENCH( return SkNEW_ARGS(AAClipBench, (true, true)); )
256 DEF_BENCH( return SkNEW_ARGS(NestedAAClipBench, (false)); )
257 DEF_BENCH( return SkNEW_ARGS(NestedAAClipBench, (true)); )
255 258
256 static BenchRegistry gReg0(Fact0);
257 static BenchRegistry gReg1(Fact1);
258 static BenchRegistry gReg2(Fact2);
259 static BenchRegistry gReg3(Fact3);
260
261 static SkBenchmark* Fact01(void* p) { return SkNEW_ARGS(AAClipRegionBench, (p)); }
262 static BenchRegistry gReg01(Fact01);
263
264 static SkBenchmark* Fact000(void* p) { return SkNEW_ARGS(AAClipBench, (p, false, false)); }
265 static SkBenchmark* Fact001(void* p) { return SkNEW_ARGS(AAClipBench, (p, false, true)); }
266 static SkBenchmark* Fact002(void* p) { return SkNEW_ARGS(AAClipBench, (p, true, false)); }
267 static SkBenchmark* Fact003(void* p) { return SkNEW_ARGS(AAClipBench, (p, true, true)); }
268
269 static BenchRegistry gReg000(Fact000);
270 static BenchRegistry gReg001(Fact001);
271 static BenchRegistry gReg002(Fact002);
272 static BenchRegistry gReg003(Fact003);
273
274 static SkBenchmark* Fact004(void* p) { return SkNEW_ARGS(NestedAAClipBench, (p, false)); }
275 static SkBenchmark* Fact005(void* p) { return SkNEW_ARGS(NestedAAClipBench, (p, true)); }
276
277 static BenchRegistry gReg004(Fact004);
278 static BenchRegistry gReg005(Fact005);
OLDNEW
« no previous file with comments | « no previous file | bench/BicubicBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698