| 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 "Benchmark.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| 11 #include "SkColorPriv.h" | 11 #include "SkColorPriv.h" |
| 12 #include "SkPaint.h" | 12 #include "SkPaint.h" |
| 13 #include "SkRandom.h" | 13 #include "SkRandom.h" |
| 14 #include "SkShader.h" | 14 #include "SkShader.h" |
| 15 #include "SkString.h" | 15 #include "SkString.h" |
| 16 | 16 |
| 17 static int rand_pts(SkRandom& rand, SkPoint pts[4]) { | 17 static int rand_pts(SkRandom& rand, SkPoint pts[4]) { |
| 18 int n = rand.nextU() & 3; | 18 int n = rand.nextU() & 3; |
| 19 n += 1; | 19 n += 1; |
| 20 | 20 |
| 21 for (int i = 0; i < n; ++i) { | 21 for (int i = 0; i < n; ++i) { |
| 22 pts[i].fX = rand.nextSScalar1(); | 22 pts[i].fX = rand.nextSScalar1(); |
| 23 pts[i].fY = rand.nextSScalar1(); | 23 pts[i].fY = rand.nextSScalar1(); |
| 24 } | 24 } |
| 25 return n; | 25 return n; |
| 26 } | 26 } |
| 27 | 27 |
| 28 class PathIterBench : public SkBenchmark { | 28 class PathIterBench : public Benchmark { |
| 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(bool raw) { | 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; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 SkPath::Iter iter(fPath, false); | 79 SkPath::Iter iter(fPath, false); |
| 80 SkPath::Verb verb; | 80 SkPath::Verb verb; |
| 81 SkPoint pts[4]; | 81 SkPoint pts[4]; |
| 82 | 82 |
| 83 while ((verb = iter.next(pts)) != SkPath::kDone_Verb) { } | 83 while ((verb = iter.next(pts)) != SkPath::kDone_Verb) { } |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 | 87 |
| 88 private: | 88 private: |
| 89 typedef SkBenchmark INHERITED; | 89 typedef Benchmark INHERITED; |
| 90 }; | 90 }; |
| 91 | 91 |
| 92 /////////////////////////////////////////////////////////////////////////////// | 92 /////////////////////////////////////////////////////////////////////////////// |
| 93 | 93 |
| 94 DEF_BENCH( return new PathIterBench(false); ) | 94 DEF_BENCH( return new PathIterBench(false); ) |
| 95 DEF_BENCH( return new PathIterBench(true); ) | 95 DEF_BENCH( return new PathIterBench(true); ) |
| OLD | NEW |