From 5b2e2640ed345c4670b99b349f62eb6f9446ec1e Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Tue, 3 Sep 2013 19:08:14 +0000 Subject: Revise SVD code to remove arctangents. Also added bench for timing matrix decomposition. R=reed@google.com Author: jvanverth@google.com Review URL: https://chromiumcodereview.appspot.com/23596006 git-svn-id: http://skia.googlecode.com/svn/trunk@11066 2bbb7eff-a529-9590-31e7-b0007b416f81 --- bench/MatrixBench.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'bench/MatrixBench.cpp') diff --git a/bench/MatrixBench.cpp b/bench/MatrixBench.cpp index cae5622414..8fe9e34e4b 100644 --- a/bench/MatrixBench.cpp +++ b/bench/MatrixBench.cpp @@ -7,6 +7,7 @@ */ #include "SkBenchmark.h" #include "SkMatrix.h" +#include "SkMatrixUtils.h" #include "SkRandom.h" #include "SkString.h" @@ -345,6 +346,34 @@ class ScaleTransDoubleMatrixBench : public MatrixBench { typedef MatrixBench INHERITED; }; +class DecomposeMatrixBench : public MatrixBench { +public: + DecomposeMatrixBench(void* param) : INHERITED(param, "decompose") {} + +protected: + virtual void onPreDraw() { + for (int i = 0; i < 10; ++i) { + SkScalar rot0 = (fRandom.nextBool()) ? fRandom.nextRangeF(-180, 180) : 0.0f; + SkScalar sx = fRandom.nextRangeF(-3000.f, 3000.f); + SkScalar sy = (fRandom.nextBool()) ? fRandom.nextRangeF(-3000.f, 3000.f) : sx; + SkScalar rot1 = fRandom.nextRangeF(-180, 180); + fMatrix[i].setRotate(rot0); + fMatrix[i].postScale(sx, sy); + fMatrix[i].postRotate(rot1); + } + } + virtual void performTest() { + SkPoint rotation1, scale, rotation2; + for (int i = 0; i < 10; ++i) { + (void) SkDecomposeUpper2x2(fMatrix[i], &rotation1, &scale, &rotation2); + } + } +private: + SkMatrix fMatrix[10]; + SkMWCRandom fRandom; + typedef MatrixBench INHERITED; +}; + class InvertMapRectMatrixBench : public MatrixBench { public: InvertMapRectMatrixBench(void* param, const char* name, int flags) @@ -408,6 +437,8 @@ DEF_BENCH( return new FloatConcatMatrixBench(p); ) DEF_BENCH( return new FloatDoubleConcatMatrixBench(p); ) DEF_BENCH( return new DoubleConcatMatrixBench(p); ) DEF_BENCH( return new GetTypeMatrixBench(p); ) +DEF_BENCH( return new DecomposeMatrixBench(p); ) + DEF_BENCH( return new InvertMapRectMatrixBench(p, "invert_maprect_identity", 0); ) DEF_BENCH(return new InvertMapRectMatrixBench(p, -- cgit v1.2.3