Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1771)

Unified Diff: bench/MatrixBench.cpp

Issue 2111703002: speed up maprect for scale+trans case (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: apply comments from #14 Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | include/core/SkMatrix.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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); )
« no previous file with comments | « no previous file | include/core/SkMatrix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698