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

Side by Side Diff: bench/AAClipBench.cpp

Issue 99893003: Simplify benchmark internal API. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 7 years 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"
(...skipping 25 matching lines...) Expand all
36 50.5f, 50.5f); 36 50.5f, 50.5f);
37 fClipPath.addRoundRect(fClipRect, SkIntToScalar(10), SkIntToScalar(10)); 37 fClipPath.addRoundRect(fClipRect, SkIntToScalar(10), SkIntToScalar(10));
38 fDrawRect.set(SkIntToScalar(0), SkIntToScalar(0), 38 fDrawRect.set(SkIntToScalar(0), SkIntToScalar(0),
39 SkIntToScalar(100), SkIntToScalar(100)); 39 SkIntToScalar(100), SkIntToScalar(100));
40 40
41 SkASSERT(fClipPath.isConvex()); 41 SkASSERT(fClipPath.isConvex());
42 } 42 }
43 43
44 protected: 44 protected:
45 virtual const char* onGetName() { return fName.c_str(); } 45 virtual const char* onGetName() { return fName.c_str(); }
46 virtual void onDraw(SkCanvas* canvas) { 46 virtual void onDraw(const int loops, SkCanvas* canvas) {
47 47
48 SkPaint paint; 48 SkPaint paint;
49 this->setupPaint(&paint); 49 this->setupPaint(&paint);
50 50
51 for (int i = 0; i < this->getLoops(); ++i) { 51 for (int i = 0; i < loops; ++i) {
52 // jostle the clip regions each time to prevent caching 52 // jostle the clip regions each time to prevent caching
53 fClipRect.offset((i % 2) == 0 ? SkIntToScalar(10) : SkIntToScalar(-1 0), 0); 53 fClipRect.offset((i % 2) == 0 ? SkIntToScalar(10) : SkIntToScalar(-1 0), 0);
54 fClipPath.reset(); 54 fClipPath.reset();
55 fClipPath.addRoundRect(fClipRect, 55 fClipPath.addRoundRect(fClipRect,
56 SkIntToScalar(5), SkIntToScalar(5)); 56 SkIntToScalar(5), SkIntToScalar(5));
57 SkASSERT(fClipPath.isConvex()); 57 SkASSERT(fClipPath.isConvex());
58 58
59 canvas->save(); 59 canvas->save();
60 #if 1 60 #if 1
61 if (fDoPath) { 61 if (fDoPath) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 this->recurse(canvas, depth+1, childOffset); 151 this->recurse(canvas, depth+1, childOffset);
152 152
153 childOffset.fX = offset.fX; 153 childOffset.fX = offset.fX;
154 childOffset.fY = offset.fY + fSizes[depth+1].fY; 154 childOffset.fY = offset.fY + fSizes[depth+1].fY;
155 this->recurse(canvas, depth+1, childOffset); 155 this->recurse(canvas, depth+1, childOffset);
156 } 156 }
157 157
158 canvas->restore(); 158 canvas->restore();
159 } 159 }
160 160
161 virtual void onDraw(SkCanvas* canvas) { 161 virtual void onDraw(const int loops, SkCanvas* canvas) {
162 162
163 for (int i = 0; i < this->getLoops(); ++i) { 163 for (int i = 0; i < loops; ++i) {
164 SkPoint offset = SkPoint::Make(0, 0); 164 SkPoint offset = SkPoint::Make(0, 0);
165 this->recurse(canvas, 0, offset); 165 this->recurse(canvas, 0, offset);
166 } 166 }
167 } 167 }
168 168
169 private: 169 private:
170 typedef SkBenchmark INHERITED; 170 typedef SkBenchmark INHERITED;
171 }; 171 };
172 172
173 //////////////////////////////////////////////////////////////////////////////// 173 ////////////////////////////////////////////////////////////////////////////////
(...skipping 14 matching lines...) Expand all
188 doAA ? "AA" : "BW"); 188 doAA ? "AA" : "BW");
189 189
190 fRegion.setRect(0, 0, 640, 480); 190 fRegion.setRect(0, 0, 640, 480);
191 fRect.set(fRegion.getBounds()); 191 fRect.set(fRegion.getBounds());
192 fRect.inset(SK_Scalar1/4, SK_Scalar1/4); 192 fRect.inset(SK_Scalar1/4, SK_Scalar1/4);
193 fPath.addRoundRect(fRect, SkIntToScalar(20), SkIntToScalar(20)); 193 fPath.addRoundRect(fRect, SkIntToScalar(20), SkIntToScalar(20));
194 } 194 }
195 195
196 protected: 196 protected:
197 virtual const char* onGetName() { return fName.c_str(); } 197 virtual const char* onGetName() { return fName.c_str(); }
198 virtual void onDraw(SkCanvas*) { 198 virtual void onDraw(const int loops, SkCanvas*) {
199 SkPaint paint; 199 SkPaint paint;
200 this->setupPaint(&paint); 200 this->setupPaint(&paint);
201 201
202 for (int i = 0; i < this->getLoops(); ++i) { 202 for (int i = 0; i < loops; ++i) {
203 SkAAClip clip; 203 SkAAClip clip;
204 if (fDoPath) { 204 if (fDoPath) {
205 clip.setPath(fPath, &fRegion, fDoAA); 205 clip.setPath(fPath, &fRegion, fDoAA);
206 } else { 206 } else {
207 clip.setRect(fRect, fDoAA); 207 clip.setRect(fRect, fDoAA);
208 } 208 }
209 } 209 }
210 } 210 }
211 private: 211 private:
212 typedef SkBenchmark INHERITED; 212 typedef SkBenchmark INHERITED;
(...skipping 10 matching lines...) Expand all
223 // evenodd means we've constructed basically a stroked circle 223 // evenodd means we've constructed basically a stroked circle
224 path.setFillType(SkPath::kEvenOdd_FillType); 224 path.setFillType(SkPath::kEvenOdd_FillType);
225 225
226 SkIRect bounds; 226 SkIRect bounds;
227 path.getBounds().roundOut(&bounds); 227 path.getBounds().roundOut(&bounds);
228 fRegion.setPath(path, SkRegion(bounds)); 228 fRegion.setPath(path, SkRegion(bounds));
229 } 229 }
230 230
231 protected: 231 protected:
232 virtual const char* onGetName() { return "aaclip_setregion"; } 232 virtual const char* onGetName() { return "aaclip_setregion"; }
233 virtual void onDraw(SkCanvas*) { 233 virtual void onDraw(const int loops, SkCanvas*) {
234 for (int i = 0; i < this->getLoops(); ++i) { 234 for (int i = 0; i < loops; ++i) {
235 SkAAClip clip; 235 SkAAClip clip;
236 clip.setRegion(fRegion); 236 clip.setRegion(fRegion);
237 } 237 }
238 } 238 }
239 239
240 private: 240 private:
241 SkRegion fRegion; 241 SkRegion fRegion;
242 typedef SkBenchmark INHERITED; 242 typedef SkBenchmark INHERITED;
243 }; 243 };
244 244
245 //////////////////////////////////////////////////////////////////////////////// 245 ////////////////////////////////////////////////////////////////////////////////
246 246
247 DEF_BENCH( return SkNEW_ARGS(AAClipBuilderBench, (false, false)); ) 247 DEF_BENCH( return SkNEW_ARGS(AAClipBuilderBench, (false, false)); )
248 DEF_BENCH( return SkNEW_ARGS(AAClipBuilderBench, (false, true)); ) 248 DEF_BENCH( return SkNEW_ARGS(AAClipBuilderBench, (false, true)); )
249 DEF_BENCH( return SkNEW_ARGS(AAClipBuilderBench, (true, false)); ) 249 DEF_BENCH( return SkNEW_ARGS(AAClipBuilderBench, (true, false)); )
250 DEF_BENCH( return SkNEW_ARGS(AAClipBuilderBench, (true, true)); ) 250 DEF_BENCH( return SkNEW_ARGS(AAClipBuilderBench, (true, true)); )
251 DEF_BENCH( return SkNEW_ARGS(AAClipRegionBench, ()); ) 251 DEF_BENCH( return SkNEW_ARGS(AAClipRegionBench, ()); )
252 DEF_BENCH( return SkNEW_ARGS(AAClipBench, (false, false)); ) 252 DEF_BENCH( return SkNEW_ARGS(AAClipBench, (false, false)); )
253 DEF_BENCH( return SkNEW_ARGS(AAClipBench, (false, true)); ) 253 DEF_BENCH( return SkNEW_ARGS(AAClipBench, (false, true)); )
254 DEF_BENCH( return SkNEW_ARGS(AAClipBench, (true, false)); ) 254 DEF_BENCH( return SkNEW_ARGS(AAClipBench, (true, false)); )
255 DEF_BENCH( return SkNEW_ARGS(AAClipBench, (true, true)); ) 255 DEF_BENCH( return SkNEW_ARGS(AAClipBench, (true, true)); )
256 DEF_BENCH( return SkNEW_ARGS(NestedAAClipBench, (false)); ) 256 DEF_BENCH( return SkNEW_ARGS(NestedAAClipBench, (false)); )
257 DEF_BENCH( return SkNEW_ARGS(NestedAAClipBench, (true)); ) 257 DEF_BENCH( return SkNEW_ARGS(NestedAAClipBench, (true)); )
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