Flutter Engine
The Flutter Engine
SKPBench.h
Go to the documentation of this file.
1/*
2 * Copyright 2014 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 SKPBench_DEFINED
9#define SKPBench_DEFINED
10
11#include "bench/Benchmark.h"
15
16class SkSurface;
17
18/**
19 * Runs an SkPicture as a benchmark by repeatedly drawing it scaled inside a device clip.
20 */
21class SKPBench : public Benchmark {
22public:
23 SKPBench(const char* name, const SkPicture*, const SkIRect& devClip, SkScalar scale,
24 bool doLooping);
25 ~SKPBench() override;
26
27 bool shouldLoop() const override {
28 return fDoLooping;
29 }
30
34 bool getDMSAAStats(GrRecordingContext*) override;
35
36protected:
37 const char* onGetName() override;
38 const char* onGetUniqueName() override;
39 void onPerCanvasPreDraw(SkCanvas*) override;
40 void onPerCanvasPostDraw(SkCanvas*) override;
41 bool isSuitableFor(Backend backend) override;
42 void onDraw(int loops, SkCanvas* canvas) override;
43 SkISize onGetSize() override;
44
45 virtual void drawMPDPicture();
46 virtual void drawPicture();
47
48 const SkPicture* picture() const { return fPic.get(); }
49 const skia_private::TArray<sk_sp<SkSurface>>& surfaces() const { return fSurfaces; }
50 const SkTDArray<SkIRect>& tileRects() const { return fTileRects; }
51
52private:
54 const SkIRect fClip;
55 const SkScalar fScale;
56 SkString fName;
57 SkString fUniqueName;
58
59 skia_private::TArray<sk_sp<SkSurface>> fSurfaces; // for MultiPictureDraw
60 SkTDArray<SkIRect> fTileRects; // for MultiPictureDraw
61
62 const bool fDoLooping;
63
64 using INHERITED = Benchmark;
65};
66
67#endif
const char * backend
const skia_private::TArray< sk_sp< SkSurface > > & surfaces() const
Definition: SKPBench.h:49
~SKPBench() override
Definition: SKPBench.cpp:42
const char * onGetName() override
Definition: SKPBench.cpp:48
void onPerCanvasPreDraw(SkCanvas *) override
Definition: SKPBench.cpp:56
SKPBench(const char *name, const SkPicture *, const SkIRect &devClip, SkScalar scale, bool doLooping)
Definition: SKPBench.cpp:32
void getGpuStats(SkCanvas *, skia_private::TArray< SkString > *keys, skia_private::TArray< double > *values) override
Definition: SKPBench.cpp:184
const SkPicture * picture() const
Definition: SKPBench.h:48
void onPerCanvasPostDraw(SkCanvas *) override
Definition: SKPBench.cpp:99
bool getDMSAAStats(GrRecordingContext *) override
Definition: SKPBench.cpp:200
virtual void drawMPDPicture()
Definition: SKPBench.cpp:153
void onDraw(int loops, SkCanvas *canvas) override
Definition: SKPBench.cpp:120
const char * onGetUniqueName() override
Definition: SKPBench.cpp:52
virtual void drawPicture()
Definition: SKPBench.cpp:157
bool isSuitableFor(Backend backend) override
Definition: SKPBench.cpp:112
bool shouldLoop() const override
Definition: SKPBench.h:27
const SkTDArray< SkIRect > & tileRects() const
Definition: SKPBench.h:50
SkISize onGetSize() override
Definition: SKPBench.cpp:116
T * get() const
Definition: SkRefCnt.h:303
float SkScalar
Definition: extension.cpp:12
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
const Scalar scale
Definition: SkRect.h:32
Definition: SkSize.h:16