OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SKPAnimationBench_DEFINED | 8 #ifndef SKPAnimationBench_DEFINED |
9 #define SKPAnimationBench_DEFINED | 9 #define SKPAnimationBench_DEFINED |
10 | 10 |
11 #include "SKPBench.h" | 11 #include "SKPBench.h" |
| 12 #include "Timer.h" |
12 | 13 |
13 /** | 14 /** |
14 * Runs an SkPicture as a benchmark by repeatedly drawing it, first centering th
e picture and | 15 * Runs an SkPicture as a benchmark by repeatedly drawing it, first centering th
e picture and |
15 * for each step it concats the passed in matrix | 16 * for each step it concats the passed in matrix |
16 */ | 17 */ |
17 class SKPAnimationBench : public SKPBench { | 18 class SKPAnimationBench : public SKPBench { |
18 public: | 19 public: |
19 SKPAnimationBench(const char* name, const SkPicture*, const SkIRect& devClip
, | 20 class Animation : public SkRefCnt { |
20 SkMatrix viewMatrix, int steps, bool doLooping); | 21 public: |
| 22 virtual const char* getTag() = 0; |
| 23 virtual void preConcatFrameMatrix(double animationTimeMs, const SkIRect&
devBounds, |
| 24 SkMatrix* drawMatrix) = 0; |
| 25 virtual ~Animation() {} |
| 26 }; |
| 27 |
| 28 SKPAnimationBench(const char* name, const SkPicture*, const SkIRect& devClip
, Animation*, |
| 29 bool doLooping); |
| 30 |
| 31 static Animation* CreateZoomAnimation(SkScalar zoomMax, double zoomPeriodMs)
; |
21 | 32 |
22 protected: | 33 protected: |
23 const char* onGetName() override; | |
24 const char* onGetUniqueName() override; | 34 const char* onGetUniqueName() override; |
25 void onPerCanvasPreDraw(SkCanvas* canvas) override; | 35 void onPerCanvasPreDraw(SkCanvas* canvas) override; |
26 | 36 |
27 void drawMPDPicture() override { | 37 void drawMPDPicture() override { |
28 SkFAIL("MPD not supported\n"); | 38 SkFAIL("MPD not supported\n"); |
29 } | 39 } |
30 void drawPicture() override; | 40 void drawPicture() override; |
31 | 41 |
32 private: | 42 private: |
33 int fSteps; | 43 SkAutoTUnref<Animation> fAnimation; |
34 SkMatrix fAnimationMatrix; | 44 WallTimer fAnimationTimer; |
35 SkString fName; | 45 SkString fUniqueName; |
36 SkString fUniqueName; | 46 SkIRect fDevBounds; |
37 SkPoint fCenter; | |
38 | 47 |
39 typedef SKPBench INHERITED; | 48 typedef SKPBench INHERITED; |
40 }; | 49 }; |
41 | 50 |
42 #endif | 51 #endif |
OLD | NEW |