joshualitt | 261c3ad | 2015-04-27 09:16:57 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef SKPAnimationBench_DEFINED |
| 9 | #define SKPAnimationBench_DEFINED |
| 10 | |
| 11 | #include "SKPBench.h" |
cdalton | 63a8285 | 2015-06-29 14:06:10 -0700 | [diff] [blame] | 12 | #include "Timer.h" |
joshualitt | 261c3ad | 2015-04-27 09:16:57 -0700 | [diff] [blame] | 13 | |
| 14 | /** |
| 15 | * Runs an SkPicture as a benchmark by repeatedly drawing it, first centering the picture and |
| 16 | * for each step it concats the passed in matrix |
| 17 | */ |
| 18 | class SKPAnimationBench : public SKPBench { |
| 19 | public: |
cdalton | 63a8285 | 2015-06-29 14:06:10 -0700 | [diff] [blame] | 20 | class Animation : public SkRefCnt { |
| 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); |
joshualitt | 261c3ad | 2015-04-27 09:16:57 -0700 | [diff] [blame] | 32 | |
| 33 | protected: |
joshualitt | 261c3ad | 2015-04-27 09:16:57 -0700 | [diff] [blame] | 34 | const char* onGetUniqueName() override; |
| 35 | void onPerCanvasPreDraw(SkCanvas* canvas) override; |
| 36 | |
| 37 | void drawMPDPicture() override { |
| 38 | SkFAIL("MPD not supported\n"); |
| 39 | } |
| 40 | void drawPicture() override; |
| 41 | |
| 42 | private: |
Hal Canary | 2db8361 | 2016-11-04 13:02:54 -0400 | [diff] [blame] | 43 | sk_sp<Animation> fAnimation; |
| 44 | WallTimer fAnimationTimer; |
| 45 | SkString fUniqueName; |
| 46 | SkIRect fDevBounds; |
joshualitt | 261c3ad | 2015-04-27 09:16:57 -0700 | [diff] [blame] | 47 | |
| 48 | typedef SKPBench INHERITED; |
| 49 | }; |
| 50 | |
| 51 | #endif |