Index: bench/Matrix44Bench.cpp |
diff --git a/bench/Matrix44Bench.cpp b/bench/Matrix44Bench.cpp |
index 5093fd274565497c4aa9952e26e4772d863a9505..81452b4a3d450b99bf4ed802f7b62069a1a0e781 100644 |
--- a/bench/Matrix44Bench.cpp |
+++ b/bench/Matrix44Bench.cpp |
@@ -248,15 +248,25 @@ private: |
class SetConcatMatrix44Bench : public Matrix44Bench { |
public: |
- SetConcatMatrix44Bench() |
- : INHERITED("setconcat") |
+ // SkMatrix44::setConcat() has a fast path for matrices that are at most scale+translate. |
+ SetConcatMatrix44Bench(bool fastPath) |
+ : INHERITED(fastPath ? "setconcat_fast" : "setconcat_general") |
, fM0(SkMatrix44::kUninitialized_Constructor) |
, fM1(SkMatrix44::kUninitialized_Constructor) |
, fM2(SkMatrix44::kUninitialized_Constructor) |
{ |
- fX = fY = fZ = SkDoubleToMScalar(1.5); |
- fM1.setScale(fX, fY, fZ); |
- fM2.setTranslate(fX, fY, fZ); |
+ if (fastPath) { |
+ const SkMScalar v = SkDoubleToMScalar(1.5); |
+ fM1.setScale(v,v,v); |
+ fM2.setTranslate(v,v,v); |
+ } else { |
+ SkRandom rand; |
+ for (int x = 0; x < 4; x++) { |
+ for (int y = 0; y < 4; y++) { |
+ fM1.setFloat(x,y, rand.nextF()); |
+ fM2.setFloat(x,y, rand.nextF()); |
+ }} |
+ } |
} |
protected: |
virtual void performTest() { |
@@ -267,7 +277,6 @@ protected: |
} |
private: |
SkMatrix44 fM0, fM1, fM2; |
- SkMScalar fX, fY, fZ; |
typedef Matrix44Bench INHERITED; |
}; |
@@ -300,5 +309,6 @@ DEF_BENCH( return new InvertMatrix44Bench(); ) |
DEF_BENCH( return new InvertAffineMatrix44Bench(); ) |
DEF_BENCH( return new InvertScaleTranslateMatrix44Bench(); ) |
DEF_BENCH( return new InvertTranslateMatrix44Bench(); ) |
-DEF_BENCH( return new SetConcatMatrix44Bench(); ) |
+DEF_BENCH( return new SetConcatMatrix44Bench(true); ) |
+DEF_BENCH( return new SetConcatMatrix44Bench(false); ) |
DEF_BENCH( return new GetTypeMatrix44Bench(); ) |