blob: b7a4ae13786068dd796d7fb3b7691895b145cc8e [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 {
Ben Wagnerb4aab9a2017-08-16 10:53:04 -040038 SK_ABORT("MPD not supported\n");
joshualitt261c3ad2015-04-27 09:16:57 -070039 }
40 void drawPicture() override;
41
42private:
Hal Canary2db83612016-11-04 13:02:54 -040043 sk_sp<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