blob: 78482d963d49f8858d64940cd170758a502e69e0 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
2/*
3 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
tfarinaf168b862014-06-19 12:32:29 -07008#include "Benchmark.h"
reed@google.com3fb51872011-06-01 15:11:22 +00009#include "SkMatrix.h"
commit-bot@chromium.org5b2e2642013-09-03 19:08:14 +000010#include "SkMatrixUtils.h"
tomhudson@google.com7b4e1072011-06-03 19:16:56 +000011#include "SkRandom.h"
reed@google.com3fb51872011-06-01 15:11:22 +000012#include "SkString.h"
13
tfarinaf168b862014-06-19 12:32:29 -070014class MatrixBench : public Benchmark {
reed@google.com3fb51872011-06-01 15:11:22 +000015 SkString fName;
reed@google.com3fb51872011-06-01 15:11:22 +000016public:
mtklein@google.com410e6e82013-09-13 19:52:27 +000017 MatrixBench(const char name[]) {
reed@google.com3fb51872011-06-01 15:11:22 +000018 fName.printf("matrix_%s", name);
commit-bot@chromium.org644629c2013-11-21 06:21:58 +000019 }
20
21 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE {
22 return backend == kNonRendering_Backend;
reed@google.com3fb51872011-06-01 15:11:22 +000023 }
24
25 virtual void performTest() = 0;
26
27protected:
reed@google.comcbefd7d2011-06-06 13:31:30 +000028 virtual int mulLoopCount() const { return 1; }
29
reed@google.com3fb51872011-06-01 15:11:22 +000030 virtual const char* onGetName() {
31 return fName.c_str();
32 }
33
commit-bot@chromium.org33614712013-12-03 18:17:16 +000034 virtual void onDraw(const int loops, SkCanvas*) {
35 for (int i = 0; i < loops; i++) {
reed@google.com3fb51872011-06-01 15:11:22 +000036 this->performTest();
37 }
38 }
39
40private:
tfarinaf168b862014-06-19 12:32:29 -070041 typedef Benchmark INHERITED;
reed@google.com3fb51872011-06-01 15:11:22 +000042};
43
reed@google.com3fb51872011-06-01 15:11:22 +000044
45class EqualsMatrixBench : public MatrixBench {
46public:
mtklein@google.com410e6e82013-09-13 19:52:27 +000047 EqualsMatrixBench() : INHERITED("equals") {}
reed@google.com3fb51872011-06-01 15:11:22 +000048protected:
49 virtual void performTest() {
50 SkMatrix m0, m1, m2;
tomhudson@google.com7b4e1072011-06-03 19:16:56 +000051
reed@google.com3fb51872011-06-01 15:11:22 +000052 m0.reset();
53 m1.reset();
54 m2.reset();
mtkleincf44feb2014-06-02 18:22:12 -070055
56 // xor into a volatile prevents these comparisons from being optimized away.
57 volatile bool junk = false;
58 junk ^= (m0 == m1);
59 junk ^= (m1 == m2);
60 junk ^= (m2 == m0);
reed@google.com3fb51872011-06-01 15:11:22 +000061 }
62private:
63 typedef MatrixBench INHERITED;
64};
65
66class ScaleMatrixBench : public MatrixBench {
67public:
mtklein@google.com410e6e82013-09-13 19:52:27 +000068 ScaleMatrixBench() : INHERITED("scale") {
commit-bot@chromium.org4b413c82013-11-25 19:44:07 +000069 fSX = fSY = 1.5f;
reed@google.com3fb51872011-06-01 15:11:22 +000070 fM0.reset();
71 fM1.setScale(fSX, fSY);
72 fM2.setTranslate(fSX, fSY);
reed@google.com3fb51872011-06-01 15:11:22 +000073 }
74protected:
75 virtual void performTest() {
76 SkMatrix m;
77 m = fM0; m.preScale(fSX, fSY);
78 m = fM1; m.preScale(fSX, fSY);
79 m = fM2; m.preScale(fSX, fSY);
80 }
81private:
82 SkMatrix fM0, fM1, fM2;
83 SkScalar fSX, fSY;
84 typedef MatrixBench INHERITED;
85};
86
reed@google.come0dcde72011-06-06 13:20:29 +000087// having unknown values in our arrays can throw off the timing a lot, perhaps
88// handling NaN values is a lot slower. Anyway, this guy is just meant to put
89// reasonable values in our arrays.
90template <typename T> void init9(T array[9]) {
commit-bot@chromium.orge0e7cfe2013-09-09 20:09:12 +000091 SkRandom rand;
reed@google.come0dcde72011-06-06 13:20:29 +000092 for (int i = 0; i < 9; i++) {
93 array[i] = rand.nextSScalar1();
94 }
95}
96
tomhudson@google.com7b4e1072011-06-03 19:16:56 +000097// Test the performance of setConcat() non-perspective case:
98// using floating point precision only.
99class FloatConcatMatrixBench : public MatrixBench {
100public:
mtklein@google.com410e6e82013-09-13 19:52:27 +0000101 FloatConcatMatrixBench() : INHERITED("concat_floatfloat") {
reed@google.come0dcde72011-06-06 13:20:29 +0000102 init9(mya);
103 init9(myb);
104 init9(myr);
tomhudson@google.com7b4e1072011-06-03 19:16:56 +0000105 }
106protected:
reed@google.comcbefd7d2011-06-06 13:31:30 +0000107 virtual int mulLoopCount() const { return 4; }
108
tomhudson@google.com7b4e1072011-06-03 19:16:56 +0000109 static inline void muladdmul(float a, float b, float c, float d,
110 float* result) {
111 *result = a * b + c * d;
112 }
113 virtual void performTest() {
tomhudson@google.coma20416b2011-06-03 20:32:58 +0000114 const float* a = mya;
115 const float* b = myb;
116 float* r = myr;
tomhudson@google.com7b4e1072011-06-03 19:16:56 +0000117 muladdmul(a[0], b[0], a[1], b[3], &r[0]);
118 muladdmul(a[0], b[1], a[1], b[4], &r[1]);
119 muladdmul(a[0], b[2], a[1], b[5], &r[2]);
tomhudson@google.coma20416b2011-06-03 20:32:58 +0000120 r[2] += a[2];
tomhudson@google.com7b4e1072011-06-03 19:16:56 +0000121 muladdmul(a[3], b[0], a[4], b[3], &r[3]);
122 muladdmul(a[3], b[1], a[4], b[4], &r[4]);
123 muladdmul(a[3], b[2], a[4], b[5], &r[5]);
tomhudson@google.coma20416b2011-06-03 20:32:58 +0000124 r[5] += a[5];
125 r[6] = r[7] = 0.0f;
126 r[8] = 1.0f;
tomhudson@google.com7b4e1072011-06-03 19:16:56 +0000127 }
128private:
tomhudson@google.coma20416b2011-06-03 20:32:58 +0000129 float mya [9];
130 float myb [9];
131 float myr [9];
tomhudson@google.com7b4e1072011-06-03 19:16:56 +0000132 typedef MatrixBench INHERITED;
133};
134
135static inline float SkDoubleToFloat(double x) {
136 return static_cast<float>(x);
137}
138
139// Test the performance of setConcat() non-perspective case:
140// using floating point precision but casting up to float for
141// intermediate results during computations.
142class FloatDoubleConcatMatrixBench : public MatrixBench {
143public:
mtklein@google.com410e6e82013-09-13 19:52:27 +0000144 FloatDoubleConcatMatrixBench() : INHERITED("concat_floatdouble") {
reed@google.come0dcde72011-06-06 13:20:29 +0000145 init9(mya);
146 init9(myb);
147 init9(myr);
tomhudson@google.com7b4e1072011-06-03 19:16:56 +0000148 }
149protected:
reed@google.comcbefd7d2011-06-06 13:31:30 +0000150 virtual int mulLoopCount() const { return 4; }
151
tomhudson@google.com7b4e1072011-06-03 19:16:56 +0000152 static inline void muladdmul(float a, float b, float c, float d,
153 float* result) {
154 *result = SkDoubleToFloat((double)a * b + (double)c * d);
155 }
156 virtual void performTest() {
tomhudson@google.coma20416b2011-06-03 20:32:58 +0000157 const float* a = mya;
158 const float* b = myb;
159 float* r = myr;
tomhudson@google.com7b4e1072011-06-03 19:16:56 +0000160 muladdmul(a[0], b[0], a[1], b[3], &r[0]);
161 muladdmul(a[0], b[1], a[1], b[4], &r[1]);
162 muladdmul(a[0], b[2], a[1], b[5], &r[2]);
tomhudson@google.coma20416b2011-06-03 20:32:58 +0000163 r[2] += a[2];
tomhudson@google.com7b4e1072011-06-03 19:16:56 +0000164 muladdmul(a[3], b[0], a[4], b[3], &r[3]);
165 muladdmul(a[3], b[1], a[4], b[4], &r[4]);
166 muladdmul(a[3], b[2], a[4], b[5], &r[5]);
tomhudson@google.coma20416b2011-06-03 20:32:58 +0000167 r[5] += a[5];
168 r[6] = r[7] = 0.0f;
169 r[8] = 1.0f;
tomhudson@google.com7b4e1072011-06-03 19:16:56 +0000170 }
171private:
tomhudson@google.coma20416b2011-06-03 20:32:58 +0000172 float mya [9];
173 float myb [9];
174 float myr [9];
tomhudson@google.com7b4e1072011-06-03 19:16:56 +0000175 typedef MatrixBench INHERITED;
176};
177
178// Test the performance of setConcat() non-perspective case:
179// using double precision only.
180class DoubleConcatMatrixBench : public MatrixBench {
181public:
mtklein@google.com410e6e82013-09-13 19:52:27 +0000182 DoubleConcatMatrixBench() : INHERITED("concat_double") {
reed@google.come0dcde72011-06-06 13:20:29 +0000183 init9(mya);
184 init9(myb);
185 init9(myr);
tomhudson@google.com7b4e1072011-06-03 19:16:56 +0000186 }
187protected:
reed@google.comcbefd7d2011-06-06 13:31:30 +0000188 virtual int mulLoopCount() const { return 4; }
189
tomhudson@google.com7b4e1072011-06-03 19:16:56 +0000190 static inline void muladdmul(double a, double b, double c, double d,
191 double* result) {
192 *result = a * b + c * d;
193 }
194 virtual void performTest() {
tomhudson@google.coma20416b2011-06-03 20:32:58 +0000195 const double* a = mya;
196 const double* b = myb;
197 double* r = myr;
tomhudson@google.com7b4e1072011-06-03 19:16:56 +0000198 muladdmul(a[0], b[0], a[1], b[3], &r[0]);
199 muladdmul(a[0], b[1], a[1], b[4], &r[1]);
200 muladdmul(a[0], b[2], a[1], b[5], &r[2]);
tomhudson@google.coma20416b2011-06-03 20:32:58 +0000201 r[2] += a[2];
tomhudson@google.com7b4e1072011-06-03 19:16:56 +0000202 muladdmul(a[3], b[0], a[4], b[3], &r[3]);
203 muladdmul(a[3], b[1], a[4], b[4], &r[4]);
204 muladdmul(a[3], b[2], a[4], b[5], &r[5]);
tomhudson@google.coma20416b2011-06-03 20:32:58 +0000205 r[5] += a[5];
206 r[6] = r[7] = 0.0;
207 r[8] = 1.0;
tomhudson@google.com7b4e1072011-06-03 19:16:56 +0000208 }
209private:
tomhudson@google.coma20416b2011-06-03 20:32:58 +0000210 double mya [9];
211 double myb [9];
212 double myr [9];
tomhudson@google.com7b4e1072011-06-03 19:16:56 +0000213 typedef MatrixBench INHERITED;
214};
215
tomhudson@google.com317d5402011-06-24 18:30:49 +0000216class GetTypeMatrixBench : public MatrixBench {
217public:
mtklein@google.com410e6e82013-09-13 19:52:27 +0000218 GetTypeMatrixBench()
219 : INHERITED("gettype") {
bsalomon@google.com820e80a2011-10-24 21:09:40 +0000220 fArray[0] = (float) fRnd.nextS();
221 fArray[1] = (float) fRnd.nextS();
222 fArray[2] = (float) fRnd.nextS();
223 fArray[3] = (float) fRnd.nextS();
224 fArray[4] = (float) fRnd.nextS();
225 fArray[5] = (float) fRnd.nextS();
226 fArray[6] = (float) fRnd.nextS();
227 fArray[7] = (float) fRnd.nextS();
228 fArray[8] = (float) fRnd.nextS();
tomhudson@google.com317d5402011-06-24 18:30:49 +0000229 }
230protected:
231 // Putting random generation of the matrix inside performTest()
232 // would help us avoid anomalous runs, but takes up 25% or
233 // more of the function time.
234 virtual void performTest() {
235 fMatrix.setAll(fArray[0], fArray[1], fArray[2],
236 fArray[3], fArray[4], fArray[5],
237 fArray[6], fArray[7], fArray[8]);
mtkleincf44feb2014-06-02 18:22:12 -0700238 // xoring into a volatile prevents the compiler from optimizing these away
239 volatile int junk = 0;
240 junk ^= (fMatrix.getType());
tomhudson@google.com317d5402011-06-24 18:30:49 +0000241 fMatrix.dirtyMatrixTypeCache();
mtkleincf44feb2014-06-02 18:22:12 -0700242 junk ^= (fMatrix.getType());
tomhudson@google.com317d5402011-06-24 18:30:49 +0000243 fMatrix.dirtyMatrixTypeCache();
mtkleincf44feb2014-06-02 18:22:12 -0700244 junk ^= (fMatrix.getType());
tomhudson@google.com317d5402011-06-24 18:30:49 +0000245 fMatrix.dirtyMatrixTypeCache();
mtkleincf44feb2014-06-02 18:22:12 -0700246 junk ^= (fMatrix.getType());
tomhudson@google.com317d5402011-06-24 18:30:49 +0000247 fMatrix.dirtyMatrixTypeCache();
mtkleincf44feb2014-06-02 18:22:12 -0700248 junk ^= (fMatrix.getType());
tomhudson@google.com317d5402011-06-24 18:30:49 +0000249 fMatrix.dirtyMatrixTypeCache();
mtkleincf44feb2014-06-02 18:22:12 -0700250 junk ^= (fMatrix.getType());
tomhudson@google.com317d5402011-06-24 18:30:49 +0000251 fMatrix.dirtyMatrixTypeCache();
mtkleincf44feb2014-06-02 18:22:12 -0700252 junk ^= (fMatrix.getType());
tomhudson@google.com317d5402011-06-24 18:30:49 +0000253 fMatrix.dirtyMatrixTypeCache();
mtkleincf44feb2014-06-02 18:22:12 -0700254 junk ^= (fMatrix.getType());
tomhudson@google.com317d5402011-06-24 18:30:49 +0000255 }
256private:
257 SkMatrix fMatrix;
258 float fArray[9];
commit-bot@chromium.orge0e7cfe2013-09-09 20:09:12 +0000259 SkRandom fRnd;
tomhudson@google.com317d5402011-06-24 18:30:49 +0000260 typedef MatrixBench INHERITED;
261};
262
tomhudson@google.com288ff332011-06-07 14:31:38 +0000263class ScaleTransMixedMatrixBench : public MatrixBench {
264 public:
mtklein@google.com410e6e82013-09-13 19:52:27 +0000265 ScaleTransMixedMatrixBench() : INHERITED("scaletrans_mixed") {
bsalomon@google.com3d3dfe02011-11-10 13:50:19 +0000266 fMatrix.setAll(fRandom.nextSScalar1(), fRandom.nextSScalar1(), fRandom.nextSScalar1(),
267 fRandom.nextSScalar1(), fRandom.nextSScalar1(), fRandom.nextSScalar1(),
268 fRandom.nextSScalar1(), fRandom.nextSScalar1(), fRandom.nextSScalar1());
tomhudson@google.com288ff332011-06-07 14:31:38 +0000269 int i;
tfarina@chromium.org7731ead2013-04-05 21:13:14 +0000270 for (i = 0; i < kCount; i++) {
bsalomon@google.com820e80a2011-10-24 21:09:40 +0000271 fSrc[i].fX = fRandom.nextSScalar1();
272 fSrc[i].fY = fRandom.nextSScalar1();
273 fDst[i].fX = fRandom.nextSScalar1();
274 fDst[i].fY = fRandom.nextSScalar1();
tomhudson@google.com288ff332011-06-07 14:31:38 +0000275 }
276 }
277 protected:
278 virtual void performTest() {
279 SkPoint* dst = fDst;
280 const SkPoint* src = fSrc;
tfarina@chromium.org7731ead2013-04-05 21:13:14 +0000281 int count = kCount;
tomhudson@google.com288ff332011-06-07 14:31:38 +0000282 float mx = fMatrix[SkMatrix::kMScaleX];
283 float my = fMatrix[SkMatrix::kMScaleY];
284 float tx = fMatrix[SkMatrix::kMTransX];
285 float ty = fMatrix[SkMatrix::kMTransY];
286 do {
287 dst->fY = SkScalarMulAdd(src->fY, my, ty);
288 dst->fX = SkScalarMulAdd(src->fX, mx, tx);
289 src += 1;
290 dst += 1;
291 } while (--count);
292 }
293 private:
tfarina@chromium.org7731ead2013-04-05 21:13:14 +0000294 enum {
mtklein@google.comc2897432013-09-10 19:23:38 +0000295 kCount = 16
tfarina@chromium.org7731ead2013-04-05 21:13:14 +0000296 };
tomhudson@google.com288ff332011-06-07 14:31:38 +0000297 SkMatrix fMatrix;
mtklein@google.comc2897432013-09-10 19:23:38 +0000298 SkPoint fSrc [kCount];
299 SkPoint fDst [kCount];
commit-bot@chromium.orge0e7cfe2013-09-09 20:09:12 +0000300 SkRandom fRandom;
tomhudson@google.com288ff332011-06-07 14:31:38 +0000301 typedef MatrixBench INHERITED;
302};
tomhudson@google.com288ff332011-06-07 14:31:38 +0000303
304class ScaleTransDoubleMatrixBench : public MatrixBench {
305 public:
mtklein@google.com410e6e82013-09-13 19:52:27 +0000306 ScaleTransDoubleMatrixBench() : INHERITED("scaletrans_double") {
tomhudson@google.com288ff332011-06-07 14:31:38 +0000307 init9(fMatrix);
308 int i;
tfarina@chromium.org7731ead2013-04-05 21:13:14 +0000309 for (i = 0; i < kCount; i++) {
bsalomon@google.com820e80a2011-10-24 21:09:40 +0000310 fSrc[i].fX = fRandom.nextSScalar1();
311 fSrc[i].fY = fRandom.nextSScalar1();
312 fDst[i].fX = fRandom.nextSScalar1();
313 fDst[i].fY = fRandom.nextSScalar1();
tomhudson@google.com288ff332011-06-07 14:31:38 +0000314 }
315 }
316 protected:
317 virtual void performTest() {
318 SkPoint* dst = fDst;
319 const SkPoint* src = fSrc;
tfarina@chromium.org7731ead2013-04-05 21:13:14 +0000320 int count = kCount;
tomhudson@google.com288ff332011-06-07 14:31:38 +0000321 // As doubles, on Z600 Linux systems this is 2.5x as expensive as mixed mode
bsalomon@google.com820e80a2011-10-24 21:09:40 +0000322 float mx = (float) fMatrix[SkMatrix::kMScaleX];
323 float my = (float) fMatrix[SkMatrix::kMScaleY];
324 float tx = (float) fMatrix[SkMatrix::kMTransX];
325 float ty = (float) fMatrix[SkMatrix::kMTransY];
tomhudson@google.com288ff332011-06-07 14:31:38 +0000326 do {
327 dst->fY = src->fY * my + ty;
328 dst->fX = src->fX * mx + tx;
329 src += 1;
330 dst += 1;
331 } while (--count);
332 }
333 private:
tfarina@chromium.org7731ead2013-04-05 21:13:14 +0000334 enum {
mtklein@google.comc2897432013-09-10 19:23:38 +0000335 kCount = 16
tfarina@chromium.org7731ead2013-04-05 21:13:14 +0000336 };
tomhudson@google.com288ff332011-06-07 14:31:38 +0000337 double fMatrix [9];
mtklein@google.comc2897432013-09-10 19:23:38 +0000338 SkPoint fSrc [kCount];
339 SkPoint fDst [kCount];
commit-bot@chromium.orge0e7cfe2013-09-09 20:09:12 +0000340 SkRandom fRandom;
tomhudson@google.com288ff332011-06-07 14:31:38 +0000341 typedef MatrixBench INHERITED;
342};
tomhudson@google.com288ff332011-06-07 14:31:38 +0000343
commit-bot@chromium.org5b2e2642013-09-03 19:08:14 +0000344class DecomposeMatrixBench : public MatrixBench {
345public:
mtklein@google.com410e6e82013-09-13 19:52:27 +0000346 DecomposeMatrixBench() : INHERITED("decompose") {}
commit-bot@chromium.org5b2e2642013-09-03 19:08:14 +0000347
348protected:
349 virtual void onPreDraw() {
350 for (int i = 0; i < 10; ++i) {
351 SkScalar rot0 = (fRandom.nextBool()) ? fRandom.nextRangeF(-180, 180) : 0.0f;
352 SkScalar sx = fRandom.nextRangeF(-3000.f, 3000.f);
353 SkScalar sy = (fRandom.nextBool()) ? fRandom.nextRangeF(-3000.f, 3000.f) : sx;
354 SkScalar rot1 = fRandom.nextRangeF(-180, 180);
355 fMatrix[i].setRotate(rot0);
356 fMatrix[i].postScale(sx, sy);
357 fMatrix[i].postRotate(rot1);
358 }
359 }
360 virtual void performTest() {
361 SkPoint rotation1, scale, rotation2;
362 for (int i = 0; i < 10; ++i) {
363 (void) SkDecomposeUpper2x2(fMatrix[i], &rotation1, &scale, &rotation2);
364 }
365 }
366private:
367 SkMatrix fMatrix[10];
commit-bot@chromium.orge0e7cfe2013-09-09 20:09:12 +0000368 SkRandom fRandom;
commit-bot@chromium.org5b2e2642013-09-03 19:08:14 +0000369 typedef MatrixBench INHERITED;
370};
371
junov@chromium.org6fc56992012-07-12 14:01:32 +0000372class InvertMapRectMatrixBench : public MatrixBench {
373public:
mtklein@google.com410e6e82013-09-13 19:52:27 +0000374 InvertMapRectMatrixBench(const char* name, int flags)
375 : INHERITED(name)
junov@chromium.org6fc56992012-07-12 14:01:32 +0000376 , fFlags(flags) {
377 fMatrix.reset();
378 fIteration = 0;
379 if (flags & kScale_Flag) {
commit-bot@chromium.org4b413c82013-11-25 19:44:07 +0000380 fMatrix.postScale(1.5f, 2.5f);
junov@chromium.org6fc56992012-07-12 14:01:32 +0000381 }
382 if (flags & kTranslate_Flag) {
commit-bot@chromium.org4b413c82013-11-25 19:44:07 +0000383 fMatrix.postTranslate(1.5f, 2.5f);
junov@chromium.org6fc56992012-07-12 14:01:32 +0000384 }
385 if (flags & kRotate_Flag) {
commit-bot@chromium.org4b413c82013-11-25 19:44:07 +0000386 fMatrix.postRotate(45.0f);
junov@chromium.org6fc56992012-07-12 14:01:32 +0000387 }
388 if (flags & kPerspective_Flag) {
commit-bot@chromium.org4b413c82013-11-25 19:44:07 +0000389 fMatrix.setPerspX(1.5f);
390 fMatrix.setPerspY(2.5f);
junov@chromium.org6fc56992012-07-12 14:01:32 +0000391 }
392 if (0 == (flags & kUncachedTypeMask_Flag)) {
393 fMatrix.getType();
394 }
395 }
396 enum Flag {
397 kScale_Flag = 0x01,
398 kTranslate_Flag = 0x02,
399 kRotate_Flag = 0x04,
400 kPerspective_Flag = 0x08,
401 kUncachedTypeMask_Flag = 0x10,
402 };
403protected:
404 virtual void performTest() {
405 if (fFlags & kUncachedTypeMask_Flag) {
406 // This will invalidate the typemask without
407 // changing the matrix.
408 fMatrix.setPerspX(fMatrix.getPerspX());
409 }
410 SkMatrix inv;
robertphillips@google.com31f8f732012-09-17 13:36:47 +0000411 bool invertible = fMatrix.invert(&inv);
junov@chromium.org6fc56992012-07-12 14:01:32 +0000412 SkASSERT(invertible);
413 SkRect transformedRect;
robertphillips@google.com31f8f732012-09-17 13:36:47 +0000414 // an arbitrary, small, non-zero rect to transform
415 SkRect srcRect = SkRect::MakeWH(SkIntToScalar(10), SkIntToScalar(10));
junov@chromium.org6fc56992012-07-12 14:01:32 +0000416 if (invertible) {
robertphillips@google.com31f8f732012-09-17 13:36:47 +0000417 inv.mapRect(&transformedRect, srcRect);
junov@chromium.org6fc56992012-07-12 14:01:32 +0000418 }
419 }
420private:
421 SkMatrix fMatrix;
junov@chromium.org6fc56992012-07-12 14:01:32 +0000422 int fFlags;
423 unsigned fIteration;
424 typedef MatrixBench INHERITED;
425};
tomhudson@google.com288ff332011-06-07 14:31:38 +0000426
reed@google.com82bf8bb2013-01-04 14:04:08 +0000427///////////////////////////////////////////////////////////////////////////////
tomhudson@google.com288ff332011-06-07 14:31:38 +0000428
mtklein@google.com410e6e82013-09-13 19:52:27 +0000429DEF_BENCH( return new EqualsMatrixBench(); )
430DEF_BENCH( return new ScaleMatrixBench(); )
431DEF_BENCH( return new FloatConcatMatrixBench(); )
432DEF_BENCH( return new FloatDoubleConcatMatrixBench(); )
433DEF_BENCH( return new DoubleConcatMatrixBench(); )
434DEF_BENCH( return new GetTypeMatrixBench(); )
435DEF_BENCH( return new DecomposeMatrixBench(); )
commit-bot@chromium.org5b2e2642013-09-03 19:08:14 +0000436
mtklein@google.com410e6e82013-09-13 19:52:27 +0000437DEF_BENCH( return new InvertMapRectMatrixBench("invert_maprect_identity", 0); )
tomhudson@google.com288ff332011-06-07 14:31:38 +0000438
mtklein@google.com410e6e82013-09-13 19:52:27 +0000439DEF_BENCH(return new InvertMapRectMatrixBench(
reed@google.com90533be2013-01-04 15:46:42 +0000440 "invert_maprect_rectstaysrect",
441 InvertMapRectMatrixBench::kScale_Flag |
442 InvertMapRectMatrixBench::kTranslate_Flag); )
443
mtklein@google.com410e6e82013-09-13 19:52:27 +0000444DEF_BENCH(return new InvertMapRectMatrixBench(
reed@google.com90533be2013-01-04 15:46:42 +0000445 "invert_maprect_translate",
446 InvertMapRectMatrixBench::kTranslate_Flag); )
tomhudson@google.com7b4e1072011-06-03 19:16:56 +0000447
mtklein@google.com410e6e82013-09-13 19:52:27 +0000448DEF_BENCH(return new InvertMapRectMatrixBench(
reed@google.com82bf8bb2013-01-04 14:04:08 +0000449 "invert_maprect_nonpersp",
450 InvertMapRectMatrixBench::kScale_Flag |
451 InvertMapRectMatrixBench::kRotate_Flag |
452 InvertMapRectMatrixBench::kTranslate_Flag); )
reed@google.com3fb51872011-06-01 15:11:22 +0000453
mtklein@google.com410e6e82013-09-13 19:52:27 +0000454DEF_BENCH( return new InvertMapRectMatrixBench(
reed@google.com82bf8bb2013-01-04 14:04:08 +0000455 "invert_maprect_persp",
456 InvertMapRectMatrixBench::kPerspective_Flag); )
tomhudson@google.com288ff332011-06-07 14:31:38 +0000457
mtklein@google.com410e6e82013-09-13 19:52:27 +0000458DEF_BENCH( return new InvertMapRectMatrixBench(
reed@google.com82bf8bb2013-01-04 14:04:08 +0000459 "invert_maprect_typemask_rectstaysrect",
460 InvertMapRectMatrixBench::kUncachedTypeMask_Flag |
461 InvertMapRectMatrixBench::kScale_Flag |
462 InvertMapRectMatrixBench::kTranslate_Flag); )
463
mtklein@google.com410e6e82013-09-13 19:52:27 +0000464DEF_BENCH( return new InvertMapRectMatrixBench(
reed@google.com82bf8bb2013-01-04 14:04:08 +0000465 "invert_maprect_typemask_nonpersp",
466 InvertMapRectMatrixBench::kUncachedTypeMask_Flag |
467 InvertMapRectMatrixBench::kScale_Flag |
468 InvertMapRectMatrixBench::kRotate_Flag |
469 InvertMapRectMatrixBench::kTranslate_Flag); )
470
mtklein@google.com410e6e82013-09-13 19:52:27 +0000471DEF_BENCH( return new ScaleTransMixedMatrixBench(); )
472DEF_BENCH( return new ScaleTransDoubleMatrixBench(); )