Index: bench/MatrixBench.cpp |
diff --git a/bench/MatrixBench.cpp b/bench/MatrixBench.cpp |
index a185fec58953a12a068294e172aad3484ff5d791..53e72967313e2deebdfc72e602a9a7a631bb7f5b 100644 |
--- a/bench/MatrixBench.cpp |
+++ b/bench/MatrixBench.cpp |
@@ -297,3 +297,37 @@ DEF_BENCH( return new MapPointsMatrixBench("mappoints_identity", SkMatrix::I()); |
DEF_BENCH( return new MapPointsMatrixBench("mappoints_trans", make_trans()); ) |
DEF_BENCH( return new MapPointsMatrixBench("mappoints_scale", make_scale()); ) |
DEF_BENCH( return new MapPointsMatrixBench("mappoints_affine", make_afine()); ) |
+ |
+/////////////////////////////////////////////////////////////////////////////// |
+ |
+class MapRectMatrixBench : public MatrixBench { |
+ SkMatrix fM; |
+ SkRect fR; |
+ bool fScaleTrans; |
+ |
+ enum { MEGA_LOOP = 1000 * 1000 }; |
+public: |
+ MapRectMatrixBench(const char name[], bool scale_trans) |
+ : MatrixBench(name), fScaleTrans(scale_trans) |
+ { |
+ fM.setScale(2, 3); |
+ fM.postTranslate(1, 2); |
+ |
+ fR.set(10, 10, 100, 200); |
+ } |
+ |
+ void performTest() override { |
+ SkRect dst; |
+ if (fScaleTrans) { |
+ for (int i = 0; i < MEGA_LOOP; ++i) { |
+ fM.mapRectScaleTranslate(&dst, fR); |
+ } |
+ } else { |
+ for (int i = 0; i < MEGA_LOOP; ++i) { |
+ fM.mapRect(&dst, fR); |
+ } |
+ } |
+ } |
+}; |
+DEF_BENCH( return new MapRectMatrixBench("maprect", false); ) |
+DEF_BENCH( return new MapRectMatrixBench("maprectscaletrans", true); ) |