Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SKPAnimationBench.h
Go to the documentation of this file.
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 "bench/SKPBench.h"
12#include "src/base/SkRandom.h"
13#include "tools/timer/Timer.h"
14
15/**
16 * Runs an SkPicture as a benchmark by repeatedly drawing it, first centering the picture and
17 * for each step it concats the passed in matrix
18 */
20public:
21 class Animation : public SkRefCnt {
22 public:
23 virtual const char* getTag() = 0;
24 virtual void preConcatFrameMatrix(double animationTimeMs, const SkIRect& devBounds,
25 SkMatrix* drawMatrix) = 0;
26 };
27
28 SKPAnimationBench(const char* name, const SkPicture*, const SkIRect& devClip, sk_sp<Animation>,
29 bool doLooping);
30
31 static sk_sp<Animation> MakeZoomAnimation(SkScalar zoomMax, double zoomPeriodMs);
32
33protected:
34 const char* onGetUniqueName() override;
35 void onPerCanvasPreDraw(SkCanvas* canvas) override;
36
37 void drawMPDPicture() override {
38 SK_ABORT("MPD not supported\n");
39 }
40 void drawPicture() override;
41
42private:
43 sk_sp<Animation> fAnimation;
44 SkRandom fAnimationTime;
45 SkString fUniqueName;
46 SkIRect fDevBounds;
47
48 using INHERITED = SKPBench;
49};
50
51#endif
#define SK_ABORT(message,...)
Definition SkAssert.h:70
virtual void preConcatFrameMatrix(double animationTimeMs, const SkIRect &devBounds, SkMatrix *drawMatrix)=0
virtual const char * getTag()=0
void drawMPDPicture() override
const char * onGetUniqueName() override
void drawPicture() override
void onPerCanvasPreDraw(SkCanvas *canvas) override
static sk_sp< Animation > MakeZoomAnimation(SkScalar zoomMax, double zoomPeriodMs)
float SkScalar
Definition extension.cpp:12
const char * name
Definition fuchsia.cc:50