OLD | NEW |
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 13 matching lines...) Expand all Loading... |
24 } | 24 } |
25 return n; | 25 return n; |
26 } | 26 } |
27 | 27 |
28 class PathIterBench : public SkBenchmark { | 28 class PathIterBench : public SkBenchmark { |
29 SkString fName; | 29 SkString fName; |
30 SkPath fPath; | 30 SkPath fPath; |
31 bool fRaw; | 31 bool fRaw; |
32 | 32 |
33 public: | 33 public: |
34 PathIterBench(void* param, bool raw) : INHERITED(param) { | 34 PathIterBench(bool raw) { |
35 fName.printf("pathiter_%s", raw ? "raw" : "consume"); | 35 fName.printf("pathiter_%s", raw ? "raw" : "consume"); |
36 fRaw = raw; | 36 fRaw = raw; |
37 | 37 |
38 SkRandom rand; | 38 SkRandom rand; |
39 for (int i = 0; i < 1000; ++i) { | 39 for (int i = 0; i < 1000; ++i) { |
40 SkPoint pts[4]; | 40 SkPoint pts[4]; |
41 int n = rand_pts(rand, pts); | 41 int n = rand_pts(rand, pts); |
42 switch (n) { | 42 switch (n) { |
43 case 1: | 43 case 1: |
44 fPath.moveTo(pts[0]); | 44 fPath.moveTo(pts[0]); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 } | 82 } |
83 } | 83 } |
84 } | 84 } |
85 | 85 |
86 private: | 86 private: |
87 typedef SkBenchmark INHERITED; | 87 typedef SkBenchmark INHERITED; |
88 }; | 88 }; |
89 | 89 |
90 /////////////////////////////////////////////////////////////////////////////// | 90 /////////////////////////////////////////////////////////////////////////////// |
91 | 91 |
92 static SkBenchmark* F0(void* p) { return new PathIterBench(p, false); } | 92 DEF_BENCH( return new PathIterBench(false); ) |
93 static SkBenchmark* F1(void* p) { return new PathIterBench(p, true); } | 93 DEF_BENCH( return new PathIterBench(true); ) |
94 | |
95 static BenchRegistry gR0(F0); | |
96 static BenchRegistry gR1(F1); | |
OLD | NEW |