OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "Benchmark.h" | 8 #include "Benchmark.h" |
9 #include "SkMatrix.h" | 9 #include "SkMatrix.h" |
10 #include "SkMatrixUtils.h" | 10 #include "SkMatrixUtils.h" |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 | 260 |
261 DEF_BENCH( return new InvertMapRectMatrixBench( | 261 DEF_BENCH( return new InvertMapRectMatrixBench( |
262 "invert_maprect_typemask_nonpersp", | 262 "invert_maprect_typemask_nonpersp", |
263 InvertMapRectMatrixBench::kUncachedTypeMask_Flag | | 263 InvertMapRectMatrixBench::kUncachedTypeMask_Flag | |
264 InvertMapRectMatrixBench::kScale_Flag | | 264 InvertMapRectMatrixBench::kScale_Flag | |
265 InvertMapRectMatrixBench::kRotate_Flag | | 265 InvertMapRectMatrixBench::kRotate_Flag | |
266 InvertMapRectMatrixBench::kTranslate_Flag); ) | 266 InvertMapRectMatrixBench::kTranslate_Flag); ) |
267 | 267 |
268 /////////////////////////////////////////////////////////////////////////////// | 268 /////////////////////////////////////////////////////////////////////////////// |
269 | 269 |
270 static SkMatrix make_ident() { SkMatrix m; m.reset(); return m; } | 270 static SkMatrix make_trans() { return SkMatrix::MakeTrans(2, 3); } |
271 static SkMatrix make_trans() { SkMatrix m; m.setTranslate(2, 3); return m; } | |
272 static SkMatrix make_scale() { SkMatrix m(make_trans()); m.postScale(1.5f, 0.5f)
; return m; } | 271 static SkMatrix make_scale() { SkMatrix m(make_trans()); m.postScale(1.5f, 0.5f)
; return m; } |
273 static SkMatrix make_afine() { SkMatrix m(make_trans()); m.postRotate(15); retur
n m; } | 272 static SkMatrix make_afine() { SkMatrix m(make_trans()); m.postRotate(15); retur
n m; } |
274 | 273 |
275 class MapPointsMatrixBench : public MatrixBench { | 274 class MapPointsMatrixBench : public MatrixBench { |
276 protected: | 275 protected: |
277 SkMatrix fM; | 276 SkMatrix fM; |
278 enum { | 277 enum { |
279 N = 32 | 278 N = 32 |
280 }; | 279 }; |
281 SkPoint fSrc[N], fDst[N]; | 280 SkPoint fSrc[N], fDst[N]; |
(...skipping 13 matching lines...) Expand all Loading... |
295 for (int i = 0; i < 1000000; ++i) { | 294 for (int i = 0; i < 1000000; ++i) { |
296 fM.mapPts(fDst, fSrc, N); | 295 fM.mapPts(fDst, fSrc, N); |
297 } | 296 } |
298 } else { | 297 } else { |
299 for (int i = 0; i < 1000000; ++i) { | 298 for (int i = 0; i < 1000000; ++i) { |
300 fM.mapPoints(fDst, fSrc, N); | 299 fM.mapPoints(fDst, fSrc, N); |
301 } | 300 } |
302 } | 301 } |
303 } | 302 } |
304 }; | 303 }; |
305 DEF_BENCH( return new MapPointsMatrixBench("mappts_ident0", make_ident(), false)
; ) | |
306 DEF_BENCH( return new MapPointsMatrixBench("mappts_ident1", make_ident(), true);
) | |
307 DEF_BENCH( return new MapPointsMatrixBench("mappts_trans0", make_trans(), false)
; ) | 304 DEF_BENCH( return new MapPointsMatrixBench("mappts_trans0", make_trans(), false)
; ) |
308 DEF_BENCH( return new MapPointsMatrixBench("mappts_trans1", make_trans(), true);
) | 305 DEF_BENCH( return new MapPointsMatrixBench("mappts_trans1", make_trans(), true);
) |
309 DEF_BENCH( return new MapPointsMatrixBench("mappts_scale0", make_scale(), false)
; ) | 306 DEF_BENCH( return new MapPointsMatrixBench("mappts_scale0", make_scale(), false)
; ) |
310 DEF_BENCH( return new MapPointsMatrixBench("mappts_scale1", make_scale(), true);
) | 307 DEF_BENCH( return new MapPointsMatrixBench("mappts_scale1", make_scale(), true);
) |
311 DEF_BENCH( return new MapPointsMatrixBench("mappts_afine0", make_afine(), false)
; ) | 308 DEF_BENCH( return new MapPointsMatrixBench("mappts_afine0", make_afine(), false)
; ) |
312 DEF_BENCH( return new MapPointsMatrixBench("mappts_afine1", make_afine(), true);
) | 309 DEF_BENCH( return new MapPointsMatrixBench("mappts_afine1", make_afine(), true);
) |
313 | 310 |
OLD | NEW |