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

Unified Diff: bench/MatrixBench.cpp

Issue 23596006: Revise SVD code to remove arctangents. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix matrix_decompose bench to actually check random matrices. Created 7 years, 4 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 | src/core/SkMatrix.cpp » ('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 cae56224142540122b2f667422782831642e760a..8fe9e34e4be959950a756ddad839636c1175a8dd 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,
« no previous file with comments | « no previous file | src/core/SkMatrix.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698