blob: c0bef308ec2e74c452580d3f7f22423f18016282 [file] [log] [blame]
joshualitt261c3ad2015-04-27 09:16:57 -07001/*
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"
cdalton63a82852015-06-29 14:06:10 -070012#include "Timer.h"
joshualitt261c3ad2015-04-27 09:16:57 -070013
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 */
18class SKPAnimationBench : public SKPBench {
19public:
cdalton63a82852015-06-29 14:06:10 -070020 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);
joshualitt261c3ad2015-04-27 09:16:57 -070032
33protected:
joshualitt261c3ad2015-04-27 09:16:57 -070034 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
42private:
cdalton63a82852015-06-29 14:06:10 -070043 SkAutoTUnref<Animation> fAnimation;
44 WallTimer fAnimationTimer;
45 SkString fUniqueName;
46 SkIRect fDevBounds;
joshualitt261c3ad2015-04-27 09:16:57 -070047
48 typedef SKPBench INHERITED;
49};
50
51#endif