OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "Benchmark.h" | 8 #include "Benchmark.h" |
9 #include "SkGeometry.h" | 9 #include "SkGeometry.h" |
10 #include "SkRandom.h" | 10 #include "SkRandom.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 DEF_BENCH( return new GeoRectBench_intersect; ) | 127 DEF_BENCH( return new GeoRectBench_intersect; ) |
128 DEF_BENCH( return new GeoRectBench_intersect_rect; ) | 128 DEF_BENCH( return new GeoRectBench_intersect_rect; ) |
129 DEF_BENCH( return new GeoRectBench_Intersects; ) | 129 DEF_BENCH( return new GeoRectBench_Intersects; ) |
130 | 130 |
131 DEF_BENCH( return new GeoRectBench_sort; ) | 131 DEF_BENCH( return new GeoRectBench_sort; ) |
132 | 132 |
133 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 133 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
134 | 134 |
135 class QuadBenchBase : public GeometryBench { | 135 class QuadBenchBase : public GeometryBench { |
136 protected: | 136 protected: |
137 SkPoint fPts[3]; | 137 SkPoint fPts[4]; |
138 public: | 138 public: |
139 QuadBenchBase(const char name[]) : GeometryBench(name) { | 139 QuadBenchBase(const char name[]) : GeometryBench(name) { |
140 SkRandom rand; | 140 SkRandom rand; |
141 for (int i = 0; i < 3; ++i) { | 141 for (int i = 0; i < 4; ++i) { |
142 fPts[i].set(rand.nextUScalar1(), rand.nextUScalar1()); | 142 fPts[i].set(rand.nextUScalar1(), rand.nextUScalar1()); |
143 } | 143 } |
144 } | 144 } |
145 }; | 145 }; |
146 | 146 |
147 class EvalQuadAt0 : public QuadBenchBase { | 147 class EvalQuadAt0 : public QuadBenchBase { |
148 public: | 148 public: |
149 EvalQuadAt0() : QuadBenchBase("evalquadat0") {} | 149 EvalQuadAt0() : QuadBenchBase("evalquadat0") {} |
150 protected: | 150 protected: |
151 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { | 151 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 for (int outer = 0; outer < loops; ++outer) { | 237 for (int outer = 0; outer < loops; ++outer) { |
238 SkChopQuadAt2(fPts, dst, 0.5f); | 238 SkChopQuadAt2(fPts, dst, 0.5f); |
239 SkChopQuadAt2(fPts, dst, 0.5f); | 239 SkChopQuadAt2(fPts, dst, 0.5f); |
240 SkChopQuadAt2(fPts, dst, 0.5f); | 240 SkChopQuadAt2(fPts, dst, 0.5f); |
241 SkChopQuadAt2(fPts, dst, 0.5f); | 241 SkChopQuadAt2(fPts, dst, 0.5f); |
242 } | 242 } |
243 } | 243 } |
244 }; | 244 }; |
245 DEF_BENCH( return new ChopQuadAt1; ) | 245 DEF_BENCH( return new ChopQuadAt1; ) |
246 | 246 |
| 247 class ChopCubicAt0 : public QuadBenchBase { |
| 248 public: |
| 249 ChopCubicAt0() : QuadBenchBase("chopcubicat0") {} |
| 250 protected: |
| 251 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { |
| 252 SkPoint dst[7]; |
| 253 for (int outer = 0; outer < loops; ++outer) { |
| 254 SkChopCubicAt(fPts, dst, 0.5f); |
| 255 SkChopCubicAt(fPts, dst, 0.5f); |
| 256 SkChopCubicAt(fPts, dst, 0.5f); |
| 257 SkChopCubicAt(fPts, dst, 0.5f); |
| 258 } |
| 259 } |
| 260 }; |
| 261 DEF_BENCH( return new ChopCubicAt0; ) |
| 262 |
| 263 class ChopCubicAt1 : public QuadBenchBase { |
| 264 public: |
| 265 ChopCubicAt1() : QuadBenchBase("chopcubicat1") {} |
| 266 protected: |
| 267 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { |
| 268 SkPoint dst[7]; |
| 269 for (int outer = 0; outer < loops; ++outer) { |
| 270 SkChopCubicAt2(fPts, dst, 0.5f); |
| 271 SkChopCubicAt2(fPts, dst, 0.5f); |
| 272 SkChopCubicAt2(fPts, dst, 0.5f); |
| 273 SkChopCubicAt2(fPts, dst, 0.5f); |
| 274 } |
| 275 } |
| 276 }; |
| 277 DEF_BENCH( return new ChopCubicAt1; ) |
| 278 |
OLD | NEW |