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

Unified Diff: bench/Matrix44Bench.cpp

Issue 1146953003: Split SetConcatMatrix44Bench to cover both internal paths. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: slow -> general Created 5 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(); )
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698