OLD | NEW |
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 #include "Benchmark.h" | 7 #include "Benchmark.h" |
8 #include "SkMatrix.h" | 8 #include "SkMatrix.h" |
9 #include "SkMatrixUtils.h" | 9 #include "SkMatrixUtils.h" |
10 #include "SkRandom.h" | 10 #include "SkRandom.h" |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 void performTest() override { | 290 void performTest() override { |
291 for (int i = 0; i < 1000000; ++i) { | 291 for (int i = 0; i < 1000000; ++i) { |
292 fM.mapPoints(fDst, fSrc, N); | 292 fM.mapPoints(fDst, fSrc, N); |
293 } | 293 } |
294 } | 294 } |
295 }; | 295 }; |
296 DEF_BENCH( return new MapPointsMatrixBench("mappoints_identity", SkMatrix::I());
) | 296 DEF_BENCH( return new MapPointsMatrixBench("mappoints_identity", SkMatrix::I());
) |
297 DEF_BENCH( return new MapPointsMatrixBench("mappoints_trans", make_trans()); ) | 297 DEF_BENCH( return new MapPointsMatrixBench("mappoints_trans", make_trans()); ) |
298 DEF_BENCH( return new MapPointsMatrixBench("mappoints_scale", make_scale()); ) | 298 DEF_BENCH( return new MapPointsMatrixBench("mappoints_scale", make_scale()); ) |
299 DEF_BENCH( return new MapPointsMatrixBench("mappoints_affine", make_afine()); ) | 299 DEF_BENCH( return new MapPointsMatrixBench("mappoints_affine", make_afine()); ) |
| 300 |
| 301 /////////////////////////////////////////////////////////////////////////////// |
| 302 |
| 303 class MapRectMatrixBench : public MatrixBench { |
| 304 SkMatrix fM; |
| 305 SkRect fR; |
| 306 bool fScaleTrans; |
| 307 |
| 308 enum { MEGA_LOOP = 1000 * 1000 }; |
| 309 public: |
| 310 MapRectMatrixBench(const char name[], bool scale_trans) |
| 311 : MatrixBench(name), fScaleTrans(scale_trans) |
| 312 { |
| 313 fM.setScale(2, 3); |
| 314 fM.postTranslate(1, 2); |
| 315 |
| 316 fR.set(10, 10, 100, 200); |
| 317 } |
| 318 |
| 319 void performTest() override { |
| 320 SkRect dst; |
| 321 if (fScaleTrans) { |
| 322 for (int i = 0; i < MEGA_LOOP; ++i) { |
| 323 fM.mapRectScaleTranslate(&dst, fR); |
| 324 } |
| 325 } else { |
| 326 for (int i = 0; i < MEGA_LOOP; ++i) { |
| 327 fM.mapRect(&dst, fR); |
| 328 } |
| 329 } |
| 330 } |
| 331 }; |
| 332 DEF_BENCH( return new MapRectMatrixBench("maprect", false); ) |
| 333 DEF_BENCH( return new MapRectMatrixBench("maprectscaletrans", true); ) |
OLD | NEW |