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

Side by Side Diff: bench/DashBench.cpp

Issue 347823004: Remove Sk prefix from some bench classes. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: SkGMBench -> GMBench Created 6 years, 6 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 | « bench/CoverageBench.cpp ('k') | bench/DecodeBench.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 "Benchmark.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkDashPathEffect.h" 11 #include "SkDashPathEffect.h"
12 #include "SkPaint.h" 12 #include "SkPaint.h"
13 #include "SkPath.h" 13 #include "SkPath.h"
14 #include "SkRandom.h" 14 #include "SkRandom.h"
15 #include "SkString.h" 15 #include "SkString.h"
16 #include "SkTDArray.h" 16 #include "SkTDArray.h"
17 17
18 18
19 /* 19 /*
20 * Cases to consider: 20 * Cases to consider:
21 * 21 *
22 * 1. antialiasing on/off (esp. width <= 1) 22 * 1. antialiasing on/off (esp. width <= 1)
23 * 2. strokewidth == 0, 1, 2 23 * 2. strokewidth == 0, 1, 2
24 * 3. hline, vline, diagonal, rect, oval 24 * 3. hline, vline, diagonal, rect, oval
25 * 4. dots [1,1] ([N,N] where N=strokeWidth?) or arbitrary (e.g. [2,1] or [1,2, 3,2]) 25 * 4. dots [1,1] ([N,N] where N=strokeWidth?) or arbitrary (e.g. [2,1] or [1,2, 3,2])
26 */ 26 */
27 static void path_hline(SkPath* path) { 27 static void path_hline(SkPath* path) {
28 path->moveTo(SkIntToScalar(10), SkIntToScalar(10)); 28 path->moveTo(SkIntToScalar(10), SkIntToScalar(10));
29 path->lineTo(SkIntToScalar(600), SkIntToScalar(10)); 29 path->lineTo(SkIntToScalar(600), SkIntToScalar(10));
30 } 30 }
31 31
32 class DashBench : public SkBenchmark { 32 class DashBench : public Benchmark {
33 protected: 33 protected:
34 SkString fName; 34 SkString fName;
35 SkTDArray<SkScalar> fIntervals; 35 SkTDArray<SkScalar> fIntervals;
36 int fWidth; 36 int fWidth;
37 SkPoint fPts[2]; 37 SkPoint fPts[2];
38 bool fDoClip; 38 bool fDoClip;
39 39
40 public: 40 public:
41 DashBench(const SkScalar intervals[], int count, int width, 41 DashBench(const SkScalar intervals[], int count, int width,
42 bool doClip = false) { 42 bool doClip = false) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 87
88 virtual void handlePath(SkCanvas* canvas, const SkPath& path, 88 virtual void handlePath(SkCanvas* canvas, const SkPath& path,
89 const SkPaint& paint, int N) { 89 const SkPaint& paint, int N) {
90 for (int i = 0; i < N; ++i) { 90 for (int i = 0; i < N; ++i) {
91 // canvas->drawPoints(SkCanvas::kLines_PointMode, 2, fPts, paint); 91 // canvas->drawPoints(SkCanvas::kLines_PointMode, 2, fPts, paint);
92 canvas->drawPath(path, paint); 92 canvas->drawPath(path, paint);
93 } 93 }
94 } 94 }
95 95
96 private: 96 private:
97 typedef SkBenchmark INHERITED; 97 typedef Benchmark INHERITED;
98 }; 98 };
99 99
100 class RectDashBench : public DashBench { 100 class RectDashBench : public DashBench {
101 public: 101 public:
102 RectDashBench(const SkScalar intervals[], int count, int width) 102 RectDashBench(const SkScalar intervals[], int count, int width)
103 : INHERITED(intervals, count, width) { 103 : INHERITED(intervals, count, width) {
104 fName.append("_rect"); 104 fName.append("_rect");
105 } 105 }
106 106
107 protected: 107 protected:
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 168
169 static void make_cubic(SkPath* path) { 169 static void make_cubic(SkPath* path) {
170 SkScalar x0 = SkIntToScalar(10); 170 SkScalar x0 = SkIntToScalar(10);
171 SkScalar y0 = SkIntToScalar(10); 171 SkScalar y0 = SkIntToScalar(10);
172 path->moveTo(x0, y0); 172 path->moveTo(x0, y0);
173 path->cubicTo(x0, y0 + 400 * SK_Scalar1, 173 path->cubicTo(x0, y0 + 400 * SK_Scalar1,
174 x0 + 600 * SK_Scalar1, y0 + 400 * SK_Scalar1, 174 x0 + 600 * SK_Scalar1, y0 + 400 * SK_Scalar1,
175 x0 + 600 * SK_Scalar1, y0); 175 x0 + 600 * SK_Scalar1, y0);
176 } 176 }
177 177
178 class MakeDashBench : public SkBenchmark { 178 class MakeDashBench : public Benchmark {
179 SkString fName; 179 SkString fName;
180 SkPath fPath; 180 SkPath fPath;
181 SkAutoTUnref<SkPathEffect> fPE; 181 SkAutoTUnref<SkPathEffect> fPE;
182 182
183 public: 183 public:
184 MakeDashBench(void (*proc)(SkPath*), const char name[]) { 184 MakeDashBench(void (*proc)(SkPath*), const char name[]) {
185 fName.printf("makedash_%s", name); 185 fName.printf("makedash_%s", name);
186 proc(&fPath); 186 proc(&fPath);
187 187
188 SkScalar vals[] = { SkIntToScalar(4), SkIntToScalar(4) }; 188 SkScalar vals[] = { SkIntToScalar(4), SkIntToScalar(4) };
189 fPE.reset(SkDashPathEffect::Create(vals, 2, 0)); 189 fPE.reset(SkDashPathEffect::Create(vals, 2, 0));
190 } 190 }
191 191
192 protected: 192 protected:
193 virtual const char* onGetName() SK_OVERRIDE { 193 virtual const char* onGetName() SK_OVERRIDE {
194 return fName.c_str(); 194 return fName.c_str();
195 } 195 }
196 196
197 virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE { 197 virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
198 SkPath dst; 198 SkPath dst;
199 for (int i = 0; i < loops; ++i) { 199 for (int i = 0; i < loops; ++i) {
200 SkStrokeRec rec(SkStrokeRec::kHairline_InitStyle); 200 SkStrokeRec rec(SkStrokeRec::kHairline_InitStyle);
201 201
202 fPE->filterPath(&dst, fPath, &rec, NULL); 202 fPE->filterPath(&dst, fPath, &rec, NULL);
203 dst.rewind(); 203 dst.rewind();
204 } 204 }
205 } 205 }
206 206
207 private: 207 private:
208 typedef SkBenchmark INHERITED; 208 typedef Benchmark INHERITED;
209 }; 209 };
210 210
211 /* 211 /*
212 * We try to special case square dashes (intervals are equal to strokewidth). 212 * We try to special case square dashes (intervals are equal to strokewidth).
213 */ 213 */
214 class DashLineBench : public SkBenchmark { 214 class DashLineBench : public Benchmark {
215 SkString fName; 215 SkString fName;
216 SkScalar fStrokeWidth; 216 SkScalar fStrokeWidth;
217 bool fIsRound; 217 bool fIsRound;
218 SkAutoTUnref<SkPathEffect> fPE; 218 SkAutoTUnref<SkPathEffect> fPE;
219 219
220 public: 220 public:
221 DashLineBench(SkScalar width, bool isRound) { 221 DashLineBench(SkScalar width, bool isRound) {
222 fName.printf("dashline_%g_%s", SkScalarToFloat(width), isRound ? "circle " : "square"); 222 fName.printf("dashline_%g_%s", SkScalarToFloat(width), isRound ? "circle " : "square");
223 fStrokeWidth = width; 223 fStrokeWidth = width;
224 fIsRound = isRound; 224 fIsRound = isRound;
(...skipping 13 matching lines...) Expand all
238 paint.setStrokeWidth(fStrokeWidth); 238 paint.setStrokeWidth(fStrokeWidth);
239 paint.setStrokeCap(fIsRound ? SkPaint::kRound_Cap : SkPaint::kSquare_Cap ); 239 paint.setStrokeCap(fIsRound ? SkPaint::kRound_Cap : SkPaint::kSquare_Cap );
240 paint.setPathEffect(fPE); 240 paint.setPathEffect(fPE);
241 for (int i = 0; i < loops; ++i) { 241 for (int i = 0; i < loops; ++i) {
242 canvas->drawLine(10 * SK_Scalar1, 10 * SK_Scalar1, 242 canvas->drawLine(10 * SK_Scalar1, 10 * SK_Scalar1,
243 640 * SK_Scalar1, 10 * SK_Scalar1, paint); 243 640 * SK_Scalar1, 10 * SK_Scalar1, paint);
244 } 244 }
245 } 245 }
246 246
247 private: 247 private:
248 typedef SkBenchmark INHERITED; 248 typedef Benchmark INHERITED;
249 }; 249 };
250 250
251 class DrawPointsDashingBench : public SkBenchmark { 251 class DrawPointsDashingBench : public Benchmark {
252 SkString fName; 252 SkString fName;
253 int fStrokeWidth; 253 int fStrokeWidth;
254 bool fDoAA; 254 bool fDoAA;
255 255
256 SkAutoTUnref<SkPathEffect> fPathEffect; 256 SkAutoTUnref<SkPathEffect> fPathEffect;
257 257
258 public: 258 public:
259 DrawPointsDashingBench(int dashLength, int strokeWidth, bool doAA) 259 DrawPointsDashingBench(int dashLength, int strokeWidth, bool doAA)
260 { 260 {
261 fName.printf("drawpointsdash_%d_%d%s", dashLength, strokeWidth, doAA ? " _aa" : "_bw"); 261 fName.printf("drawpointsdash_%d_%d%s", dashLength, strokeWidth, doAA ? " _aa" : "_bw");
(...skipping 23 matching lines...) Expand all
285 { SkIntToScalar(640), 0 } 285 { SkIntToScalar(640), 0 }
286 }; 286 };
287 287
288 for (int i = 0; i < loops; ++i) { 288 for (int i = 0; i < loops; ++i) {
289 pts[0].fY = pts[1].fY = SkIntToScalar(i % 480); 289 pts[0].fY = pts[1].fY = SkIntToScalar(i % 480);
290 canvas->drawPoints(SkCanvas::kLines_PointMode, 2, pts, p); 290 canvas->drawPoints(SkCanvas::kLines_PointMode, 2, pts, p);
291 } 291 }
292 } 292 }
293 293
294 private: 294 private:
295 typedef SkBenchmark INHERITED; 295 typedef Benchmark INHERITED;
296 }; 296 };
297 297
298 // Want to test how we handle dashing when 99% of the dash is clipped out 298 // Want to test how we handle dashing when 99% of the dash is clipped out
299 class GiantDashBench : public SkBenchmark { 299 class GiantDashBench : public Benchmark {
300 SkString fName; 300 SkString fName;
301 SkScalar fStrokeWidth; 301 SkScalar fStrokeWidth;
302 SkPoint fPts[2]; 302 SkPoint fPts[2];
303 SkAutoTUnref<SkPathEffect> fPathEffect; 303 SkAutoTUnref<SkPathEffect> fPathEffect;
304 304
305 public: 305 public:
306 enum LineType { 306 enum LineType {
307 kHori_LineType, 307 kHori_LineType,
308 kVert_LineType, 308 kVert_LineType,
309 kDiag_LineType, 309 kDiag_LineType,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 p.setStyle(SkPaint::kStroke_Style); 363 p.setStyle(SkPaint::kStroke_Style);
364 p.setStrokeWidth(fStrokeWidth); 364 p.setStrokeWidth(fStrokeWidth);
365 p.setPathEffect(fPathEffect); 365 p.setPathEffect(fPathEffect);
366 366
367 for (int i = 0; i < loops; i++) { 367 for (int i = 0; i < loops; i++) {
368 canvas->drawPoints(SkCanvas::kLines_PointMode, 2, fPts, p); 368 canvas->drawPoints(SkCanvas::kLines_PointMode, 2, fPts, p);
369 } 369 }
370 } 370 }
371 371
372 private: 372 private:
373 typedef SkBenchmark INHERITED; 373 typedef Benchmark INHERITED;
374 }; 374 };
375 375
376 // Want to test how we draw a dashed grid (like what is used in spreadsheets) of many 376 // Want to test how we draw a dashed grid (like what is used in spreadsheets) of many
377 // small dashed lines switching back and forth between horizontal and vertical 377 // small dashed lines switching back and forth between horizontal and vertical
378 class DashGridBench : public SkBenchmark { 378 class DashGridBench : public Benchmark {
379 SkString fName; 379 SkString fName;
380 int fStrokeWidth; 380 int fStrokeWidth;
381 bool fDoAA; 381 bool fDoAA;
382 382
383 SkAutoTUnref<SkPathEffect> fPathEffect; 383 SkAutoTUnref<SkPathEffect> fPathEffect;
384 384
385 public: 385 public:
386 DashGridBench(int dashLength, int strokeWidth, bool doAA) { 386 DashGridBench(int dashLength, int strokeWidth, bool doAA) {
387 fName.printf("dashgrid_%d_%d%s", dashLength, strokeWidth, doAA ? "_aa" : "_bw"); 387 fName.printf("dashgrid_%d_%d%s", dashLength, strokeWidth, doAA ? "_aa" : "_bw");
388 fStrokeWidth = strokeWidth; 388 fStrokeWidth = strokeWidth;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 vertPts[0].fY = pts[2].fY + j * 22.f; 430 vertPts[0].fY = pts[2].fY + j * 22.f;
431 vertPts[1].fX = pts[3].fX + k * 22.f; 431 vertPts[1].fX = pts[3].fX + k * 22.f;
432 vertPts[1].fY = pts[3].fY + j * 22.f; 432 vertPts[1].fY = pts[3].fY + j * 22.f;
433 canvas->drawPoints(SkCanvas::kLines_PointMode, 2, vertPts, p ); 433 canvas->drawPoints(SkCanvas::kLines_PointMode, 2, vertPts, p );
434 } 434 }
435 } 435 }
436 } 436 }
437 } 437 }
438 438
439 private: 439 private:
440 typedef SkBenchmark INHERITED; 440 typedef Benchmark INHERITED;
441 }; 441 };
442 442
443 /////////////////////////////////////////////////////////////////////////////// 443 ///////////////////////////////////////////////////////////////////////////////
444 444
445 static const SkScalar gDots[] = { SK_Scalar1, SK_Scalar1 }; 445 static const SkScalar gDots[] = { SK_Scalar1, SK_Scalar1 };
446 446
447 #define PARAM(array) array, SK_ARRAY_COUNT(array) 447 #define PARAM(array) array, SK_ARRAY_COUNT(array)
448 448
449 DEF_BENCH( return new DashBench(PARAM(gDots), 0); ) 449 DEF_BENCH( return new DashBench(PARAM(gDots), 0); )
450 DEF_BENCH( return new DashBench(PARAM(gDots), 1); ) 450 DEF_BENCH( return new DashBench(PARAM(gDots), 1); )
(...skipping 29 matching lines...) Expand all
480 // hori_2 is just too slow to enable at the moment 480 // hori_2 is just too slow to enable at the moment
481 DEF_BENCH( return new GiantDashBench(GiantDashBench::kHori_LineType, 2); ) 481 DEF_BENCH( return new GiantDashBench(GiantDashBench::kHori_LineType, 2); )
482 DEF_BENCH( return new GiantDashBench(GiantDashBench::kVert_LineType, 2); ) 482 DEF_BENCH( return new GiantDashBench(GiantDashBench::kVert_LineType, 2); )
483 DEF_BENCH( return new GiantDashBench(GiantDashBench::kDiag_LineType, 2); ) 483 DEF_BENCH( return new GiantDashBench(GiantDashBench::kDiag_LineType, 2); )
484 484
485 DEF_BENCH( return new DashGridBench(1, 1, true); ) 485 DEF_BENCH( return new DashGridBench(1, 1, true); )
486 DEF_BENCH( return new DashGridBench(1, 1, false); ) 486 DEF_BENCH( return new DashGridBench(1, 1, false); )
487 DEF_BENCH( return new DashGridBench(3, 1, true); ) 487 DEF_BENCH( return new DashGridBench(3, 1, true); )
488 DEF_BENCH( return new DashGridBench(3, 1, false); ) 488 DEF_BENCH( return new DashGridBench(3, 1, false); )
489 #endif 489 #endif
OLDNEW
« no previous file with comments | « bench/CoverageBench.cpp ('k') | bench/DecodeBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698